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: "info@mysite.org" 
X-Sender: info@mysite.org
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <51a901aa74a21@mysite.org>
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('me@mysite.org', 'Me');
$this->email->to('someone@someone.com'); 

$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 库,那就太好了。

4

1 回答 1

0

我遇到了同样的问题,并且能够通过更改 codeigniter 的 system/libraries 文件夹中的 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
于 2014-01-20T14:50:04.500 回答