我正在尝试发送电子邮件。这是我写的代码。
config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = '465';
$config['smtp_user'] = 'mymail@gmail.com';
$config['smtp_pass'] = '123';
$config['mailtype'] = 'html';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$config['newline'] = "\r\n";
这是我得到的错误:
遇到以下SMTP错误:110连接超时无法使用PHP SMTP发送电子邮件。您的服务器可能不是 配置为使用此方法发送邮件。
User-Agent: CodeIgniterDate: Wed, 24 May 2017 14:39:24 +0530 From: "SMEC" <contact@labs.info> Return-Path: <contact@labs.info> Reply-To: <training@labs.org> To: test00@gmail.com Subject: =?ISO-8859-1?Q?=53=4D=45=43=4C=61=62=73=20=2D=20=43=41=52=45=45=52=20=49?= =?ISO-8859-1?Q?=4E=20=43=4F=52=45=20=49=4E=44=55=53=54=52=49=45=53=21=21?= X-Sender: contact@labs.info X-Mailer: CodeIgniter X-Priority: 3 (Normal) Message-ID: <gt; Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="B_ALT_59254dc4bc79e" This is a multi-part message in MIME format. Your email application may not support this format.
答案 0 :(得分:0)
即使使用Gmail,以下配置也非常适合我。
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = 'example@gmail.com';
$config['smtp_pass'] ='yourmailpassword';
$config['mailtype'] = 'html';
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('from@gmail.com', 'TEST MAIL');
$this->email->to($to);
$this->email->subject($subject);
$this->email->message($message);
$this->email->send();
不要忘记在Gmail帐户中启用不太受信任的应用访问权限。我能够发送简单的文本电子邮件和电子邮件与HTML模板和具有上述配置的图像没有任何问题。