Configure WAMP server to send email

Configuring a working email client from localhost is quite a chore, I have spent hours of frustration attempting it. I’m sure someone more experienced may be able to help, or they may perhaps agree with me. If you just want to test, here is a great tool for testing mail locally, that requires almost no … Read more

Fatal error: Class ‘PHPMailer’ not found

all answers are outdated now. Most current version (as of Feb 2018) does not have autoload anymore, and PHPMailer should be initialized as follows: <?php require(“/home/site/libs/PHPMailer-master/src/PHPMailer.php”); require(“/home/site/libs/PHPMailer-master/src/SMTP.php”); $mail = new PHPMailer\PHPMailer\PHPMailer(); $mail->IsSMTP(); // enable SMTP $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only $mail->SMTPAuth = true; // authentication enabled … 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

PHPMailer – SMTP ERROR: Password command failed when send mail from my server

A bit late, but perhaps someone will find it useful. Links that fix the problem (you must be logged into google account): https://security.google.com/settings/security/activity?hl=en&pli=1 https://www.google.com/settings/u/1/security/lesssecureapps https://accounts.google.com/b/0/DisplayUnlockCaptcha Some explanation of what happens: This problem can be caused by either ‘less secure’ applications trying to use the email account (this is according to google help, not sure how … 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(‘[email protected]’, ‘First Last’); $mail->AddAddress(‘[email protected]’, ‘John Doe’); $mail->SetFrom(‘[email protected]’, ‘First Last’); $mail->AddReplyTo(‘[email protected]’, ‘First Last’); $mail->Subject=”PHPMailer Test Subject via mail(), advanced”; … Read more

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: [email protected]\r\n”; $headers .= “Reply-To: [email protected]\r\n”; $headers .= “Return-Path: [email protected]\r\n”; $headers .= “CC: [email protected]\r\n”; $headers .= “BCC: [email protected]\r\n”; if ( mail($to,$subject,$message,$headers) ) { echo “The email has been sent!”; } else { echo “The email has failed!”; } ?>

Unable to send email using Gmail SMTP server through PHPMailer, getting error: SMTP AUTH is required for message submission on port 587. How to fix?

$mail = new PHPMailer(); // create a new object $mail->IsSMTP(); // enable SMTP $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only $mail->SMTPAuth = true; // authentication enabled $mail->SMTPSecure=”ssl”; // secure transfer enabled REQUIRED for Gmail $mail->Host = “smtp.gmail.com”; $mail->Port = 465; // or 587 $mail->IsHTML(true); $mail->Username = “[email protected]”; $mail->Password … Read more

Getting error while sending email through Gmail SMTP – “Please log in via your web browser and then try again. 534-5.7.14” [closed]

I know this is an older issue, but I recently had the same problem and was having issues resolving it, despite attempting the DisplayUnlockCaptcha fix. This is how I got it alive. Head over to Account Security Settings (https://www.google.com/settings/security/lesssecureapps) and enable “Access for less secure apps”, this allows you to use the google smtp for … Read more