Solved

php mailer not sending to all addresses

Posted on 2004-10-04
6
533 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

810 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