这是我的代码:
$this->email->from('your@example.com', 'Your Name');
$this->email->to('myemail@gmail.com');
$this->email->cc('myemail2@gmail.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();
echo $this->email->print_debugger();
这是echo的结果:
Your message has been successfully sent using the following protocol: mail
From: "Your Name" <your@example.com>
Return-Path: <your@example.com>
Cc: myemail2@gmail.com
Reply-To: "your@example.com" <your@example.com>
X-Sender: your@example.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <55058c9e98942@example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
=?utf-8?Q?Email_Test?=
Testing the email class.
我正在测试联系表单。首先尝试收到邮件,即使我在gmail帐户"This message may not have been sent by: myemail@gmail.com"
我尝试使用php的邮件功能:
$to = "myemail@gmail.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: webmaster@example.com" . "\r\n" .
"CC: myemail2@gmail.com";
但我没有收到任何电子邮件。我该怎么办 ?我做错了什么?
更新:
$config['protocol'] = 'sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$config['priority'] = 1;
$this->email->initialize($config);
$this->email->from('your@example.com', 'Your Name');
$this->email->to('cazare.carei.strand@gmail.com');
$this->email->cc('naghi.attila@gmail.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();
echo $this->email->print_debugger(); exit();
答案 0 :(得分:0)
如果您的端口25已打开,则该电子邮件应该是可发送的。某些电子邮件提供商要求在发件人的电子邮件域的DNS记录中设置有效的mx record,以便发送未经授权的发件人的虚假电子邮件。
我不确定gmail是否有此要求。
如果您想捕获该问题,请重新配置example.com的DNS条目以包含服务器的IP地址。另一种可能性是使用forign smtp服务器而不是服务器的内部sendmail发送电子邮件。我的经验表明这可能很慢(在一个大的webabbplication上)。
作为found on google,您可以将
修改强>
“此消息可能尚未通过发送:myemail@gmail.com”
这可能表示Google不信任发送服务器。