PHP mailer multiple address [duplicate]

You need to call the AddAddress method once for every recipient. Like so: $mail->AddAddress(‘person1@domain.example’, ‘Person One’); $mail->AddAddress(‘person2@domain.example’, ‘Person Two’); // .. Better yet, add them as Carbon Copy recipients. $mail->AddCC(‘person1@domain.example’, ‘Person One’); $mail->AddCC(‘person2@domain.example’, ‘Person Two’); // .. To make things easy, you should loop through an array to do this. $recipients = array( ‘person1@domain.example’ => … Read more

File attachment with PHPMailer

When you call move_uploaded_file($file_tmp,”uploads/”.$file_name); This creates a file in the uploads/ directory with the name of the file as it was named on the uploader’s computer. Then you used sample code to add the attachment to phpMailer so you’re basically attempting to attach non-existent files. These two lines: $mail->addAttachment(‘uploads/file.tar.gz’); // I took this from the … Read more

“Password not accepted from server: 535 Incorrect authentication data” when sending with GMail and phpMailer

The solution was to enable outgoing SMTP from the server settings. On servers running cPanel’s WHM, this is located under WHM’s “Tweak Settings” section. The option is to enable/disable – choose disable. Caveat: Making this change will redirect outgoing SMTP connections allow accounts to make direct connections which may increase your odds of getting your … Read more

PHPMailer character encoding issues

If you are 100% sure $message contain ISO-8859-1 you can use utf8_encode as David says. Otherwise use mb_detect_encoding and mb_convert_encoding on $message. Also take note that $mail -> charSet = “UTF-8”; Should be replaced by: $mail->CharSet = “UTF-8”; And placed after the instantiation of the class (after the new). The properties are case sensitive! See … Read more

require(vendor/autoload.php): failed to open stream

What you’re missing is running composer install, which will import your packages and create the vendor folder, along with the autoload script. Make sure your relative path is correct. For example the example scripts in PHPMailer are in examples/, below the project root, so the correct relative path to load the composer autoloader from there … Read more

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 – SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

PHP 5.6 introduces SSL certificate verification, so if your config is broken, it will fail with this error. You should fix your SSL, but you can revert to the old behaviour by setting the SMTPOptions property to not verify certificates: $mail->SMTPOptions = array( ‘ssl’ => array( ‘verify_peer’ => false, ‘verify_peer_name’ => false, ‘allow_self_signed’ => true … Read more

tech