1
我在使用配置項發送郵件時遇到問題。我使用「sendmail」協議發送郵件,但它被過濾爲垃圾郵件。我用SMTP協議解決了這個問題,但沒有發送。使用SMTP協議發送郵件CodeIgniter不起作用
我的代碼如下:
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '*******@gmail.com',
'smtp_pass' => '********',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$message = "test mail";
$this->email->set_newline("\r\n");
$this->email->from('[email protected]', 'St. Maries');
$this->email->to("[email protected]");
$this->email->subject('Contact - St. Marians Belguam');
$this->email->message($message);
if($this->email->send())
{
echo "mail sent successfully";
}
else
{
show_error($this->email->print_debugger());
}
當我使用CI 「SMTP」 協議發送電子郵件,我得到以下錯誤:
A PHP Error was encountered
Severity: Warning
Message: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.googlemail.com:465 (Connection timed out)
Filename: libraries/Email.php
Line Number: 1673
和錯誤的其他列表..
我問服務器管理員啓用「openssl」。它已經被照顧並被啓用。
如果你想試試看,請訪問this link並檢查你自己。
嘗試使用sendmail而不是smtp,看看它是如何工作的。 – Brad
是的,我嘗試使用sendmail,但它發送爲「垃圾郵件」。我希望它出現在收件箱中。告訴gmail特定郵件是垃圾郵件的條件是什麼?感謝您回答布拉德。任何其他選項,我可以嘗試..? – siddharth
我不確定sendmail是否適合我,但我正在使用我的網站電子郵件。無論我嘗試過什麼,我都無法忍受工作。我認爲Nettuts在這方面做了一次嘗試。檢查了這http://net.tutsplus.com/articles/news/codeigniter-from-scratch-day-3/我瘦他們使用Gmail – Brad