phpmailer trouble

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jmilane
Forum Commoner
Posts: 89
Joined: Mon Aug 07, 2006 6:05 pm

phpmailer trouble

Post by jmilane »

hi,

using phpmailer

i have an array of checkboxes, each designating a program that people can apply to.

in my code, i go through the array of checkboxes and concatenate the associated email addresses into the $to variable

Code: Select all

foreach ($_POST[custom_12] as $key => $value) {
            $to = $to . $value . '; '
        }
works fine...

but when i go to send the mail, i get this:

Code: Select all

Message was not sent 
Please tell the Administrator: Mailer Error: SMTP Error: The following recipients failed: erc@myco.org; tti@myco.org;
erc and tii are exchange server aliases. does this matter?

or is the problem that $to is a string with embedded semicolons?

i am doing this:

Code: Select all

$mail->AddAddress($to,"Coordinator(s)");
thanks!
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

Add this line before you send the email

Code: Select all

$mail->SMTPDebug = TRUE;
jmilane
Forum Commoner
Posts: 89
Joined: Mon Aug 07, 2006 6:05 pm

Post by jmilane »

jayshields wrote:Add this line before you send the email

Code: Select all

$mail->SMTPDebug = TRUE;
Okay. Thanks. I get this:

Code: Select all

FROM SERVER: 501 5.5.4 Invalid Address SMTP
But they are valid addresses. Must be the way they are strung together, huh?
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

Are you trying this on your home server? Running Windows?

Have you changed the SMTP settings in your php.ini file?
jmilane
Forum Commoner
Posts: 89
Joined: Mon Aug 07, 2006 6:05 pm

Post by jmilane »

jayshields wrote:Are you trying this on your home server? Running Windows?

Have you changed the SMTP settings in your php.ini file?
It works... just not when I try to do this.

Otherwise I can send SMTP fine... just not when I add multiple addresses this way.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

jmilane wrote:
jayshields wrote:Are you trying this on your home server? Running Windows?

Have you changed the SMTP settings in your php.ini file?
It works... just not when I try to do this.

Otherwise I can send SMTP fine... just not when I add multiple addresses this way.
I find it hard to believe you. Try sending to one address in the exact same script, just remove all other AddAddress calls except one. Does it work? If it does, I can't help you any further. Sorry.
jmilane
Forum Commoner
Posts: 89
Joined: Mon Aug 07, 2006 6:05 pm

Post by jmilane »

jayshields wrote:
jmilane wrote:
jayshields wrote:Are you trying this on your home server? Running Windows?

Have you changed the SMTP settings in your php.ini file?
It works... just not when I try to do this.

Otherwise I can send SMTP fine... just not when I add multiple addresses this way.
I find it hard to believe you. Try sending to one address in the exact same script, just remove all other AddAddress calls except one. Does it work? If it does, I can't help you any further. Sorry.
Okay, I must not have been clear.

I am only doing ONE AddAddress call.

Before I do the call, I am concatenating all the addresses into one variable

I am adding that variable (with multiple addresses concatenated inside of it)

And it fails.

If I just add a regular email address, it works fine.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

That's because you're not supposed to interface with PHPMailer like that. You have to call addAddress() multiple times with the correct parameters. It's trying to use your concatenated string in the RCPT envelope command directly. That's not how SMTP works; SMTP has to call RCPT multiple times itself.
jmilane
Forum Commoner
Posts: 89
Joined: Mon Aug 07, 2006 6:05 pm

Post by jmilane »

d11wtq wrote:That's because you're not supposed to interface with PHPMailer like that. You have to call addAddress() multiple times with the correct parameters. It's trying to use your concatenated string in the RCPT envelope command directly. That's not how SMTP works; SMTP has to call RCPT multiple times itself.
Okay, thanks!
Post Reply