我正在使用CakePHP向客户发送自动邮件。一直很好用,但是似乎有些收件人没有收到我们的邮件。所以我决定使用SMTP选项来发送邮件,并通过我们的电子邮件提供商Media Temple路由电子邮件。
然而,在尝试从Media Temple帐户发送电子邮件时,我收到了“550-中继不允许”的错误信息。
这听起来像Media Temple服务器根本不允许我通过它发送邮件。
这很奇怪,因为我已经确认了我使用的用户名和密码是正确的,并且我可以通过我的macmail客户端和iPhone邮件客户端通过它发送邮件。我还确认了我的cakephp电子邮件设置是正确的,因为我可以使用与cakephp中完全相同的配置通过SMTP发送gmail帐户的电子邮件。
您知道我为什么会收到此错误消息以及如何解决它吗?
谢谢
以下是处理发送电子邮件的代码。我像常规EmailComponent一样在许多不同的控制器中使用此类。
以下是处理发送电子邮件的代码。我像常规EmailComponent一样在许多不同的控制器中使用此类。
class CanadafindsEmailerComponent extends EmailComponent
{
...
function send($content = null, $template = null, $layout = null) {
if(!in_array(TECHY_MONITOR_EMAIL,$this->bcc) && is_array($this->bcc))
$this->bcc[]=TECHY_MONITOR_EMAIL;
else if (!in_array(TECHY_MONITOR_EMAIL,$this->bcc) && !is_array($this->bcc))
$this->bcc=array(TECHY_MONITOR_EMAIL);
if(DEVSITE){//commented-out code are settings for smtp with gmail, which works fine
$this->delivery = 'smtp';
$this->smtpOptions = array(
'port'=>'465',//'465',
'timeout'=>'30',//'30',
'auth' => true,
'host' => 'ssl://mail.thenumber.biz',//'ssl://smtp.gmail.com',
'username'=>USERNAME,//'USERNAME@gmail.com',
'password'=>SMTP_PASSWORD//,
);
$this->to=$this->correctFormatOn($this->to);
$this->bcc=$this->correctFormatOn($this->bcc);
$this->cc=$this->correctFormatOn($this->cc);
$this->replyTo=$this->correctFormatOn($this->replyTo);
$this->from=$this->correctFormatOn($this->from);
}
return parent::send($content,$template,$layout);
}
function correctFormatOn(&$email){
if(is_array($email)){
$copiedEmail=array();
foreach($email as $singleEmail){
$copiedEmail[]=$this->correctFormatOnSingle($singleEmail);
}
$email=$copiedEmail;
}else{
$email=$this->correctFormatOnSingle($email);
}
return $email;
}
function correctFormatOnSingle(&$email){
$subEmails=explode(",",$email);
$fixedSubEmails=array();
foreach($subEmails as $subEmail){
$fixedSubEmails[]=preg_replace('/<?([^< ]+)@([^>,]+)[>,]?/i', '<$1@$2>', trim($subEmail));
}
$email=implode(",",$fixedSubEmails);
return $email;
}
}
$this->smtpOptions = array( 'port'=>'465', 'timeout'=>'30', 'auth' => true, 'host' => 'ssl://mail.thenumber.biz', 'username'=>'michael@thenumber.biz', 'password'=>{password}, );
它还建议如果是新服务器,则无法工作,但我们已经使用桌面客户端成功发送电子邮件多年了。 - thespacecamel