无法使用php通过heroku发送电子邮件

时间:2018-01-17 12:31:06

标签: php email heroku

我是heroku的新手,我试图在heroku中使用php发送电子邮件,但它不会发送任何电子邮件,php工作正常,但邮件无法正常工作,我搜索了它并查找,其工作仅与添加-ons,插件和那种,我试过PHPmailer库,并尝试了这个代码,它是phpmailer提到的例子

    <?php 

       $mail = new PHPMailer(false); // Passing true enables exceptions

        //Server settings
        //$mail->SMTPDebug = 1;//Enable verbose debug output
        $mail->isSMTP();//Set mailer to use SMTP
        $mail->Host = 'smtp.gmail.com';//Specify main and backup SMTP servers
        $mail->SMTPAuth = true;//Enable SMTP authentication
        $mail->Username = 'example@gmail.com';//SMTP username
        $mail->Password = 'mypassword';//SMTP password
        $mail->SMTPSecure = 'tls';//Enable TLS encryption, `ssl` also accepted
        $mail->Port = 465;//TCP port to connect to


        //Recipients
        $mail->setFrom('example@gmail.com','myapp');
        $mail->addAddress('example@gmail.com');//Add a recipient
        //$mail->addAddress('example@gmail.com');//Name is optional
        $mail->addReplyTo('example@gmail.com','Contact');



        //Content
        $mail->isHTML(true);//Set email format to HTML
        $mail->Subject = 'test';

        $mail->Body    = 'this is a test';


        $mail->send();
?>

我是初学者,请帮助我让它与heroku一起工作:(我知道如何在PHP中运行,并且这样可以正常工作,但在heroku中,不工作,似乎需要插件......一步一步解释,感谢您提前回答@&gt;

0 个答案:

没有答案
相关问题