我只是帮助您使用Codeigniter创建电子邮件发件人。我有这样的代码。 在我的控制器中:
<?php
class Email_Controller extends CI_Controller{
public function __construct(){
parent::__construct();
}
public function index(){
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'xxxxx@gmail.com', // change it to yours
'smtp_pass' => 'xxxxx', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$message = '';
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('xxxxx@gmail.com'); // change it to yours
$this->email->to('xxxxx@gmail.com');// change it to yours
$this->email->subject('Resume from JobsBuddy for your Job posting');
$this->email->message($message);
if($this->email->send()){
echo 'Email sent.';
}
else{
show_error($this->email->print_debugger());
}
$this->load->view("index");
}
}
?>
如何配置电子邮件?
我收到了这个错误
A PHP Error was encountered
Severity: Warning
Message: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()
Filename: libraries/Email.php
Line Number: 1553
An Error Was Encountered
Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.
From:
Return-Path:
Reply-To: "xxxxx@gmail.com"
X-Sender: xxxxx@gmail.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <52805e90ecbed@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
=?utf-8?Q?Resume_from_JobsBuddy_for_your_Job_posting?=
答案 0 :(得分:0)
您需要在运行的服务器上配置smtp, 如果它的wamp,灯或其他什么, 一旦你这样做,php函数电子邮件可能会成功发送电子邮件