I'm trying to send email with PHPMailer. Here is my code:
<?php
require_once('PHPMailer/PHPMailerAutoload.php');
class Mail {
public static function sendMail($subject, $body, $address) {
$mail = new PHPMailer();
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = 'ssl://sub5.mail.dreamhost.com';
$mail->Port = '587';
$mail->isHTML();
$mail->Username = 'user@name.com';
$mail->Password = 'password';
$mail->SetFrom('user@name.com');
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($address);
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->Send();
}
}
?>
And then
Mail::sendMail('New message', $body, $email);
This is the error I get:
SMTP ERROR: Failed to connect to server: (0)
SMTP connect() failed.
https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
I read the Troubleshooting but it didn't help. I also read help articles by Dreamhost, but they are vague.
I'm wondering if it's something specific to Dreamhost that I need to do?