2
我試圖用笨發送SMTP電子郵件,但即時響應收到錯誤......遇到 「以下SMTP錯誤:0 無法使用PHP SMTP發送電子郵件。您的服務器可能不被配置爲使用這個方法來發送郵件。「SMTP郵件錯誤:服務器可能不被配置爲發送郵件
User-Agent: CodeIgniter
Date: Tue, 13 Dec 2016 07:06:56 +0000
From: "Blabla" <xxxxxxxxxxxxxx>
Return-Path: <xxxxxxxxxxxxxxxxxxx>
To: xxxxxxxxxxxx
Reply-To: "Explendid Videos" <xxxxxxxxxxxxxxxxxx>
Subject: =?utf-8?Q?=54=68=69=73=20=69=73=20=61=6E=20=65=6D=61=69=6C=20=74=65=73=74?=
X-Sender: [email protected]
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <[email protected]>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_584f9e1023f99"
This is a multi-part message in MIME format.
Your email application may not support this format.
--B_ALT_584f9e1023f99
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
It is working. Great!
--B_ALT_584f9e1023f99
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
It is working. Great!
--B_ALT_584f9e1023f99--
代碼是
$ci = get_instance();
$ci->load->library('email');
$config = array();
$config['protocol'] = "smtp";
$config['smtp_host'] = "xxxxx";
$config['smtp_port'] = 25;
$config['smtp_user'] = "xxxxx";
$config['smtp_pass'] = "xxxxx";
$config['charset'] = "utf-8";
$config['mailtype'] = "html";
$config['newline'] = "\r\n";
$ci->email->initialize($config);
$ci->email->from('xxxxx', 'Blabla');
$list = array('xxxxx');
$ci->email->to($list);
$this->email->reply_to('xxxxx', 'Explendid Videos');
$ci->email->subject('This is an email test');
$ci->email->message('It is working. Great!');
if($ci->email->send()){echo "send";}else{echo "error ";print_r($ci->email->print_debugger());}
使用'$ this-> ci'而不是'$ ci'。 –
我會把這個$ this-> ci = get_instance();在庫的__construct()區域中 – user4419336
您需要向服務提供商諮詢您的smtp服務器詳細信息。另外,如果您使用gmail從您的應用程序發送電子郵件,則需要從gmail-settings激活smtp電子郵件。再一次,如果你將你的應用程序上傳到你的服務器上,那麼不需要使用'''smtp'''協議,而是使用''sendmail'''來代替。 – kishor10d