ninedoors Posted October 7, 2007 Share Posted October 7, 2007 I am having a problem with the phpmailer. I have been using the following code to try and send emails to all the people in my database. But it isn't really working properly, I have been trying to test it with my own email addresses one at a time. The problem is that when I try and send an email to me@hotmail.com or me @rogers.com it isn't sending the email although I am getting the 'Message has been sent' from the bottom of my code. As you can see I am using the email help@barriemenshockey.com to send the emails from. When I send an email to me@barriemenshockey.com it goes through and works. I can't figure it out and any help would be great. Here's the script I am using: <?php require("class.phpmailer.php"); require("phpmailer.lang-en.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "mail.barriemenshockey.com"; // SMTP server $mail->SMTPAuth = "true"; // turn on SMTP authentication $mail->Username = "help@barriemenshockey.com"; // SMTP username $mail->Password = "*********"; // SMTP password include 'mailconfig.php'; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $mail->From = "info@barriemenshockey.com"; $mail->FromName = "Barrie Mens Hockey League"; $query = "SELECT name, email FROM Test"; $result = mysql_query($query); while ($row = mysql_fetch_array ($result)) { // HTML body $body = "Hey " . $row['name'] . ", <p>"; $body .= "Something I would like to write<p>"; $body .= "Sincerely, <p>"; $body .= "Nick and Rob"; //non-HTML body $textbody = "Hey " . $row['name'] . ", \n\n"; $textbody .= "Some thing I would like to write\n\n"; $textbody .= "Sincerely, \n"; $textbody .= "Nick and Rob"; $mail->Subject = "Final BMHL dues"; $mail->Body = $body; $mail -> AltBody = $textbody; $mail->AddAddress($row['email']); $mail->WordWrap = 50; if(!$mail->Send()) { echo "There has been a mail error sending to " . $row["email"] . "<br>"; echo 'Mailer error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent.'; } // Clear all addresses and attachments for next loop $mail->ClearAddresses(); } ?> Thanks Quote Link to comment Share on other sites More sharing options...
AV1611 Posted October 7, 2007 Share Posted October 7, 2007 Does your server allow you to do mail relay? Many servers only let you send to foreign hosts if the sender is a valid user. You said you are sending @hotmail.com... I would never allow that on my server... SPAMMERS are getting harder to combat, and mail relay is an often exploited configuration. Quote Link to comment Share on other sites More sharing options...
ninedoors Posted October 7, 2007 Author Share Posted October 7, 2007 I'm not sure, is there a way around the mail relay? How do I check if my server allows it? Quote Link to comment 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.