我使用 Xampp,并且想使用 CodeIgniter 发送电子邮件。如果使用 smtp 会出现错误:
Message: fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) Filename: libraries/Email.php
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c4a3a9a5ada884a3a9a5ada8eaa7aba9" rel="noreferrer noopener nofollow">[email protected]</a>',
'smtp_pass' => 'your_password'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b7ced8c2c5f7d2cfd6dac7dbd299d4d8da" rel="noreferrer noopener nofollow">[email protected]</a>', 'Your Name');
$this->email->to('(here I put my mail)@yahoo.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();
echo $this->email->print_debugger();
(line extension=php_openssl.dll is decomented)
使用这些设置:
$this->load->library('email');
$this->email->set_newline("\r\n");
$this->email->from('<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="166f79636456736e777b667a733875797b" rel="noreferrer noopener nofollow">[email protected]</a>', 'Your Name');
$this->email->to('(here I put my mail)@yahoo.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();
echo $this->email->print_debugger();
出现消息:您的消息已使用以下协议(protocol)成功发送:邮件
出自:《你的名字》 返回路径:......
但我没有收到任何邮件。
问题是什么?
最佳答案
- “邮件”协议(protocol)意味着它使用 PHP 的
mail()
简单地提交到服务器的邮件代理的功能。 “成功”仅仅意味着它被接受,但并不表明它是否曾经尝试过交付。邮件代理可能已关闭、配置错误等。您需要检查邮件日志,或者更有可能询问您的托管提供商。 - 如果您实际上使用
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b7d6d9cec3dfded9d0f7d2cfd6dac7dbd299d4d8da" rel="noreferrer noopener nofollow">[email protected]</a>
的“发件人”地址我怀疑这封邮件是否真的能够通过。使用可以接收电子邮件的真实电子邮件地址。 - 检查您的垃圾邮件文件夹。
关于php - "Your message has been successfully sent using the following protocol: mail",但我什么也没得到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15030783/