Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

php mailer not sending to all addresses

Posted on 2004-10-04
6
Medium Priority
?
570 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 1200 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 400 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 1200 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 400 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

972 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