kwstephenchan Posted March 9, 2009 Share Posted March 9, 2009 Hi all, I tried sending email using phpmailer. It works for one account and it does not work for another. For example, if I use [email protected] as sender to send out mail it works. But if use [email protected] as the sender, it does not send out the mail. To confirm the set up and password is correct, I tried sending the email from the 126 account instead of from the PHP program, it works. The smtp server I used is smtp.126.com. Is it possible that one account is attached to smtp.126.com and another account is attached to another smtp server, thus if I use smtp.126.com. it works for one account and it does not work for another. Is this possible?? Any one any hints?? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/148588-same-email-service-two-email-account-one-work-one-doesnt-using-phpmailer/ Share on other sites More sharing options...
WolfRage Posted March 9, 2009 Share Posted March 9, 2009 Why do you not just use mail(); ? Quote Link to comment https://forums.phpfreaks.com/topic/148588-same-email-service-two-email-account-one-work-one-doesnt-using-phpmailer/#findComment-780310 Share on other sites More sharing options...
PFMaBiSmAd Posted March 9, 2009 Share Posted March 9, 2009 Why do you not just use mail(); ? Because mail() does not support SMTP Authentication which is necessary to send through an ISP's mail server. The phpmailer class should return an error from the mail server if the smtp settings are not correct. What is your code? Quote Link to comment https://forums.phpfreaks.com/topic/148588-same-email-service-two-email-account-one-work-one-doesnt-using-phpmailer/#findComment-780324 Share on other sites More sharing options...
WolfRage Posted March 9, 2009 Share Posted March 9, 2009 Copy that, I digress. Quote Link to comment https://forums.phpfreaks.com/topic/148588-same-email-service-two-email-account-one-work-one-doesnt-using-phpmailer/#findComment-780331 Share on other sites More sharing options...
kwstephenchan Posted March 9, 2009 Author Share Posted March 9, 2009 The following are my codes: I have defined this as a function and it is called by a main program. The problem : if I use the account abc.126.com, it works, if I used another one, it does not. The user id and password of another account are correct (I tested that). So I do not know why. By the way, I put the error_reporting(E_ALL), I am not getting any error message. code -- function smtp_mail ($subj,$body,$email,$name) { $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP $mail->Host = "smtp.126.com"; // SMTP servers $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "abc"; // SMTP username $mail->Password = "abc254494"; // SMTP password $mail->From = "[email protected]"; // sender email address $mail->FromName = "cs@abc"; // sender name $mail->CharSet = "GB2312"; // ! $mail->Encoding = "base64"; $mail->AddAddress($email,$name); // recipient email and name $mail->IsHTML(true); // send as HTML $mail->Subject = $subj; // $mail->Body = $body;// $mail->AltBody ="text/html"; $mail->Send(); } -- end code Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/148588-same-email-service-two-email-account-one-work-one-doesnt-using-phpmailer/#findComment-780365 Share on other sites More sharing options...
PFMaBiSmAd Posted March 9, 2009 Share Posted March 9, 2009 Replace your $mail->Send(); line with the following - if(!$mail->Send()) { echo 'Mailer error: ' . $mail->ErrorInfo; } Quote Link to comment https://forums.phpfreaks.com/topic/148588-same-email-service-two-email-account-one-work-one-doesnt-using-phpmailer/#findComment-780369 Share on other sites More sharing options...
kwstephenchan Posted March 9, 2009 Author Share Posted March 9, 2009 The error is: Mailer error: SMTP Error: Could not connect to SMTP host. But if I use another account, the mail will be sent. Don't know why. Quote Link to comment https://forums.phpfreaks.com/topic/148588-same-email-service-two-email-account-one-work-one-doesnt-using-phpmailer/#findComment-780393 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.