Jump to content


Photo

Mail Sending Error


  • Please log in to reply
1 reply to this topic

#1 alagardeGSMHP

alagardeGSMHP

    Newbie

  • New Members
  • Pip
  • 1 posts

Posted 04 March 2014 - 07:34 PM

Hey guys I've been getting this problem for a couple days now and it is highly likely this issues has been mentioned in this forum more than a few times but

 

HOW DO I GET PHP TO MAIL TO EXTERNAL ADDRESSES!

 

I'm developing a reset password function on the company website that sends to the email along with their new random generated ID (which i have yet to create.)

 

Everything is fine and dandy when i send it to local email but php generates this error:

 

Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay in C:\xampp\xampp\htdocs\passwordreset.php on line 101

 

I don't know if this is a php coding issue or a exchange issue

 

Here is a copy of my code:

 

<?php


$s=$_POST['s'];
if(isset($s)){


$username = $_POST['username'];
$email = $_POST['email'];


$query = "SELECT * FROM authuser WHERE username = '$username'";
$result = mysql_query($query);




if (!$result) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die($message);
}


$num = mysql_numrows($result);


//$row = mysql_fetch_assoc($result);


$i = 0;
while ($i < $num){ 


$USERNAME=mysql_result($result, $i, "username");
$EMAIL=mysql_result($result, $i, "EMAIL");
     
$newpassword = substr(md5(uniqid(mt_rand(), true)), 0, $l);




$subject = "HEALTH PORTAL PASSWORD RESET";
$message = "You have requested a password reset for the health portal Password for username ".$USERNAME."has been reset You have been assigned the default password ".$newpassword." The system will prompt you to change your password


$message = wordwrap($message, 70);
$to = $EMAIL;
$from = "From:alagarde@gsmhp.com";







mail($to,$subject,$message,$from);
?>

Any Ideas? I'm running Microsoft exchange server 2007 I believe

 

Thanks,

 

-Abe



#2 jeffreyappel

jeffreyappel

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts

Posted 11 April 2015 - 01:22 PM

Remember To prevent abuse for sending spam, many email servers require that the client be authenticated as a legitimate user before relaying mail (forwarding it to the recipient's email server). You have specified credentials in IIS; however, PHP does not make use of them.

 

Here are your options:

 

    Instead of the mail() function, use one of the existing PHP mailer libraries that supports SMTP authentication (PEAR Mail, phpmailer, Swift Mailer, etc.).

 

    Install and configure msmtp or one of the alternatives (here's how to make msmtp work with PHP). PHP will execute the program, which does support SMTP authentication, whenever it has to send a message if you set sendmail_path accordingly.

 

    Change the mail server's configuration to allow relaying mail from the web server's IP address.

 


Essay writing service by Pimion





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users