所以代码:
$this->load->library('email');
$this->email->from('mysite@mysite.com', 'mysite');
$this->email->to($email);
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();
我无法理解为什么发送电子邮件时没有错误,但是当我查看我的电子邮箱时,没有电子邮件,所以看起来电子邮件没有到达目的地,我使用CodeIgniter,也许我需要添加一些其他设置来解决这个问题?请帮助!!
ps:我也使用了本机mail()函数,无论如何电子邮件都没有来,我在gmail中检查它
Your message has been successfully sent using the following protocol: mail
From: "mysite"
Return-Path:
Reply-To: "mysite@mysite.kg"
X-Sender: mysite@mysite.kg
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <501f4f33580d5@mysite.kg>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
=?utf-8?Q?Email_Test?=
Testing the email class.
有什么不对吗?
答案 0 :(得分:2)
您是在localhost服务器上还是在生产服务器上使用它?如果您使用自己的Apache,PHP和MySQL安装(例如手动安装,WAMP,XAMPP,MAMP等),那么您的本地主机上可能没有安装邮件服务器来发送邮件。
尝试以下方法:
mail('you@youremail.com', 'My Subject', 'Test message...');
如果这不起作用,那么很可能您的服务器上没有安装邮件服务器。
答案 1 :(得分:0)
奇怪!也许你应该在config文件夹中创建一个文件email.php。
在文件
中添加以下代码$config['protocol'] = 'sendmail';
$config['mailtype'] = 'html';
$config['mailpath'] = '/usr/sbin/sendmail';
在您发送电子邮件的控制器中,在设置to和from标头之前添加一行。
$this->load->library('email');
确保加载新设置。