user2231217
user2231217

Reputation: 11

Can not send mail from external SMTP on heroku?

I used the following code in my app to send a mail from my heroku app

<?php
    require("PHPMailer-master/class.phpmailer.php");
    require("PHPMailer-master/class.smtp.php");
    $mail = new PHPMailer();
    $mail->IsSMTP();  // telling the class to use SMTP
    $mail->Host     = "smtp.gmail.com"; // SMTP server
    $mail->From     = "[email protected]";
    $mail->AddAddress("[email protected]");
    $mail->Subject  = "First PHPMailer Message";
    $mail->Body     = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
    $mail->WordWrap = 50;
    if(!$mail->Send()) {
        echo 'Message was not sent.';
        echo 'Mailer error: ' . $mail->ErrorInfo;
    }else {
        echo 'Message has been sent.';
    }
?>

But, my app is showing up "Message was not sent.Mailer error: The following From address failed: [email protected] : MAIL FROM command failed,530,5.7.0 Must issue a STARTTLS command first. h20sm18987465qen.5 - gsmtp" \n Can any one help me to solve this problem.Thanks.

Upvotes: 1

Views: 1811

Answers (1)

Manuel van Rijn
Manuel van Rijn

Reputation: 10305

I think this more a issue with your smtp config's See this answer: https://stackoverflow.com/a/16048485/959041

Does your code work on your local machine?

Upvotes: 1

Related Questions