I'm using a system to manage appointments: http://easyappointments.org/ The system runs smoothly but I'm having problems to send mails with this software + phpmailer - that comes integrated in this project.
The problem is: When i simply install it and do all that the software do, it runs smoothly but don't send the email. But no errors generated.
This is the sample and original code:
// :: INSTANTIATE EMAIL OBJECT AND SEND EMAIL
$mail = new PHPMailer();
$mail->From = $company_settings['company_email'];
$mail->FromName = $company_settings['company_name'];
$mail->AddAddress($receiver_address); // "Name" argument crushes the phpmailer class.
$mail->IsHTML(true);
$mail->CharSet = 'UTF-8';
$mail->Subject = $title;
$mail->Body = $email_html;
if (!$mail->Send()) {
throw new Exception('Email could not been sent. Mailer Error (Line '
. __LINE__ . '): ' . $mail->ErrorInfo);
}
return TRUE;
So I tried to edit the notifications.php to match server smtp provided:
// :: INSTANTIATE EMAIL OBJECT AND SEND EMAIL
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Port = 587; //Indica a porta de conexão para a saída de e-mails
$mail->Host = 'smtp.site123.com.br'; //smtp.dominio.com.br
$mail->SMTPAuth = true; //define se haverá ou não autenticação no SMTP
$mail->Username = 'contato@site123.com.br'; //Informe o e-mai o completo
$mail->Password = 'goodpassword'; //Senha da caixa postal
$mail->From = $company_settings['company_email'];
$mail->FromName = $company_settings['company_name'];
$mail->AddAddress($receiver_address); // "Name" argument crushes the phpmailer class.
$mail->IsHTML(true);
$mail->CharSet = 'UTF-8';
$mail->Subject = $title;
$mail->Body = $email_html;
if (!$mail->Send()) {
throw new Exception('Email could not been sent 1. Mailer Error (Line '
. __LINE__ . '): ' . $mail->ErrorInfo);
}
return TRUE;
When I does that, the log of the easy tells me:
ERROR - 2016-11-07 12:32:22 --> Severity: Warning --> stream_socket_enable_crypto(): Peer certificate CN=`*.locaweb.com.br' did not match expected CN=`smtp.site123.com.br' /home/storage/9/7c/40/site123/public_html/site/agenda/application/third_party/phpmailer/phpmailer/class.smtp.php 344
ERROR - 2016-11-07 12:32:22 --> Email could not been sent. Mailer Error (Line 134): SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
ERROR - 2016-11-07 12:32:22 --> #0 /home/storage/9/7c/40/site123/public_html/site/agenda/application/controllers/appointments.php(445): Notifications->send_appointment_details(Array, Array, Array, Array, Array, 'O seu hor&aacut...', 'Obriagado por a...', 'http://site123...', 'felipe@tecnicos...')
#1 [internal function]: Appointments->ajax_register_appointment()
#2 /home/storage/9/7c/40/site123/public_html/site/agenda/system/core/CodeIgniter.php(360): call_user_func_array(Array, Array)
#3 /home/storage/9/7c/40/site123/public_html/site/agenda/index.php(229): require_once('/home/storage/9...')
#4 {main}
Ok! I read and went to https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting to see if something helps. There has a sample of code saying:
The correct fix for this is to replace the invalid, misconfigured or self-signed certificate with a good one. Failing that, you can allow insecure connections via the SMTPOptions property introduced in PHPMailer 5.2.10 (it's possible to do this by subclassing the SMTP class in earlier versions), though this is not recommended:
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
Ok! I do that. And so system error log tells me:
ERROR - 2016-11-07 19:04:41 --> Email could not been sent. Mailer Error (Line 141): SMTP Error: The following recipients failed: felipe@tecnicosvirtuais.com.br: <felipe@tecnicosvirtuais.com.br>: Recipient address rejected: Access Denied
ERROR - 2016-11-07 19:04:41 --> #0 /home/storage/9/7c/40/site123/public_html/site/agenda/application/controllers/appointments.php(445): Notifications->send_appointment_details(Array, Array, Array, Array, Array, 'O seu hor&aacut...', 'Obriagado por a...', 'http://site123...', 'felipe@tecnicos...')
#1 [internal function]: Appointments->ajax_register_appointment()
#2 /home/storage/9/7c/40/site123/public_html/site/agenda/system/core/CodeIgniter.php(360): call_user_func_array(Array, Array)
#3 /home/storage/9/7c/40/site123/public_html/site/agenda/index.php(229): require_once('/home/storage/9...')
#4 {main}
And I'm just like... and now? Googled about 10 hours and trying anything that could be corelated... nothing... tried to change Email class, etc... nothing... in the 3 above cases the system runs ok but do not send mail!