multiple recipients and mail formating in mailer class

doc

@DGEC:
Multiple BCC, CC and TOs is easy to integrate with the PHPMailer class. Have done this for a customer some time ago for the massmail module. If I find the time I will post the solution in the massmail thread.

Regards Christian

DGEC


Lotus

hmm, in WB 2.7 you can have multiple recipients in the settings for form by separating them with a "," but all adresses will show in the recipients mail, as in "TO". (I have tried two adresses).

@ruebenwurzel will this make a recipent "BCC" instead of "TO"?

diodak

As I understand, i can add several e-mail addresses at form module like in example: test1@tes.com, test2@tes.com, test3@tes.com which in fact I`m doing on some of my websites and this snippet will send 3 mails for several addresses that none of the recepitnents will know about each other?
Buchsbaum

ruebenwurzel

Hello,

got today a mail with some nice ideas for a tweaked mailer class. Here are the descriptions and the changes:

1. multiple recipients
First change is to support multiple recipients on form submission (For example, when a user submits a web request in my case there are usually always two persons responsible - one is the primary responsible and one the secondary when the first is not available. Depending on the particular form it is other people. Creating distribution lists on the mail server is more difficult and I neither have the permissions to do that. So specifying more recpients using comma to separate multiple e-mail addresses is a good help here.

Replace Line 328 of framework/class_wb.php
$myMail->AddAddress($toaddress);
with:
$addresses = explode(",", $toaddress);
if (count($addresses) > 0) {
   for ($i = 0; $i < count($addresses); $i++) {
       $add = trim($addresses[$i]);
       $myMail->AddAddress($add);
   }
} else {
   $myMail->AddAddress($toaddress);
}


2.) Email output:
Second change is because of the fact that the form e-mail sent arrives in a one-liner getting wrapped to multiple lines somewhere which makes the e-mail not very readable.

Replace Line 331 of framework/class_wb.php
$myMail->AltBody = strip_tags($message);
with:
$myMail->AltBody = str_replace("<br \\>", "\r\n", $message);

So please test it.

Matthias