Forum Moderators: coopster

Message Too Old, No Replies

PHPMailer sends mail butgives error

         

smagdy

6:36 am on Jun 17, 2005 (gmt 0)

10+ Year Member



hi,
am using latest PHPMailer and it sends emails fine but take a loot at this last part of the code...

mailer->send();

if(!mailer->send())
{
echo"error":
}

so it sends the mail very fine but also echo error so how is that possible?

I mean its good that is sendin the mails but i still wana check if there is error in sendin any of the emails in the loop so i mark in the DB who didnt recieve so i resend it or somethig

thanks in advance

coopster

1:08 pm on Jun 17, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I've never used PHPMailer so I'm not familiar with the code, but why attempt to send the mail twice, which is exactly what you are doing here. The other thing to check is what exactly is returned by that method? Is it a true/false value?
// No need to do this here if you are  
// going to check it again anyway ...
//mailer->send();
if(!mailer->send()) {
echo "error"; //<-- you had a colon here, not a semicolon
}

dreamcatcher

1:17 pm on Jun 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ar you creating a new mail class $mailer? Should it be like this:

$mailer = new PHPMailer();

$mailer->send();

if(!$mailer->send())
{
echo"error":
}

dc

smagdy

1:34 pm on Jun 17, 2005 (gmt 0)

10+ Year Member



Yes exactly like this:

$mailer = new PHPMailer();

$mailer->send();

if(!$mailer->send())
{
echo"error";
}

and its working fine but it echo the error!

so i think it should echo error when it doesnt send not when it sends.

dreamcatcher

2:54 pm on Jun 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does $mailer->send() actually return a value? Maybe thats the problem?

Why not just use $mailer->send() without the error?

smagdy

4:24 pm on Jun 17, 2005 (gmt 0)

10+ Year Member



because I want to know if the mailer couldnt send one of the emails in the mailing list!

yes it returned a value 1 when it sends but also returned same value 1 when i tried to send to wrong email without domain name