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 = "******@e-track.co.za"; //To recipients 
$email_from = '*****@etrackbureau.co.za';//<== 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: ******@e-track.co.za;*****@e-track.co.za;******@e-track.co.zarn";
//$headers = "Reply-To: $visitor_email rn";
//Send the email!
mail($to,$email_subject,$email_body,$headers);

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

 Answers

4

You should concatenate $headers

Example :

$headers  = "From: *****@etrackbureau.co.zarnX-Mailer: 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
 
4

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 @hotmail.com 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 @hotmail.com but the mail comes from your domain which of course is not hotmail.com.

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

http://en.wikipedia.org/wiki/Reverse_DNS_lookup

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

Thursday, April 1, 2021
 
1

use $headers['Cc'] = 'cc@example.com, bb@example.com, dd@ex.com';

see the link below for pear mail

Sending multiple CC's and BCCs with PHP PEAR MAIL

or can get help from

http://phpmailer.worxware.com/index.php?pg=exampledb -- 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
 
hakre
 
5

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->IsSMTP();                                     
$mail->SMTPAuth = true;
$mail->Host = 'Specify main and backup server here';
$mail->Port = 465;
$mail->Username = 'xyz@domainname.com';
$mail->Password = 'email account password';
$mail->SMTPSecure = 'ssl';
$mail->From = 'From Email Address';
$mail->FromName = "Any Name";
$mail->AddReplyTo('xyz@domainname.com', 'any name'); 
$mail->AddAddress($to['email'],$to['name']);
$mail->Priority = 1;
$mail->AddCustomHeader("X-MSMail-Priority: High");
$mail->WordWrap = 50;    
$mail->IsHTML(true);  
$mail->Subject = $subject;
$mail->Body    = $str;
if(!$mail->Send()) {
$err = 'Message could not be sent.';
$err .= 'Mailer Error: ' . $mail->ErrorInfo;                        
}

$mail->ClearAddresses();

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

Saturday, May 29, 2021
 
Neysor
 
1

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:

Note:
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
 
Jauco
 
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 :