Solved

php mailer not sending to all addresses

Posted on 2004-10-04
6
512 Views
Last Modified: 2010-07-27
Hi, I need some urgent help. My client is getting quite upset...I've got the following code to send an email to multiple addressses. For some reason, it's only sending to the first AddAddress.....although I can see all the to addresses when $email receicves the mail in the to box...
I swear I tested this out b4, but now it doesn't work...please can anyone tell me why?

$mail = new PHPMailer();
$mail->From = "sender@sender.com";
$mail->FromName = "your friend sender";
$mail->AddAddress('$email', '$contactname');
$mail->AddAddress('me@me.com', 'Phil');
$mail->AddReplyTo("sender@sender.com");
$mail->Subject = "Ball Registration";
$mail->IsHtml(true);
$mail->Body = $emailcontent;
$mail->AltBody = "you email client is HTML disabled";
if(!$mail->Send()) {
     echo "Message was not sent";
     echo "Mailer Error: " . $mail->ErrorInfo;
}

else {
    header('Location: http://www.casbaaconvention.com/success.html');
}
0
Comment
Question by:skylabel
6 Comments
 
LVL 12

Expert Comment

by:minichicken
ID: 12224339
Maybe in your PHPMailer class, disable email address validation and see.

j311y :)
0
 
LVL 7

Accepted Solution

by:
jdpipe earned 300 total points
ID: 12224480
Sometimes the configuration of your mailserver can be an issue. For example, if you are connecting to smtp.server.com, you will usually be allowed to send to anyone@server.com but not to anyone@another.com, unless you are a 'trusted sender'.

With many ISPs, your localhost will also be acting as the SMTP server, so the 'trusted sender' problem isn't serious. But if perhaps your ISP gives you a separate SMTP server, then there can be problems.

Try configuring phpmailer to use the 'SMTP' mode of sending, instead of the 'mail' mode, and see if you can get some more diagnostic information back.

Also try sending using the plain old mail() function.

Hope that helps
JP
0
 
LVL 27

Assisted Solution

by:Diablo84
Diablo84 earned 100 total points
ID: 12224892
There isn't a problem with the script, and if you can see the other addresses in the to line of the email you are receiving then it suggests that prehaps the problem isn't originating on the server, so it could be a case of the emails are being classed as junk email when receivied by the other servers or they is a time delay. If you have any doubts you could resort to sending them one by one and looping through the phpmailer code.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 27

Expert Comment

by:Diablo84
ID: 12224912
You could also try sending the additional mails as a carbon copy, or a blind carbon copy, eg:

$mail->AddCC('me@me.com', 'Phil');

or

$mail->AddBCC('me@me.com', 'Phil');

These are both limited to win32 though.
0
 
LVL 7

Assisted Solution

by:jdpipe
jdpipe earned 300 total points
ID: 12225556
I think Diablo's comment about AddCC and AddBCC is a bit unclear: the AddCC and AddBCC commands will work fine on Win32 so long as you choose the 'SMTP' mailer mode. And they will both work fine on unixy systems whichever way you configure, either 'mail' or 'SMTP'. Here's frmo the docs:

"Note: this function works with the SMTP mailer on win32, not with the "mail" mailer."
http://phpmailer.sourceforge.net/docs/

JP
0
 
LVL 14

Assisted Solution

by:ThG
ThG earned 100 total points
ID: 12225744
The following is stupid as it won't produce any varsub in PHP:
$mail->AddAddress('$email', '$contactname');

remember that single quote ' ' will add literal text, while double quotes " " will allow parsed string. so:
$mail->AddAddress("$email", "$contactname");

is the first step to go. Next, I would say to loop through all your addresses and call multiple time the AddAddress() method, but that depends on your variables structure.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now