简体   繁体   中英

How to solve codeigniter SMTP TLS email connection error?

I have smtp mail and i am sending verification mail of account at webproject. Webprject is developed using codeigniter 3.0.

I tested with using gmail, it was working perfectly. Now i have to put smtp mail instead of gmail. It does not seem to have successful connection to the smtp account.

$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. I think it's the reason why you get this error. To use SMTP, you need a real SMTP account, not a bogus one. This is why there is the "change this" comments in your code. You should actually change those lines, and put the real credential.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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