2013-06-01 81 views
1

我剛剛將我的網站從一個託管公司移至另一個託管公司。但在這個過程中,如果我使用附件發送,我的電子郵件功能將不起作用。發送附件時電子郵件失敗

這是從調試器:

Unable to send email using PHP mail(). Your server might not be configured to send mail using this method. 
User-Agent: CodeIgniter 
Date: Sat, 1 Jun 2013 03:01:46 +0700 
From: "My name" 
Return-Path: 
Reply-To: "[email protected]" 
X-Sender: [email protected] 
X-Mailer: CodeIgniter 
X-Priority: 3 (Normal) 
Message-ID: <[email protected]> 
Mime-Version: 1.0 
Content-Type: multipart/mixed; boundary="B_ATC_51a901aa74aa0" 


=?iso-8859-1?Q?Email_Test?= 
This is a multi-part message in MIME format. 
Your email application may not support this format. 

--B_ATC_51a901aa74aa0 
Content-Type: multipart/alternative; boundary="B_ALT_51a901aa74a67" 

--B_ALT_51a901aa74a67 
Content-Type: text/plain; charset=iso-8859-1 
Content-Transfer-Encoding: 8bit 

Testing the email class. 


--B_ALT_51a901aa74a67 
Content-Type: text/html; charset=iso-8859-1 
Content-Transfer-Encoding: quoted-printable 

Testing the email class. 

--B_ALT_51a901aa74a67-- 

--B_ATC_51a901aa74aa0 
Content-type: image/png; name="screenshot.png" 
Content-Disposition: attachment; 
Content-Transfer-Encoding: base64 

這是我的代碼

$config['set_newline'] = "\r\n"; 
$config['mailtype'] = 'html'; 
$config['charset'] = 'iso-8859-1'; 
$config['wordwrap'] = TRUE; 

$this->email->initialize($config); 

$this->email->from('[email protected]', 'Me'); 
$this->email->to('[email protected]'); 

$this->email->subject('Email Test'); 
$this->email->message('Testing the email class.'); 
$this->email->attach('screenshot.png'); //I put it on root directory of CI 

$this->email->send(); 
echo $this->email->print_debugger(); 

但是,如果我發送電子郵件使用CI外庫的附件,它的工作。實際上,我現在的解決方案是幫助不使用CI庫發送郵件。但是如果有什麼辦法可以繼續使用CI庫,那將會很棒。

+0

它的工作原理,如果你註釋掉'$這個 - >的電子郵件 - >附加(」 screenshot.png');'?或者換句話說:是真的是導致問題的附件,還是CodeIgniter的電子郵件功能配置? –

+0

邑...如果我不附加任何文件,它將工作 – l1th1um

回答

0

我有同樣的問題,並能夠通過在系統改變email.php文件來解決它/庫笨

var $protocol = "smtp"; // mail/sendmail/smtp 
var $smtp_host = "localhost"; // SMTP Server. 

的文件夾中的問題似乎是在上述第一行中的郵件協議。

您可能還需要在格蘭接下來的兩行添加用戶名和密碼,如果你有這些設置

var $smtp_user = "my_username"; // SMTP Username 
var $smtp_pass = "my_password"; // SMTP Password 
+0

我也面臨一些問題,但我使用sendmail和它的罰款 $ config ['protocol'] ='sendmail'; – FormaL

+0

嘗試從sendmail將其更改爲smtp。看看是否能解決你的問題 – Sahil