从本地WAMP服务器向google帐户(PHP、MySQL、SwiftMailer)正确注册后向管理员发送电子邮件
在正确的用户注册之后(数据被记录到数据库并且注册运行正常),我想收到一封发送到gmail帐户的电子邮件,确认成功。我正在WAMP本地服务器上工作,并且正在使用SwiftMailer库 下面的代码,不幸的是这封电子邮件没有发送给我从本地WAMP服务器向google帐户(PHP、MySQL、SwiftMailer)正确注册后向管理员发送电子邮件,php,mysql,swiftmailer,Php,Mysql,Swiftmailer,在正确的用户注册之后(数据被记录到数据库并且注册运行正常),我想收到一封发送到gmail帐户的电子邮件,确认成功。我正在WAMP本地服务器上工作,并且正在使用SwiftMailer库 下面的代码,不幸的是这封电子邮件没有发送给我 <?php $transporter = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl') ->setUsername('testphp201
<?php
$transporter = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')
->setUsername('testphp2017@gmail.com')
->setPassword('testxxx');
$mailer = Swift_Mailer::newInstance($transporter);
$mailer = Swift_Mailer::newInstance($transporter);
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('testphp2017@gmail.com'))
->setTo(array('testphp2017@gmail.com'))
->setBody('Test Message Body')
;
您的代码缺少发送功能:
$result = $mailer->send($message);
你的错误日志怎么说?是的,我的不好,但在注册后添加了这行代码之后,chrome显示:预期响应代码250,但得到代码“535”,并显示消息“535-5.7.8用户名和密码不被接受。更多信息,请访问535 5.7.8 s26sm403221ljd.27-gsmtp”您是否验证了您使用的用户名和密码是否正确?此问题出现在google帐户的安全设置中。但是谢谢你,杰森,谢谢你的代码行。我不知道我怎么能忘记那件事;)