Reputation: 153
i have config for smtp mailer in codeigniter like this,
$config['useragent'] = 'PHPMailer'; // Mail engine switcher: 'CodeIgniter' or 'PHPMailer'
$config['protocol'] = 'smtp'; // 'mail', 'sendmail', or 'smtp'
$config['mailpath'] = '/usr/sbin/sendmail';
$config['smtp_host'] = 'tls://smtp.gmail.com:587';
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = 'xxxxxxxx';
$config['smtp_port'] = 587;
$config['smtp_timeout'] = 30; // (in seconds)
$config['smtp_crypto'] = 'tls'; // '' or 'tls' or 'ssl'
$config['smtp_debug'] = 0; // PHPMailer's SMTP debug info level: 0 = off, 1 = commands, 2 = commands and data, 3 = as 2 plus connection status, 4 = low level data output.
$config['smtp_auto_tls'] = true; // Whether to enable TLS encryption automatically if a server supports it, even if `smtp_crypto` is not set to 'tls'.
$config['smtp_conn_options'] = array(); // SMTP connection options, an array passed to the function stream_context_create() when connecting via SMTP.
$config['wordwrap'] = true;
$config['wrapchars'] = 76;
$config['mailtype'] = 'html'; // 'text' or 'html'
$config['charset'] = 'utf-8'; // 'UTF-8', 'ISO
I use the phpmailer library to send this email and I have activated less secure apps on my gmail account, what problems have occurred? because on localhost everything works fine
this is the error,
ERROR - 2019-07-17 12:49:32 --> Severity: Warning --> stream_socket_enable_crypto(): Peer certificate CN=`bigcarica.harapmaklum.com' did not match expected CN=`smtp.gmail.com' /home/matoaind/public_html/application/third_party/phpmailer/class.smtp.php 368
Upvotes: 0
Views: 222
Reputation: 37700
You are asking it to connect to smtp.gmail.com
on port 587, but your error message shows that it’s connecting to a different server. This will be because your hosting provider is redirecting SMTP traffic to their own server. The script is detecting this, and rejecting the mismatched name. This is one of the main reasons to use TLS - it allows you to detect man-in-the-middle attacks (which effectively what this is).
Refer to your provider’s documentation for how they want you to send email, or ask them to remove this redirection.
This exact problem is covered in the troubleshooting guide the error message links to.
Upvotes: 2