cakephp 2.8与1.3 smtp的差异会导致550错误
我们最近将一个应用程序从Cakephp 1.3更新为2.8版 我们使用该应用程序通过单独的SMTP服务器向客户发送订单信息电子邮件。一次可以发送多达1000条消息 我们的1.3应用程序用于愉快地批量发送邮件,而不会产生超过最大收件人配额550的邮件,即使是对于超过SMTP服务器上最大收件人级别的卷也是如此。SMTP服务器尚未更改。“最大收件人”级别设置为每小时500个,一如既往 Cakephp版本2有一种处理电子邮件的新方法(CakeEmail): CakePHP1.3和CakePHP2.8通过SMTP方法发送电子邮件的方式肯定有根本性的区别,但我真的很难看出这一点。有人能帮忙吗 相关代码如下所示 ///1.3代码cakephp 2.8与1.3 smtp的差异会导致550错误,cakephp,Cakephp,我们最近将一个应用程序从Cakephp 1.3更新为2.8版 我们使用该应用程序通过单独的SMTP服务器向客户发送订单信息电子邮件。一次可以发送多达1000条消息 我们的1.3应用程序用于愉快地批量发送邮件,而不会产生超过最大收件人配额550的邮件,即使是对于超过SMTP服务器上最大收件人级别的卷也是如此。SMTP服务器尚未更改。“最大收件人”级别设置为每小时500个,一如既往 Cakephp版本2有一种处理电子邮件的新方法(CakeEmail): CakePHP1.3和CakePHP2.8通
$config['smtp'] = array(
'port'=>'25',
'timeout'=>'30',
'host' => 'mail.smtpservername.com',
'username'=>'smtp@domainname.com',
'password'=>'password'
);
private function send_email($customer, $email_message) {
$this->Email->from = 'Sender Name <address@domain.com>';
$this->Email->smtpOptions = array(
'port'=>Configure::read('smtp.port'),
'timeout'=>Configure::read('smtp.timeout'),
'host' => Configure::read('smtp.host'),
'username'=>Configure::read('smtp.username'),
'password'=>Configure::read('smtp.password')
);
$this->Email->delivery = 'smtp';
$this->Email->to = $customer['first_name'].' '.$customer['last_name'].' <'.$customer['email_address'].'>';
$this->Email->subject = 'A nice subject line';
$this->Email->sendAs = 'text';
$this->Email->template = 'simple_message';
$this->set('email_content', $email_message);
if (!$this->Email->send()) {
CakeLog::write('error', "Sending email to customer {$customer['id']} failed.");
throw new EmailNotSentException("Sending email to customer {$customer['id']} failed.\n\n".$email_message);
}
$this->Email->reset();
return true;
}
$config['smtp'] = array(
'port' => '25',
'timeout' => '30',
'host' => 'mail.smtpservername.com',
'username' => 'smtp@domainname.com',
'password' => 'password',
'transport' => 'Smtp'
);
private function send_email($customer, $email_message)
{
$Email = new CakeEmail;
$Email->config(Configure::read('smtp'));
$from = array('address@domain.com' => 'Sender Name');
$recipient = array($customer['email_address'] => $customer['first_name'] . ' ' . $customer['last_name']);
$subject = 'A nice subject line';
$Email->from($from);
$Email->to($recipient);
$Email->subject($subject);
$Email->emailFormat('text');
$Email->template('simple_message');
$Email->viewVars(array('email_content' => $email_message));
if (! $Email->send()) {
CakeLog::write('error', "Sending email to customer {$customer['id']} failed.");
throw new EmailNotSentException("Sending email to customer {$customer['id']} failed.\n\n".$email_message);
}
$Email->reset();
return true;
}