我正在开发一个必须发送邮件的webapp,我正在使用以下接口类使用基本邮件路由器(如果我没错,则是sendmail):
class My_Mail_Interface
{
protected $_defaultCharset = 'utf-8';
public function __construct() {
$this->init();
}
public function init() {
}
/**
* Send the email
* @param string $from the sender address
* @param string $to the receiver address
* @param string $subject the subject
* @param string $bodyHtml the HTML message
* @param string $bodyText the text message
* @param string $sender the sender label
* @param string $receiver the receiver label
* @return void
*/
public function send($from, $to, $subject, $bodyHtml = NULL, $bodyText = NULL, $sender = NULL, $receiver = NULL) {
if (!isset($sender)) {
$sender = $from;
}
if (!isset($receiver)) {
$receiver = $to;
}
$mail = $this->_getNewMail();
$mail->setFrom($from, $sender);
$mail->addTo($to, $receiver);
$mail->setSubject($subject);
$mail->setBodyHtml($bodyHtml);
$mail->setBodyText($bodyText);
$mail->send();
}
/**
* Get a new mail object
* @return Zend_Mail
*/
protected function _getNewMail() {
return new Zend_Mail($this->_defaultCharset);
}
}
当它向Yahoo地址发送电子邮件时它工作正常,但在向GMail发送电子邮件时失败。我打算将来转移到像SendGrid这样的邮件服务,但是出于测试目的,使用这种配置应该不是问题。有没有一点我缺席或GMail成为SPAM的偏执狂?