phpmailer
How do I prevent mails sent through PHP mail() from going to spam? [duplicate]
You must to add a needle headers: Sample code : $headers = “From: myplace@example.com\r\n”; $headers .= “Reply-To: myplace2@example.com\r\n”; $headers .= “Return-Path: myplace@example.com\r\n”; $headers .= “CC: sombodyelse@example.com\r\n”; $headers .= “BCC: hidden@example.com\r\n”; if ( mail($to,$subject,$message,$headers) ) { echo “The email has been sent!”; } else { echo “The email has failed!”; } ?>
phpmailer – The following SMTP Error: Data not accepted
your server dosen’t allow different sender and username you should config: $mail->From like $mail->Username
PHPMailer generates PHP Warning: stream_socket_enable_crypto(): Peer certificate did not match expected
I had the same problem and I found the answer in the PHPMailer documentation. PHP 5.6 certificate verification failure In a change from earlier versions, PHP 5.6 verifies certificates on SSL connections. If the SSL config of the server you are connecting to is not correct, you will get an error like this: Warning: stream_socket_enable_crypto(): … Read more
PHPMailer: SMTP Error: Could not connect to SMTP host
Since this questions shows up high in google, I’d like to share here my solution for the case where PHP was just upgraded to version 5.6 (which has stricter SSL behavior). The PHPMailer wiki has a section on this: https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting#php-56-certificate-verification-failure The suggested workaround is including the following piece of code: $mail->SMTPOptions = array( ‘ssl’ => … Read more
Error handling with PHPMailer
PHPMailer uses Exceptions. Try to adopt the following code: require_once ‘../class.phpmailer.php’; $mail = new PHPMailer(true); //defaults to using php “mail()”; the true param means it will throw exceptions on errors, which we need to catch try { $mail->AddReplyTo(‘name@yourdomain.com’, ‘First Last’); $mail->AddAddress(‘whoto@otherdomain.com’, ‘John Doe’); $mail->SetFrom(‘name@yourdomain.com’, ‘First Last’); $mail->AddReplyTo(‘name@yourdomain.com’, ‘First Last’); $mail->Subject=”PHPMailer Test Subject via mail(), advanced”; … Read more