无法通过SMTP发送电子邮件,因为出现“550-中继不允许”的错误提示。

4
我正在使用CakePHP向客户发送自动邮件。一直很好用,但是似乎有些收件人没有收到我们的邮件。所以我决定使用SMTP选项来发送邮件,并通过我们的电子邮件提供商Media Temple路由电子邮件。 然而,在尝试从Media Temple帐户发送电子邮件时,我收到了“550-中继不允许”的错误信息。 这听起来像Media Temple服务器根本不允许我通过它发送邮件。 这很奇怪,因为我已经确认了我使用的用户名和密码是正确的,并且我可以通过我的macmail客户端和iPhone邮件客户端通过它发送邮件。我还确认了我的cakephp电子邮件设置是正确的,因为我可以使用与cakephp中完全相同的配置通过SMTP发送gmail帐户的电子邮件。 您知道我为什么会收到此错误消息以及如何解决它吗? 谢谢
以下是处理发送电子邮件的代码。我像常规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;
   }
}

3
请点击此处:Media Temple SMTP问题的故障排除 - paulsm4
听起来正是我需要的,但建议并没有帮助。关于“中继被拒”的部分基本上说要验证我是否使用密码身份验证,以下是我的cakephp设置: $this->smtpOptions = array( 'port'=>'465', 'timeout'=>'30', 'auth' => true, 'host' => 'ssl://mail.thenumber.biz', 'username'=>'michael@thenumber.biz', 'password'=>{password}, ); 它还建议如果是新服务器,则无法工作,但我们已经使用桌面客户端成功发送电子邮件多年了。 - thespacecamel
你的 PHP 代码是否与你测试时的 Mac/iPhone 来自同一域?我认为某些中继还需要传入连接来自受信任的 IP 范围。 - eaj
@Hoff 当然,我会发布代码,尽管它相当复杂。 - thespacecamel
你尝试过使用587端口吗?不确定这是否会有所不同...另外,我不知道你是否想要在代码中发布你的电子邮件地址..哈哈 - Hoff
显示剩余2条评论
2个回答

0
我遇到的主要问题是客户无法从我们的服务器接收电子邮件,因此我想使用SMTP服务器来查看是否可以解决这个问题,而不是使用服务器的默认电子邮件服务器。 但是,通过进行一些其他更改,我成功让那些客户从服务器接收电子邮件,因此不再需要使用SMTP和Media Temple电子邮件服务器。 (作为FYI,我发现我们从客户端电子邮件服务器收到了退回邮件,指出Diagnostic-Code: smtp; 550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1),但它们直接发送回服务器,并进入Linux用户帐户“www-data”。(我在/var/mail/www-data中读取它们,只使用tail和vim)。我发现处理电子邮件发送的postfix将电子邮件发送者的主机名(即“HELO名称”)标记为canadafinds3,在Rackspace中我给服务器命名的名称,而不是域名:canadafinds.com。因此,我在/etc/postfix/main.cf中进行了更改,重新启动了postfix,et voila!那些特定客户不再有退回邮件,每个人都很高兴。)


0

https://web.archive.org/web/20180401094709/http://www.dreamincode.net/forums/topic/36108-send-emails-using-php-smtp-direct/ - JayRizzo

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接