1

我正在开发一个必须发送邮件的 web 应用程序,我正在使用带有以下接口类的基本邮件路由器(如果我没记错的话就是 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);
    }

}

它在向雅虎地址发送电子邮件时工作正常,但在向 GMail 发送电子邮件时失败。我计划将来转移到像 SendGrid 这样的邮件服务,但是为了测试目的,使用这个配置应该不是问题。是否有一点我遗漏或 GMail 已成为垃圾邮件偏执狂?

4

0 回答 0