我应该能够使用CodeIgniter在本地开发PC上发送SMTP电子邮件,而无需在本地开发PC上安装SMTP服务器应用程序?在没有本地安装smtp服务器的情况下发送smtp邮件
例如,以下不起作用。
的application/config/email.php
$config['mailtype'] = 'html';
$config['protocol'] = 'smtp';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = '*********';
控制器代码
$this->load->library('email');
$this->email->from('[email protected]', 'Noel');
$this->email->to('[email protected]');
$this->email->subject('SMTP email Test');
$this->email->message('Testing smtp email in codeigniter.');
$this->email->send();
$data['message'] = "Sorry Unable to send email...";
if($this->email->send()){
$data['message'] = "Mail sent...";
}
$this->load->view('test_view', $data);
下返回
对不起无法发送电子邮件...
并没有到达目标电子邮件地址。
您是否检查过GMail SMTP疑难解答指南? https://support.google.com/mail/answer/78775?hl=zh-CN – gabe3886
@ gabe3886 - 嗨,我注意到该链接是IMAP POP指南。是否在Gmail中启用了POP或IMAP?那么需要使用SMTP发送邮件? – user3442612
另外从问题指南,我能够通过端口465,587,但不是25访问gmail与telnet smtp.gmail.com因为我使用ssl和465,我想这不是问题。 – user3442612