不能通过SMTP发送电子邮件,因为“550 -继电器不允许”

时间:2021-01-09 18:11:46

I'm using CakePHP to send automated emails to clients. It's been working great, but it seems some recipients aren't receiving our emails. So I decided to use the SMTP option for sending emails, and route emails through our email provider at Media Temple. However, when trying to send email from a Media Temple account, I get the error "550- relay not permitted". That sounds like the Media Temple server is just plain not allowing me to send mail through it. That's odd because I've confirmed the username and password I'm using is correct and I can send mail via SMTP through it from my macmail client and iPhone mail client. I've also confirmed my cakephp email settings are correct, because I can send emails via SMTP with a gmail account with the exact same configuration in cakephp. Any idea why I'm getting this error and how to resolve it? Thanks

我正在使用CakePHP向客户发送自动邮件。它工作得很好,但似乎有些收件人没有收到我们的邮件。所以我决定使用SMTP选项来发送电子邮件,并通过我们的电子邮件提供商在Media Temple发送电子邮件。然而,当我试图从一个媒体圣殿的帐户发送电子邮件时,我得到了错误“550-继电器不允许”。听起来好像媒体圣殿服务器不允许我通过它发送邮件。这很奇怪,因为我已经确认我使用的用户名和密码是正确的,我可以通过SMTP从我的macmail客户端和iPhone邮件客户端发送邮件。我还确认了我的cakephp电子邮件设置是正确的,因为我可以通过SMTP发送电子邮件,带有gmail帐户,在cakephp中配置完全相同。你知道我为什么会犯这个错误,怎么解决吗?谢谢

Here's the code that handles sending an email. I use this class just like the regular EmailComponent from within many different controllers.

这是处理发送电子邮件的代码。我使用这个类就像普通的电子邮件组件一样来自于许多不同的控制器。

    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;
   }
}

2 个解决方案

#1


0  

The main problem I was having was that clients weren't receiving emails from our server, (and so I wanted to use an SMTP server to see if that would fix it, instead of the server's default email server). But I managed to get those clients to receive emails from the server by making some other changes, thus removing the need to use SMTP and the Media Temple email server. (As an FYI, I found that we were getting bouncebacks from client email servers stating Diagnostic-Code: smtp; 550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1), but they were being sent directly back to the server, and going into the linux user account "www-data". (I read them in /var/mail/www-data, just using tail and vim). I found that postfix, which was handling the sending of emails, was marking the email sender's hostname (ie, "HELO name") as canadafinds3, the name I gave the server in Rackspace, not the domain name: canadafinds.com. So I changed that in /etc/postfix/main.cf, restarted postfix, et voila! No more bouncebacks from those particular clients, and everyone's happy again.)

我遇到的主要问题是客户端没有从我们的服务器接收电子邮件(因此我想使用SMTP服务器来查看是否可以修复它,而不是服务器的默认电子邮件服务器)。但是我设法让这些客户端通过做一些其他更改从服务器接收电子邮件,从而消除了使用SMTP和Media Temple电子邮件服务器的需要。(作为一个参考,我发现我们正在从客户端电子邮件服务器获得返回,说明诊断代码:smtp;拒绝访问——无效的HELO名称(参见RFC2821 4.1.1.1),但是它们被直接发送回服务器,并进入linux用户帐户“www-data”。(我在/var/mail/www-data中读到它们,只使用tail和vim)。我发现postfix(处理邮件发送)将邮件发送者的主机名(即“HELO name”)标记为canadafinds3,这是我在Rackspace中给服务器的名称,而不是域名:canadafinds.com。我把它改成了/etc/ postfix/main_。cf,重启后缀,瞧!再也不能从这些特定的客户那里得到回报了,每个人都重新开心起来。

#2


0  

I ended up writing my own PHP mail() script based on http://www.dreamincode.net/forums/topic/36108-send-emails-using-php-smtp-direct/ in order to circumvent this error.

我最后基于http://www.dreamincode.net/forums/topic/36108-send-emails-using-php-smtp-direct/编写了我自己的PHP mail()脚本,以避免这个错误。

#1


0  

The main problem I was having was that clients weren't receiving emails from our server, (and so I wanted to use an SMTP server to see if that would fix it, instead of the server's default email server). But I managed to get those clients to receive emails from the server by making some other changes, thus removing the need to use SMTP and the Media Temple email server. (As an FYI, I found that we were getting bouncebacks from client email servers stating Diagnostic-Code: smtp; 550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1), but they were being sent directly back to the server, and going into the linux user account "www-data". (I read them in /var/mail/www-data, just using tail and vim). I found that postfix, which was handling the sending of emails, was marking the email sender's hostname (ie, "HELO name") as canadafinds3, the name I gave the server in Rackspace, not the domain name: canadafinds.com. So I changed that in /etc/postfix/main.cf, restarted postfix, et voila! No more bouncebacks from those particular clients, and everyone's happy again.)

我遇到的主要问题是客户端没有从我们的服务器接收电子邮件(因此我想使用SMTP服务器来查看是否可以修复它,而不是服务器的默认电子邮件服务器)。但是我设法让这些客户端通过做一些其他更改从服务器接收电子邮件,从而消除了使用SMTP和Media Temple电子邮件服务器的需要。(作为一个参考,我发现我们正在从客户端电子邮件服务器获得返回,说明诊断代码:smtp;拒绝访问——无效的HELO名称(参见RFC2821 4.1.1.1),但是它们被直接发送回服务器,并进入linux用户帐户“www-data”。(我在/var/mail/www-data中读到它们,只使用tail和vim)。我发现postfix(处理邮件发送)将邮件发送者的主机名(即“HELO name”)标记为canadafinds3,这是我在Rackspace中给服务器的名称,而不是域名:canadafinds.com。我把它改成了/etc/ postfix/main_。cf,重启后缀,瞧!再也不能从这些特定的客户那里得到回报了,每个人都重新开心起来。

#2


0  

I ended up writing my own PHP mail() script based on http://www.dreamincode.net/forums/topic/36108-send-emails-using-php-smtp-direct/ in order to circumvent this error.

我最后基于http://www.dreamincode.net/forums/topic/36108-send-emails-using-php-smtp-direct/编写了我自己的PHP mail()脚本,以避免这个错误。