Solved

php mailer not sending to all addresses

Posted on 2004-10-04
6
559 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

 
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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.

622 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