如何使用zend框架发送电子邮件

时间:2016-06-17 11:53:56

标签: php email zend-framework

我使用Zend API发送电子邮件,但经过多次测试仍然无法发送任何电子邮件。

这是我的剧本:

set_include_path( get_include_path().PATH_SEPARATOR.dirname(__FILE__).'/lib');
set_include_path( get_include_path().PATH_SEPARATOR.dirname(__FILE__).'/lib/Zend');
error_reporting(E_ERROR);
ini_set("max_execution_time",0);
session_save_path(dirname(__FILE__));
include_once 'SMTPMailer.php';
include_once 'email_validation.php';

.....

$validator=new email_validation_class();
$smtpMailer = new SMTPMailer();
if ($smtpMailer->sendEmails($to,$attachmentArray) === true) {
    print '<font size="5" color="#0000FF"> ... Successfull!</font><br>';
} else {
    print '<font color="#FF0000"> ... Aborted!</font><br>';
}

运行脚本后,输出“...已中止!”

这是Zend sendEmails功能:

public function sendEmails($to,$attachment = array ()) {
    try{
        $this->mailer = new Zend_Mail ();
        var_dump($this->smtpTransport);
        if ($this->mailType == 'html') {

            $this->mailer->setBodyHtml($this->getMailBody());
        }else{
            $this->mailer->setBodyText($this->getMailBody());
        }

        $this->mailer->setFrom($this->mailFromEmail, $this->mailFrom);
        $this->mailer->addTo($to);
        $this->mailer->setSubject($this->mailSubject);
        if (!empty($attachment)) {
            $this->mailer->createAttachment($attachment['data'],$attachment['type'],Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64,$attachment['name']);
        }

        $this->mailer->send($this->smtpTransport);
        return true;
    } catch (Zend_Exception $e) {
        return false;   
    }
}

这是var_dump($this->smtpTransport)

的输出
  

发送邮件至david@gmail.com ... object(Zend_Mail_Transport_Smtp)#3   (15){[“EOL”] =&gt; string(1)“”[“_ host”:protected] =&gt;串(27)   “smtpout.supvttor2026.com”[“_ port”:protected] =&gt; string(2)“25”   [ “_name”:保护] =&GT; string(9)“localhost”[“_ auth”:protected] =&gt;   string(5)“login”[“_ config”:protected] =&gt; array(4){[“auth”] =&gt;   string(5)“login”[“username”] =&gt; string(24)“info@supvttor2026.com”   [ “密码”] =&GT; string(9)“david1976”[“port”] =&gt; string(2)“25”}   [ “_connection”:保护] =&GT; NULL [“body”] =&gt; string(0)“”   [ “边界”] =&GT; string(0)“”[“header”] =&gt; string(0)“”   [ “_headers”:保护] =&GT; array(0){} [“_ isMultipart”:protected] =&gt;   bool(false)[“_ mail”:protected] =&gt; bool(false)[“_ parts”:protected] =&gt;   array(0){} [“recipients”] =&gt; string(0)“”}

我的凭据是正确的,域名,用户,密码和端口都很完美。 你能帮我找出问题所在吗

0 个答案:

没有答案