Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Build a Basic PHP Website (2018) Enhancing a Form Escaping Output

phpmailer auto reply

Hi, is there anyway i can make a Auto Reply so when they for example press Submit Media it automatically let's them know we got their email in a email? Searched through the web but with no luck really..

1 Answer

Of course. You just add the PHPMailer function to your code and it will run every time you ask it to.

For instance - make sure you include the PHPMailer autoloader in your include files.

Then - just an example - set your HTML form action to direct itself to a PHP script page upon someone hitting SUBMIT that includes the PHP Mailer function filled out to your specifications. You can then redirect back to any page or a thank you page or whatever you'd like after the mail script executes (usually something along the line of the following):

 if(!$mail->send()) {
          echo 'There was an error sending the contact form email. <br>';
          echo 'Mailer Error: ' . $mail->ErrorInfo;
      }  else {

I hope this helps at all!