Email Issues

March 16, 2014 3k views
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?
2 Answers
I think you're missing the Port configuration, Gmail uses port 465 or 587 for SMTP. Take a look at this:
What's the output of
telnet 25
Have another answer? Share your knowledge.