Jump to content

error when sending mail


cluce

Recommended Posts

my situation: I am in an internal network that is using our company's SMTP. I am working on a forgot password page for our website.  When I type in an email and submit it it verifies that the email is in the database and sends that email account the username and password. 

 

This only works with the company's email accounts such as me@company.com but when I use me@yahoo.com it does not send the username and password. I receive these errors....

 

 

Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for me@yahoo.com in C:\wamp\www\email_info.php on line 28

 

Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\email_info.php:28) in C:\wamp\www\email_info.php on line 30

 

 

can someone tell me what the problem may be????

 

 

Link to comment
Share on other sites

ok here is the code......

<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

//connects to database
$mysqli = mysqli_connect("localhost", "root", "", "test");

//check to see if email exists in database/table
$usercheck = strip_tags(trim($_POST['email']));
$check = mysqli_query($mysqli,"SELECT email FROM auth_users WHERE email = '$usercheck' LIMIT 1"); 
$check2= mysqli_num_rows($check);

//if the email does not exist, it gives an error
if ($check2 != 0) {


    //create and issue the query
    $sql = "SELECT username, password FROM auth_users WHERE email = '".$_POST["email"]."' LIMIT 1";
    $res = mysqli_query($mysqli, $sql); 
$bodyArr = mysqli_fetch_array($res);
    	
//send query through email	
    $to = $_POST["email"];
$subject = "Account Information";
    $body = "Username: " . $bodyArr['username'] . "\nPassword: " . $bodyArr['password'];

mail ($to, $subject, $body);

header("Location: http://localhost/Account_information.html");

}else{
    $_SESSION['emailExists'] = "<font color='red'>The email"." ".$_POST['email']." "."does not exist in our database.<br>You may register for free by filling out the online registration form.</font>";	
header ("Location: forgot_password.php");
}
mysqli_close($mysqli);
?>

Link to comment
Share on other sites

well you are using a wamp server, so wamp is probably using a third party SMTP server. find out what the SMTP server is, visit their site, and ask on their forums. the code looks fine to me, or i could be wrong lol.

 

i wish i could be more help,

 

HoTDaWg

Link to comment
Share on other sites

thanks for the reply. I think my code is right too. ;D  For some reason the mail server doesn't wont to relay the message externally.

 

It does send email just not to my external accounts(ex. gmail, yahoo,etc.).  It only sends  the messges to my company email accounts.

 

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.