PHPMailer

PHPMailer is a PHP email transport class featuring file attachments, SMTP servers, CCs, BCCs, HTML messages, word wrap, and more. Sends email via sendmail, PHP mail, QMail, or with SMTP.

Download and installation

 * 1) Get the PHPMailer files from Github.
 * 2) Copy the class.phpmailer.php, class.smtp.php, and class.pop3.php files your site using an SFTP client.
 * 3) Use PHPMailer according to your needs.

Note: Older versions of PHP may also need to use PHPMailerAutoload. More information is in this PHPMailer support thread. You can check and adjust your site's PHP version in the panel's Manage Domains page, click the Edit button to see the PHP Mode setting.

Basic code example
This basic code will send emails. require("(location of files)/class.phpmailer.php"); $mail = new PHPMailer; $mail->IsSMTP;                                     // set mailer to use SMTP $mail->Host = "localhost"; // specify main and backup server $mail->SMTPAuth = true;    // turn on SMTP authentication $mail->Username = "your_ssh_username";       // Make sure to replace this with your shell enabled user $mail->Password = "your_ssh_user_password";     // Make sure to use the proper password for your user $mail->From = "me@mydomain"; $mail->FromName = "Your Name"; $mail->AddAddress("recipient@theirdomain", "Their Name"); $mail->AddCC("cc@ccdomain"); $mail->AddBCC("bcc@bccdomain");

$mail->AddReplyTo("me@mydomain", "me"); $mail->WordWrap = 50;                                // set word wrap to 50 characters $mail->IsHTML(true);                                 // set email format to HTML $mail->Subject = "PHPmailer example"; $mail->Body   = "This is a test of email"; if(!$mail->Send){ echo "Message could not be sent. "; echo "Mailer Error: ". $mail->ErrorInfo; exit; }

More examples are available at http://phpmailer.sourceforge.net/tutorial.html.

NOTE: If you use localhost (aka the web server) then you will want to use your FTP/SSH username and password.

Want to use mail.yourDomain.com instead of localhost?
This is assuming that your @yourDomain.com email addresses are hosted with DreamHost:


 * If you want to use mail.yourDomain.com (aka the mail server) you will need to use your email address's username and password, the username will be the full email address.

If you wish to use a third-party's SMTP server (like gmail) you may, just use their mail hostname, and the username and password you use to access that specific email address's inbox.

Using PHPMailer with Drupal's SunMailer
Drupal's SunMailer module requires PHPMailer. To set up PHPMailer for SunMailer:
 * 1) Follow download instructions above.
 * 2) In the SunMailer PHPMailer configuration settings, indicate the path of your class.phpmailer.php file on your Dreamhost site.
 * 3) In the SunMailer PHPMailer configuration settings, indicate a test email address and click "Send test email"

Important Information
Any bulk email of any kind sent from a DreamHost account is subject to the DreamHost spam policy which is part of the terms of service.

Port 587 is open for connecting to any mail server anywhere. Port 25 can only be used to connect to a DreamHost mail server.