使用Swift邮件程序SmtpTransport

时间:2016-06-18 16:33:41

标签: php heroku

为了测试,我想从我的Heroku服务器发送带有硬编码消息的电子邮件。当我调用页面“sendMessage.php”时,我在Heroku上收到500错误。为了调查500错误,我将代码放在MAMP下来调查日志错误。当我这样做时,我得到以下语法错误:

PHP Parse error:  syntax error, unexpected '$transport' (T_VARIABLE) in /Applications/MAMP/htdocs/sendmail.php on line 6

这是我的代码的样子。我从github下载了最新版本的swift邮件程序。任何帮助将不胜感激。谢谢!

<?php 

 require 'SwiftMailer/lib/swift_required.php'


$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com',465,'ssl')
            ->setUserName('FOO@gmail.com')
            ->setPassword('BAR');


$swift = Swift_Message::newInstance($transport)


$content = "This is a test message.";



$message = Swift_Message::newInstance("This is a test email")
            ->setFrom("FOO@gmail.com")
            ->setTo('BAR@gmail.com')
            ->setBody($content,'text/html')
            ->addPart(strip_tags($content),'text/plain');



$swift->send($message);


?>

1 个答案:

答案 0 :(得分:0)

您在两行中缺少半冒号canvas.onmousemove = function(e) { var boundingRect = this.Yes.getBounds(this); if(isMouseOverSymbol(e.offsetX, e.offsetY, boundingRect)) { this.YesHOT.setVisible(true); } }.bind(this); //Function to check whether the specified point lies within the rect. function isMouseOverSymbol(pointX, pointY, rect) { if(rect.left <= pointX && pointX <= rect.left + rect.width) if(rect.top <= pointY && pointY <= rect.top + rect.height) return true; return false; } 。 这是更正。

;