Page 1 of 1

phpmailer trouble

Posted: Tue Sep 12, 2006 11:20 am
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!

Posted: Tue Sep 12, 2006 11:33 am
by jayshields
Add this line before you send the email

Code: Select all

$mail->SMTPDebug = TRUE;

Posted: Tue Sep 12, 2006 11:36 am
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?

Posted: Tue Sep 12, 2006 11:39 am
by jayshields
Are you trying this on your home server? Running Windows?

Have you changed the SMTP settings in your php.ini file?

Posted: Tue Sep 12, 2006 11:40 am
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.

Posted: Tue Sep 12, 2006 11:45 am
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.

Posted: Tue Sep 12, 2006 11:47 am
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.

Posted: Tue Sep 12, 2006 11:49 am
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.

Posted: Tue Sep 12, 2006 12:06 pm
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!