Solved

php mailer not sending to all addresses

Posted on 2004-10-04
6
540 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

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…
This article discusses how to create an extensible mechanism for linked drop downs.
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

840 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