WebsiteBaker Community Forum

General Community => Global WebsiteBaker 2.8.x discussion => Topic started by: ruebenwurzel on May 16, 2008, 07:43:20 PM

Title: multiple recipients and mail formating in mailer class
Post by: ruebenwurzel on May 16, 2008, 07:43:20 PM
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
Code: [Select]
$myMail->AddAddress($toaddress);with:
Code: [Select]
$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
Code: [Select]
$myMail->AltBody = strip_tags($message);with:
Code: [Select]
$myMail->AltBody = str_replace("<br \\>", "\r\n", $message);
So please test it.

Matthias
Title: Re: multiple recipients and mail formating in mailer class
Post by: diodak on May 17, 2008, 08:25:11 AM
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?
Title: Re: multiple recipients and mail formating in mailer class
Post by: Lotus on May 26, 2008, 10:08:10 AM
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"?
Title: Re: multiple recipients and mail formating in mailer class
Post by: DGEC on June 02, 2008, 01:02:57 AM
I don't think that gets bcc.. seems to be tricky,, try this guy's solution:
http://www.phpbuilder.com/board/showthread.php?t=10314199
Title: Re: multiple recipients and mail formating in mailer class
Post by: doc on June 02, 2008, 07:39:46 AM
@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