Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29758

CodeIgniter, PHPMailer & SendGrid Not Working on a cPanel-Based Host

$
0
0

I have CodeIgniter project running on a cPanel/centOS based host. The CodeIgniter email class (running off of phpMailer v 6.1.4) is not working on this host, but is working locally and in other environments.

  • When we run the code below on our cPanel-based host, we get an uninterpretable error from the PHPMailer debugging function:

    The following SMTP error was encountered: +�W��TV���:����;�D���q�� Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

  • The weird thing is that everything was working until two days ago, and nothing was changed (to my knowledge) on the code-level.

  • When we check error logs we see the following:

Severity: Warning --> stream_socket_enable_crypto(): Peer certificate CN=*.mywebhost.com' did not match expected CN=smtp.sendgrid.net' /home/irissb2007/public_html/system/libraries/Email.php

The above leads me to believe that:

  • The host is utilizing some kind of configuration (such as "FKA SMTP Tweak") preventing us from connecting to SendGrid. (I toggled this on/off, but it didnt' seem to to anything).
  • There's some kind of SSL issue

I've been trying to diagnose with our host, but they have been rather unhelpful until now, so any insights would be most welcome and thanks in advance!

Please let us know if we can provide any more information and thank you in advance for your cooperation.

$config                     = array();
$config['useragent']        = 'PHPMailer';
$config['protocol']         = 'smtp';
$config['mailpath']         = '/usr/sbin/sendmail';
$config['smtp_host']        = 'smtp.sendgrid.net';
$config['smtp_user']        = 'USER';
$config['smtp_pass']        = 'PASSWORD';
$config['smtp_port']        = 587;
$config['smtp_timeout']     = 5;
$config['smtp_crypto']      = 'tls';
$config['wordwrap']         = true;
$config['wrapchars']        = 76;
$config['mailtype']         = 'html';
$config['charset']          = 'iso-8859-1';
$config['validate']         = true;
$config['priority']         = 3;
$config['crlf']             = "\n";
$config['newline']          = "\n";
$config['bcc_batch_mode']   = false;
$config['bcc_batch_size']   = 200;

$this->load->library('email');
$this->email->initialize($config);
$this->email->from('my@email.com', 'Your Name');
$this->email->to('my@email.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();
show_error($this->email->print_debugger());

Viewing all articles
Browse latest Browse all 29758

Trending Articles