Email Issues

  • Posted March 16, 2014

I’ve moved my app over to digitalocean but my notifications aren’t working. I’m using Ubuntu. I’m using php mailer and using the following function function sendEmail($subject, $body, $altbody, $fromEmail, $fromName, $replyToEmail, $to, $cc, $bcc) { $mail = new PHPMailer;

$mail->IsSMTP(); // Set mailer to use SMTP $mail->Host = ‘’; // Specify main and backup server $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = ‘GMAIL ADDRESS’; // SMTP username $mail->Password = ‘PASSWORD’; // SMTP password $mail->SMTPSecure = ‘tls’; // Enable encryption, ‘ssl’ also accepted

$mail->From = $fromEmail; $mail->FromName = $fromName; //$mail->AddAddress(‘RECIPIENT EMAIL’); // Add a recipient $mail->AddReplyTo($replyToEmail); $mail->AddAddress($to); // Name is optional $mail->AddCC($cc); $mail->AddBCC($bcc);

$mail->WordWrap = 50; // Set word wrap to 50 characters //$mail->AddAttachment(‘/var/tmp/file.tar.gz’); // Add attachments //$mail->AddAttachment(‘/tmp/image.jpg’, ‘new.jpg’); // Optional name $mail->IsHTML(true); // Set email format to HTML

$mail->Subject = $subject; $mail->Body = $body; $mail->AltBody = $altbody;

if(!$mail->Send()) { echo ‘Message could not be sent.’; echo 'Mailer Error: ’ . $mail->ErrorInfo; exit; } else { echo “Message has been sent”; }

but I’m getting the error "Message could not be sent.Mailer Error: SMTP Connect() failed.thorn@BlackThorn:~$ "

What should I be using?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

What’s the output of <pre>telnet 25</pre>?

I think you’re missing the Port configuration, Gmail uses port 465 or 587 for SMTP. Take a look at this: <br>