我刚刚将我的网站从一家托管公司转移到另一家托管公司。但是在此过程中,如果我发送附件,我的电子邮件功能将无效。
这是来自调试器:
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库,那就太棒了。
答案 0 :(得分: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