The magic of PHPMailer

November 10, 2013 - 2 minutes
Educational

Recently I updated the website for my club, the Association for Women in Computing at WWU, to send e-mails via PHPMailer. We have a contact form with the usual subject, content, name, etc. and want to send all that to our e-mail address. The previous e-mail system went through the school’s network  and was very much broken, so it was in need of a good fix.

It was easier than I thought it would be, mostly just building some basic PHPMailer code. Add the script to your site, create a new instance of PHPMailer, and set the various properties on that instance. For example, if your mailer is $mail, you set the subject of the email like so: $mail->Subject ="E-mail subject here";

Then once you’re done adding all the properties, you do $mail->Send, and you’re good to go! For the server, I ended up just creating a new Gmail e-mail address so I could use Gmail as a host. So our host property looked something like this: $mail->Host = "smtp.gmail.com";