我正在尝试使用codeigniter发送电子邮件, 这是我正在使用的代码,
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://sub5.mail.xxxxxxxx.com',
'smtp_port' => 465,
'smtp_user' => 'account@xxxxxxxxxxxx.com',
'smtp_pass' => 'xxxxxxxx',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => FALSE
);
$this->load->library('email');
$this->email->initialize($config);
$this->email->set_newline("\r\n");
$this->email->clear(TRUE);
$this->email->from($datadatay['hcusemail'], 'FMF Refund Form Data');
$this->email->to("eranga.p@xxxxx.lk");
$this->email->cc("eranga.xxxx@gmail.com");
$this->email->subject("Refund Form");
$this->email->message("The form is attached hereby");
$this->email->set_mailtype("html");
$this->email->attach($_SERVER['DOCUMENT_ROOT']. '/dist/pdf/' . $filename);
$this->email->send();
此代码在localhost中运行得非常好。但是当它在服务器上发布时,我会得到以下错误,
220 homiemail-a119.g.dreamhost.com ESMTP
<br /><pre>hello: 250-homiemail-a119.g.dreamhost.com
250-PIPELINING
250-SIZE 40960000
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250 8BITMIME
</pre><pre>from: 250 2.1.0 Ok
</pre><pre>to: 250 2.1.5 Ok
</pre><pre>to: 250 2.1.5 Ok
</pre><pre>data: 354 End data with <CR><LF>.<CR><LF>
</pre>550 5.7.1 Sender domain not allowed. Please read: http://dhurl.org/20b D157
<br />The following SMTP error was encountered: 550 5.7.1 Sender domain not allowed. Please read: http://dhurl.org/20b D157
<br />Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.<br /><pre>User-Agent: CodeIgniter
Date: Wed, 18 Jan 2017 16:50:59 +0530
From: "FMF Refund Form Data" <erangainfo@gmail.com>
Return-Path: <erangainfo@gmail.com>
To: eranga.p@findmyfare.lk
Cc: eranga.findmyfare@gmail.com
Subject: =?iso-8859-1?Q?Refund_Form?=
Reply-To: "erangainfo@gmail.com" <erangainfo@gmail.com>
X-Sender: erangainfo@gmail.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <587f4f9b1ea8f@gmail.com>
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="B_ATC_587f4f9b1eb0f"
This is a multi-part message in MIME format.
Your email application may not support this format.
--B_ATC_587f4f9b1eb0f
Content-Type: multipart/alternative; boundary="B_ALT_587f4f9b1ead4"
--B_ALT_587f4f9b1ead4
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
The form is attached hereby
--B_ALT_587f4f9b1ead4
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
The form is attached hereby
--B_ALT_587f4f9b1ead4--
--B_ATC_587f4f9b1eb0f
Content-type: application/x-unknown-content-type; name="eranga.docx"
Content-Disposition: attachment;
Content-Transfer-Encoding: base64
--B_ATC_587f4f9b1eb0f--</pre>
尝试了很多东西,但没有任何作用。请帮忙。
答案 0 :(得分:1)
此错误表示您尝试从不属于您的域发送信件。
从日志中可以看出,您从erangainfo@gmail.com
发送电子邮件。
但是你通过显然不是ssl://sub5.mail.xxxxxxxx.com
的{{1}}服务器发送它。你欺骗发件人的地址。 Dreamhost阻止它,因此错误。