Jump to content

Mail Sending Error


alagardeGSMHP

Recommended Posts

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

Link to comment
Share on other sites

  • 1 year later...

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.