How to send mail via PHP mail() and avoid spam filters

For about the past 12 years, I’ve been using PHP to send personalized Holiday Greetings to about 200 recipients, using the PHP mail() command. I am using gmail SMTP. Something must have changed in the past year, because MANY of the recipients did not get their Greeting this year, even though my program finished without any obvious errors, and reported that each batch was sent (I send only about 20 Greetings in each batch).

I would appreciate some example code that shows the best way to do a batch send and avoid spam filters.

My thanks in advance!

Stop spamming them and just send the emails out. That is never a problem.
What I am saying is making a PHP mail() function with 200 items in the TO: field or CC: or BC: fields is a SPAM.
Just loop thru your list of 200 email addresses and sent each one at a time with just one email in the TO: field and nothing in the CC/BC fields. Also, the FROM: field MUST contain your true server’s SMTP email account. Not one you make up.

Hope that helps!

I AM looping through the list, and each eMail has just ONE address; it is in the TO: field, and nothing is in the CC or BCC fields.
Still, Google recently added something that detects if the message is not coming from a gmail server – that is what I need help with.

Okay, now that I understand that you are using Gmail’s account to send out, there is a solution that is supposed to work to fix this. You need to enable 2 factor authentication in your Gmail settings. You need to do it in this manner. Google has stopped allowing direct email without the correct authorization. Here is what was said on StackOverflow that should fix it. Try it and let us know.



Yes, It's not working after removing the option by google.
 But nothing to worry! It's still very simple to send email. 
To send email again you need to do this as bellow:

    Login to your gmail
    Go to Security setting and Enable 2 factor authentication
    After enabling this you can see app passwords option. Click here!
    And then, from Your app passwords tab select Other option 
       and put your app name and click GENERATE button to get new app password.
    Finally copy the 16 digit of password and click done. 
    Now use this password instead of email password to send mail via your app.

Now you can use just email and this generated pass to send email.

Another possible solution would be to use a formal library such as “PHPmailer”. A free mailing library. To use that, you would loosely use this type of code…

$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 = "password";
$mail->SetFrom("[email protected]");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("[email protected]");

 if(!$mail->Send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
 } else {
    echo "Message has been sent";
 }

Let us know how it works out. Hope something in here helps…

Thank you for sending this… FYI, my App worked OK from December 2009 - Dec 2021, and only had the issues in Dec 2022…
Here is what the code does now (excerpted from a larger PHP batch file):

=================================================

$AT = “@”;
$DOT = “.”;

//This is in a loop that selects just ONE Recipent…

  $recipientAddress = $row['EmailAddress'];

  $email6 = 'Todd.Greeno' . $__AT__ . 'gMail' . $__DOT__ . 'com';

  $headers = 'From: Todd Greeno <' . $email6 . '>' . $eol;
  $headers .= 'Reply-to: Todd Greeno <' . $email6 . '>' . $eol;
  $headers .= 'Return-Path: Todd Greeno <' . $email6 . '>' . $eol;    // these two to set reply address 
  $headers .= 'Message-ID: ' . sprintf("<%s.%s@%s>",
                                  base_convert(microtime(), 10, 36),
                                  base_convert(bin2hex(openssl_random_pseudo_bytes(8)), 16, 36),
                                  'hdlenhancement.com') . $eol; 

  $headers .= 'X-Mailer: PHP v' . phpversion() . $eol;          // This & thye next line are supposed to help avoid spam-filters 

  $headers .= 'Content-type: text/html; charset=us-ascii' . $eol;

  $additional = "[email protected]";


  //Send message to current recipient

  mail($recipientAddress,$Subject,$msg,$headers,$additional)

//Loop gets next recipient and starts over

===============================================

Using the above code, and batches of just 10 to 20 addresses in the loop, about half of the messages didn’t get sent, not did I get any indication of error(s).

I would appreciate any suggestions for this code.

Sorry, I was out of the state on an ice fishing derby trip. Just got back.
Your code is just the PHP standard mail() function and will NOT send out SMTP messages.
Gmail dropped their simple email service and only allows secured SMTP with two-layer security!

The SMTP info can be put into the mail() function, but, nobody has ever got it to work very well.
The easy fix is just to use a simple email library. Like PHPmailer or Swiftmail. Either work great!
They both have tons of ways to secure emails thru Gmail’s server. You will have to set up the two-layer security on your Gmail account first. It is just a few clicks and easy to do.

I gave you commands to set up the Gmail’s two-layer security and I also gave you a sample code for PHPMailer library. Did you set up your extra security? Did you download and try PHPMailer? You should look at PHPMailer’s site, it is a free library and they give examples if you don’t just want to use the one I already gave you. Here is their site, let us know how it works for you… PHPMailer

Thank you for sending this…
I haven’t done any major coding (except for patches) since 2010, and the PHPMailer code confuses me. (I.e.: I am not at all familiar with the “- >” operator)… Any chance you know someone who could help me with the code, or just do it for me for a reasonable price? (I am 72 years old and on a fixed income)…

My thanks in advance…

Sure, no charge, this site is about helping people. We do have a section where you can hire a coder, but, we can do it here for free… Here is what you need to do.

First, you need to install a copy of PHPmailer. You can use COMPOSER if you have it installed.
If you use composer, you can use this command… composer require phpmailer/phpmailer
And, it will install the library for you. If you do not use composer, you can just install a copy. I can send you one. It would just be a folder of the library commands. So, let us know if you have composer.

Next, you would need to log into the Gmail account online and enable the 2-factor authentication.
I mentioned that above…

To test an email message, use the code that I gave you for the PHPmailer system. The best way is to create a page by itself and call it something like email_test.php. Then, in that page past the PHPmailer code above that I gave you. Change the email address of your Gmail account and password. Loosely something like this should work for testing… ( not tested, just a slight rewrite of the code above )

<?PHP
//  Set up mailing defaults ( Your code already does this... )
$subject = "A test Message!";
$message = "A test message from the new PHPmailer routines...  Did you get it?";
$email_address = " ONE EMAIL TO SEND TO FOR testing, probably yours";

//  PHP-Mailer code to send an email ( Could be put into a function if needed or just replace the old code! )
$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 = "YOUR EMAIL ADDRES GOES [email protected]";
$mail->Password = "YOUR PASSWORD";
$mail->SetFrom("[email protected]");
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AddAddress($email_address);

 if(!$mail->Send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
 } else {
    echo "Message has been sent";
 }
?>

The FROM section is usually the address you want the user to reply to, but, sometimes you need to use your email account’s address here. So, this is really all you need to test it. Once you set up this test page and have the PHPmailer installed, you just open that page from your server and see if the mail goes out and if you get the email in your inbox. Should work, but, I have had some troubles on some servers.

Try to get this far and if it fails post your page here, just do NOT post your real email or password here. Mark them out with *******'s. That way nobody will spam you. Ha! Well, let us know how it goes! If you can get this test page to work, then we can alter your code above to work with the PHPmailer. In your code there are “headers” and they are basically the same things that PHPmailer use, just formated differently. Each header is separated into the → object names. Easy to fix once you get PHPmailer working. Good luck!

THANK YOU!..

I’m still confused by the code you referenced. My website is hosted by BlueHost, and I rely on their PHP processes. I have a database of Names, eMail Addresses, graphics, and personal messages for each recipient. My front-end enables me to select a subset of the records to keep the batches small, and the mail() command is in a loop that selects just one recipient at a time… That code is less than 400 lines, including comments and blank lines for easy reading; I wanted to post a copy here, but I don’t see a link for that… I tried pasting it below, but it did not render properly in the preview.

The mail() command I am using is:

mail($recipientAddress,$Subject,$msg,$headers,$additional)

The $headers is:

$headers2 = ‘From: Todd Greeno <’ . $email6 . ‘>’ . $eol;
$headers2 .= ‘Reply-to: Todd Greeno <’ . $email6 . ‘>’ . $eol;
$headers2 .= ‘Return-Path: Todd Greeno <’ . $email6 . ‘>’ . $eol; // these two to set reply address

$headers2 .= 'Message-ID: ’ . sprintf("<%s.%s@%s>",
base_convert(microtime(), 10, 36),
base_convert(bin2hex(openssl_random_pseudo_bytes(8)), 16, 36),
hdlenhancement.com’) . $eol;

$headers2 .= ‘X-Mailer: PHP v’ . phpversion() . $eol; // These two to help avoid spam-filters
$headers2 .= ‘Content-type: text/html; charset=us-ascii’ . $eol;

$headers = $headers2;

$additional is:

$additional = “-r” . $email6 ;

This is what you posted…

$**AT** = “@”;
$**DOT** = “.”;

//This is in a loop that selects just ONE Recipent…

$recipientAddress = $row[‘EmailAddress’];

$email6 = ‘Todd.Greeno’ . $AT . ‘gMail’ . $DOT . ‘com’;

$headers = ‘From: Todd Greeno <’ . $email6 . ‘>’ . $eol;
$headers .= ‘Reply-to: Todd Greeno <’ . $email6 . ‘>’ . $eol;
$headers .= ‘Return-Path: Todd Greeno <’ . $email6 . ‘>’ . $eol; // these two to set reply address
$headers .= 'Message-ID: ’ . sprintf("<%s.%s@%s>",
base_convert(microtime(), 10, 36),
base_convert(bin2hex(openssl_random_pseudo_bytes(8)), 16, 36),
hdlenhancement.com’) . $eol;

$headers .= ‘X-Mailer: PHP v’ . phpversion() . $eol; // This & thye next line are supposed to help avoid spam-filters

$headers .= ‘Content-type: text/html; charset=us-ascii’ . $eol;

$additional = “[email protected]”;

//Send message to current recipient
mail($recipientAddress,$Subject,$msg,$headers,$additional)

//Loop gets next recipient and starts over

Therefore, first, you need to copy the PHPmailer library to your server.  It is a folder named usually, PHPmailer.  This folder can be placed on your server in the area where you mailing code is.  Then, in your code you would replace the above code with something like this:   ( For testing, in a separate test page as I mentioned about above! ! ! )

// Set up new PHPmailer connection and set to SMTP version
$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);

//This is in a loop that selects just ONE Recipent… ( Set up recipient info which is just an email address )
$mail->AddAddress( $row[‘EmailAddress’] );

// Set up user information and server information
$mail->Username = “[email protected]”;
$mail->Password = “PASSWORD OF THE GMAIL ACCOUNT… password”;
$mail->SetFrom(" 'From: Todd Greeno [email protected]";
$mail->Subject = “YOU DIDN’T HAVE A SUBJECT, SO ADDED THIS ONE…Test”;
$mail->Body = “THIS IS THE $msg BUT YOU DID NOT INCLUDE THAT IN YOUR POST…”;

//Send message to current recipient
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo “Message has been sent”;
}

//Loop gets next recipient and starts over

You did not post your SUBJECT or MESSAGE, not a problem.  But, in this sample code, I stuck something in where they go.  You probably would want it like this for these two lines:
$mail->Subject = $subject;
$mail->Body = $msg;
Or, if they are always the same subject and message, just hard code it there.  Also, to make this work, you MUST make sure that your Gmail account has the 2-factor security set up on it.  That is step number one!  And, as I mentioned before, you should just make a small test page, a simple email_test.php page with this code in it so that you test it before making changes to the live site.  You should never test on your live pages.  
Well, hope this helps move you further along...

OK… I trimmed the code in my previous reply so it would be easier to read. Here’s the code where I define $recipientAddress, $Subject, $msg, $headers and $additional:

/*** Build message as combo of hardcoded and variable parts; can also intercept some fields from input screen ***/

$AT = ‘@’;
$DOT = ‘.’;
$eol = ‘\r\n’;
$email5 = ‘Todd.Greeno’ . $AT . ‘gMail’ . $DOT . ‘com’;
$email6 = ‘Todd.Greeno’ . $AT . ‘gMail’ . $DOT . ‘com’;

$style0 = ‘BODY {font-family: Verdana; font-size: 10px; color: Navy; }’ . $eol;
$style1 = ‘TD { white-space: normal; font-size: 12px;}’ . $eol;
$style2 = “TD.data {background-color: ‘#EFE2DC’; font-family: ‘Comic Sans MS’; font-size: 13px; color: Navy; }” . $eol;
$style3 = “TD.title, th {font-family: ‘Times New Roman’; font-style: ‘italic’; font-size: 16px; color : red; font-weight: bold; background-color: ‘#EFE2DC’; }” . $eol;
$style4 = “.emph {font-family: ‘Times New Roman’; font-style: ‘italic’; font-size: 16px; color : red; font-weight: bold; }” . $eol;
$style5 = “.emph3 {font-family: ‘Comic Sans MS’; font-style: ‘italic’; font-size: 22px; color: ‘#C00000’; font-weight: normal; }” . $eol;

$style = '<style>' . $eol . $style0 . $style1 . $style2 . $style3 . $style4 . $style5 . '</style>' . $eol;

$BodyTag = "<body bgcolor=#ffffff text=navy leftmargin='0' topmargin='0'

marginwidth=‘0’ marginheight=‘0’>" . $eol;
$eoBody = “” . $eol . “” . $eol;

// -----------[ SUBJECT
$Subject = ‘A Special Holiday Greeting For You’;
$WineGlass = “<img alt=“It’s about WINE!” width=82 height=132 src=”…Images/aWineGlass2.gif">";

$result = mysqli_query($link, $newQuery) or die(mysqli_error($link));
$num = 0;
while($row = mysqli_fetch_array($result)){
$num = 1 + $num;
$recipientAddress = $email4;
$recipAddr = $row[‘EmailAddress’];
if($ProductionChecked == ‘1’) {$recipientAddress = $recipAddr;}
$RecipientName = $row[‘LastName’] . ", " . $row[‘FirstName’];
$GreetingName = $row[‘GreetingName’];
$PersMsg = $row[‘PersMsg’];
$CurrPriority = $row[‘Priority’];
$SentPriority = $CurrPriority + (10 * $CurrPriority);

$Cover1 = "<img src=../Images/CoverNYC-atNight4XmasEdit.jpg width=762 height=507>";


$InsideImage1 = "background=../Images/PortLayer.jpg";

$Signature = "<tr><td><center><img width=331 height=49 src=../Images/ProducedByGreenoCom2.gif></center></td></tr>";

$Table1 = "<table border=0 cellspacing=8 cellpadding=0><tr><td width=100 valign=top>";
$Table2 = "</td><td width=* valign=top>";
$Table3 = "</td></tr></table>";


$msgHdr = "<HTML>" . $eol . "<HEAD>" . $eol . $style . $eol . "</HEAD>" . $eol . $BodyTag . $eol;

$xmasmsg = "

<span style="font-family: ‘Comic Sans MS’; font-style: ‘italic’; font-size: 22px; color: ‘#C00000’; font-weight: normal; ">My warmest wishes this winter season for a happy and memorable and SAFE Holiday celebration that brings you close to friends, family and loved-ones.

All the best for a wonderful and SAFE New Year!

Cheers!
Todd
.   " . $eol;

$msg = "";
$msg .= $msgHdr;
$msg .= "<span style=\"font-family: 'Verdana'; font-size: '12px';\">" . $eol;
$msg .= "<br /><br /><b>If you are unable to see the images below, <a target=_blank href=https://www.greeno.com/Main/MyCard.php?ADDR=" . $recipAddr . "&S=" . $iStamp . "&CVR=" . $CoverImg . "&INS=" . $InsideImg . "&SEQ=" . $CurrPriority . ">you can view your card here</a>.</b><br /><br />" . $eol;

$msg .= "<table width=762 border=1 cellspacing=0 cellpadding=0>" . $eol;
$msg .= "<tr><td class=title valign=top>" . $eol;
$msg .= "<table width=* border=0><tr><td width=20> &nbsp; </td><td width=* valign=top>" . $eol;
$msg .= "<table align=right border=0 width=200><tr><td valign=top>" . $Stamp . "</td></tr></table><br><span style=\"font-family: 'Times New Roman'; font-style: 'italic'; font-size: 16px; color : red; font-weight: bold; \"><i>" . $eol;
$msg .= "In previous years, I designed Holiday cards that were printed on recycled paper, but sending them still expended a lot of resources in printing and in using the US Postal service to make the door-to-door deliveries...  This year, I am continuing the \"greener\" approach I started over a decade ago with this electronic version that still has my unique custom design and my personal message to you." . $eol;
$msg .= "</i></span><br>" . $eol;
$msg .= "</td></tr></table>" . $eol;
$msg .= "</td></tr>" . $eol;
$msg .= "<tr><td>" . $Cover . "</td></tr>" . $eol;
$msg .= "<tr><td class=data " . $InsideImage . " height=490 valign=top>" . $eol;
$msg .= "<table width=* border=0 align=top><tr><td width=20> &nbsp; </td><td width=* valign=top>" . $eol;
$msg .= "<span style=\"font-family: 'Comic Sans MS'; font-style: 'italic'; font-size: 22px; color: '#C00000'; font-weight: normal; \"><i><br>" . $eol;
$msg .= $PersMsg . $eol;

/-----------------[CHRISTMAS CONTENT --------------/
$msg .= $xmasmsg ;
/---------------------------------------------------/

$msg .= $Signature . $eol;

$msg .= "</td></tr></table>" . $eol;
$msg .= "<br><br>" . $eol;
$msg .= "</span>" . $eol;

$msg .= $eoBody;

$headers2 = ‘From: Todd Greeno <’ . $email6 . ‘>’ . $eol;
$headers2 .= ‘Reply-to: Todd Greeno <’ . $email6 . ‘>’ . $eol;
$headers2 .= ‘Return-Path: Todd Greeno <’ . $email6 . ‘>’ . $eol; // these two to set reply address

$headers2 .= 'Message-ID: ’ . sprintf("<%s.%s@%s>",
base_convert(microtime(), 10, 36),
base_convert(bin2hex(openssl_random_pseudo_bytes(8)), 16, 36),
‘myURL’) . $eol;

$headers2 .= ‘X-Mailer: PHP v’ . phpversion() . $eol; // These two to help avoid spam-filters
$headers2 .= ‘Content-type: text/html; charset=us-ascii’ . $eol;
$headers = $headers2;

$additional = ‘-r’ . $email6 ;

if (mail($recipientAddress,$Subject,$msg,$headers,$additional)) {
$ResultMsg .= “” . $CurrPriority . "Sent to: " . $RecipientName . “” . $recipientAddress . “” . $eol;
$Counter = $Counter + 1;
$uQuery=“UPDATE Recipients SET DateSent=CURDATE(), Priority=$SentPriority WHERE EmailAddress=’$recipientAddress’”;
mysqli_query($link, $uQuery);
sleep(8);
} else {
$ErrorTrap .= "NOT Sent: " . $RecipientName . “” . $recipientAddress . “” . $eol;
$Failed = $Failed + 1 ;
}

//There’s a lot more code with error checks, and a few status echos to the screen…
//So instead of The if/else section above, should I use:

/ Set up new PHPmailer connection and set to SMTP version
$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);

//This is in a loop that selects just ONE Recipent… ( Set up recipient info which is just an email address )
$mail->AddAddress( $row[‘EmailAddress’] );

// Set up user information and server information
$mail->Username = “[" . $email5 ."](mailto:" . $email5 .")”;
$mail->Password = “my gMail PW”;
$mail->SetFrom(" 'From: Todd Greeno [" . $email5 ."](mailto:" . $email5 .")”;
$mail->Subject = $Subject;
$mail->Body = $msg;

//Send message to current recipient
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo “Message has been sent”;
}

//End of loop
}

Well, you should just make a much, very much, smaller test page to just for testing. As I have mentioned a few times so far. Just a super simple , one page test for sending an email. Once that works, then place the working version into your live version. You might need a lot of changes made to get this PHPmailer to work correctly. Hard to debug if you have all the other code. Something simply like this would be a good test page to try. Just copy this code, put in your password and then put on your server and execute the page. Call it something like email_test.php. Once it sends out a valid email to yourself, then, move the code to your live page. Test page:

<?PHP
//  Allow this page to display error messages
error_reporting(E_ALL);
ini_set("display_errors", 1);

// Set up new PHPmailer connection and set to SMTP version
$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);

//This is in a loop that selects just ONE Recipent… ( Set up recipient info which is just an email address )
$mail->AddAddress( YOUR EMAIL ADDRESS GOES HERE );

// Set up user information and server information
$mail->Username = “ YOUR EMAIL ADDRESS GOES HERE ”;
$mail->Password = “ YOUR EMAIL PASSWORD GOES HERE ”;
$mail->SetFrom = " YOUR EMAIL ADDRESS GOES HERE ";
$mail->Subject = "TEST EMAIL ! ";
$mail->Body = "JUST IGNORE THIS EMAIL, TESTING PHPmailer SYSTEM ! ";

//  Send message to current recipient
if(!$mail->Send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo “Message has been sent”;
}
?>

Just fill in your email info and run this file. If it does not work, then check the error messages and post it here and we can help you fix it. Once this page works and sends you an email, then you can move it to the more complicated version. Hope that makes sense…

OK, I used your short code, and ran it… I received this error:
Fatal error: Uncaught Error: Class ‘PHPMailer’ not found in /home2/hdlenhan/public_html/CardSender/0-MailTester.php:27 Stack trace: #0 {main} thrown in /home2/hdlenhan/public_html/CardSender/0-MailTester.php on line 27

I had previously called BlueHost and was told they had PHPMailer on their servers, but evidently that was not correct.

I went to the PHPMailer page you linked in a previous message, but when I get to that page, I am at a loss of what to do – that is, what file(s) do I copy, and do I just place them in the same folder as my code?

Thanks in advance!

Sorry, I was not home. Yes, you must put PHPMailer on your server. In Bluehost, I think you log into your control panel and in the dashboard move down to programs and select PHPMailer. Then, it will install on your server. Once you have it installed try your test page again. If you still have issues, you can install it manually using FTP. Let us know how it goes.

I do not see a section labeled “Programs” on my BH Control Panel, so I went to this site:

but it’s not clear what I need to download to get PHPMailer.

I would appreciate any suggestions.
Thank you!

Later today, I will locate what you need and post it here. ( Not at home right now. )
In the meantime, can you tell me which version of PHP you have on your server?
I have been using 7.4 as there are a lot of changes on my code for 8.0 or 8.0+.
You need to use the correct version of PHPmailer that matches your PHP version.

Therefore, let me know which version and I will post the version you need.

One other question… Are you needing to save your emails in your Gmail’s Sent-Folder?
If so, you will need other extra code to handle that part.

Here’s a screenShot from BlueHosts phpMyAdmin:

Also, I do not need to keep a copy of the messages I send – my code generates a separate Results eMail that shows each address and whether the Send was successful.

Thank you!

Thank you for the info. You do not need the latest version then.
When I get home I will send more info. A few hours from now.
I found detailed examples of how to handle this. There is one extra library you
need, but, it comes with the PHPmailer library. More later!

Sorry, NYC-HDL, my computer died after running a Windows 11 Update. I tracked it down to a problem with ExplorerPatcher which I use to keep my windows in separate displays on the taskbar. I have been down for a few days fixing it and backing it up. I will find the correct file for you later today now that I just got back up and running. Again, sorry for the delay!

Sponsor our Newsletter | Privacy Policy | Terms of Service