简体   繁体   English

如何解决 codeigniter SMTP TLS 电子邮件连接错误?

[英]How to solve codeigniter SMTP TLS email connection error?

I have smtp mail and i am sending verification mail of account at webproject.我有 smtp 邮件,我正在 webproject 发送帐户验证邮件。 Webprject is developed using codeigniter 3.0. Webprject 是使用 codeigniter 3.0 开发的。

I tested with using gmail, it was working perfectly.我使用 gmail 进行了测试,它运行良好。 Now i have to put smtp mail instead of gmail.现在我必须把 smtp 邮件而不是 gmail。 It does not seem to have successful connection to the smtp account.它似乎没有成功连接到 smtp 帐户。

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'mail.company.com'; //change this
$config['smtp_port'] = '587';
$config['smtp_user'] = 'support@company.com'; //change this
$config['smtp_pass'] = '******'; //change this
$config['smtp_crypto'] = 'tls'; 
$config['mailtype'] = 'html';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$config['newline'] = "\r\n";

Received error like this收到这样的错误

A PHP Error was encountered
Severity: Warning
Message: stream_socket_enable_crypto(): Peer certificate CN=`outlook.com' did not match expected CN=`mail.company.com'
Filename: libraries/Email.php
Line Number: 1978

如果您使用 smtp_crypto = tls,请设置“$config['starttls'] = true”

需要此配置,否则邮件发送失败:

$config['smtp_crypto'] = 'tls'; 

The error you get refer to "mail.company.com", which is a bogus address, I suppose.您收到的错误是指“mail.company.com”,我想这是一个虚假地址。 I think it's the reason why you get this error.我认为这就是您收到此错误的原因。 To use SMTP, you need a real SMTP account, not a bogus one.要使用 SMTP,您需要一个真实的 SMTP 帐户,而不是伪造的帐户。 This is why there is the "change this" comments in your code.这就是为什么您的代码中有“更改此”注释的原因。 You should actually change those lines, and put the real credential.您实际上应该更改这些行,并放置真正的凭据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM