Asked  1 Year ago    Answers:  5   Viewed   6 times

I have a form that populates a PHP mail to be sent to our clients, I want to BCC most of the clients due to privacy. I have the following code

$to = "******"; //To recipients 
$email_from = '*****';//<== update the email address
$email_subject = "New Overdue Loaded";
$email_body = "A new High Risk Client has been loaded by $name $company.n".
    "n Client Name: $driver_name $driver_surnamen
    n Client ID or Passport Number: $driver_idn
    n Nationality: $driver_nationalityn
    n Reason for Loading Client: $typen
    n Notes: $notesn
$headers = "From: $email_from rn";
$headers = "Bcc: ******;*****;******";
//$headers = "Reply-To: $visitor_email rn";
//Send the email!

I have added the BCC as a $headers but once I add this it doesn't send mails at all when I remove it I get the mail to the $to recipient.

I have tried spacing between the BCC mails as well. I have replaced the mail names with **** for spamming reasons



You should concatenate $headers

Example :

$headers  = "From: ***** phprn";
$headers .= "MIME-Version: 1.0rn"; #Define MIME Version
$headers .= "Content-Type: text/html; charset=ISO-8859-1rn"; #Set content type
$headers .= "Bcc: $EmailListHerern"; #Your BCC Mail List
Thursday, April 1, 2021

Based on you code i notice that you are sending an email directly from you web page on your domain.

For example you used an address.

When the recipient receive the emails the mail service of the recipient may test a reverse DNS of the sender of the mail. So the sender is from but the mail comes from your domain which of course is not

So I receive a mail from an address but the IP sender isn't related at all with domain that's SPAM!

I think a possible solution is: in you PHP code use authenticate with SMTP and from there send the mail!

Thursday, April 1, 2021

use $headers['Cc'] = ',,';

see the link below for pear mail

Sending multiple CC's and BCCs with PHP PEAR MAIL

or can get help from -- it is not pear mail. but it works very fine. I have used this and it is very easy to integrate.

Thursday, April 1, 2021

After trying various ways, i found following code working with almost all email providers

$to['email'] = "recipients email address";      
$to['name'] = "name";   
$subject = "email subject";
$str = "<p>Hello, World</p>";
$mail = new PHPMailer;
$mail->SMTPAuth = true;
$mail->Host = 'Specify main and backup server here';
$mail->Port = 465;
$mail->Username = '';
$mail->Password = 'email account password';
$mail->SMTPSecure = 'ssl';
$mail->From = 'From Email Address';
$mail->FromName = "Any Name";
$mail->AddReplyTo('', 'any name'); 
$mail->Priority = 1;
$mail->AddCustomHeader("X-MSMail-Priority: High");
$mail->WordWrap = 50;    
$mail->Subject = $subject;
$mail->Body    = $str;
if(!$mail->Send()) {
$err = 'Message could not be sent.';
$err .= 'Mailer Error: ' . $mail->ErrorInfo;                        


variable values needs to be changed accordingly. Hope these helps people having issues with PHPmailer

Saturday, May 29, 2021

Sending to all as BCC will be a lot faster. The code will execute faster and mail() will be executed only once.

This is the quick fix, but as mentioned, a large BCC list is a safe road to the spam folder. However, using mail() is a sure destination to spam too.

If you want to actually improve it, use PHPMailer from SourceForge and send via SMTP (less spam hits) using cron in batches of X emails once.

The PHP docs state:

It is worth noting that the mail() function is not suitable for larger volumes of email in a loop. This function opens and closes an SMTP socket for each email, which is not very efficient.

For sending large amounts of email, see the » PEAR::Mail, and » PEAR::Mail_Queue packages.

Saturday, May 29, 2021
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :