无法在codeigniter中发送电子邮件

时间:2017-12-04 05:14:45

标签: php codeigniter email

我使用codeigniter电子邮件库发送邮件。以下是我的 email.php库文件配置

public $useragent   = 'CodeIgniter';

public $mailpath    = '/usr/sbin/sendmail'; // Sendmail path

public $protocol    = 'smtp';       // mail/sendmail/smtp

public $smtp_host   = 'smtp.mailhostbox.com';

public $smtp_user   = 'myemailid';

public $smtp_pass   = 'mypassword';

public $smtp_port   = 25;

public $smtp_timeout    = 5;

public $smtp_keepalive  = FALSE;

public $smtp_crypto = '';

public $wordwrap    = TRUE;

public $wrapchars   = 76;

public $mailtype    = 'html';

public $charset     = 'iso-8859-1';

这是我在控制器中的发送电子邮件功能:

$message = '<div>test</div>';
$this->email->message($message);
$this->email->to(ADMIN_EMAIL);
$this->email->from($email, $userName); // if $email = 'myemailid', then its working

$this->email->subject('SenderID Request');
if($path != '')
     $this->email->attach(USER_PROFILE_PATH.$path);
if($this->email->send()){
    $result = $this->User_model->senderIDStatus($senderIDID, 3);
    if($result == 1) {

         $this->session->set_flashdata('Status','success');
         $this->session->set_flashdata('Message','SenderID submitted for approval, we will notify you soon');            
    }
    else {
       $this->session->set_flashdata('Status','failure');
       $this->session->set_flashdata('Message', 'An error occured, please try again');            
    }  
}
else {
    print_r($this->email->print_debugger());
}

我可以发送电子邮件,如果 $ this-&gt; email-&gt; from() myemailid ,这是在电子邮件库中设置的。如果我尝试从其他电子邮件ID发送电子邮件,则会显示错误信息 The following SMTP error was encountered: 553 5.7.1 : Sender address rejected: not owned by user myemailid

1 个答案:

答案 0 :(得分:0)

邮件服务器拒绝您的电子邮件,因为您尝试使用与您登录的用户名不同的用户名进行发送,例如:您已将“发件人:”设为no-reply@mydomain.com,这显然与myemailid

不同