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 [email protected] but when I use [email protected] 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 [email protected] 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
https://forums.phpfreaks.com/topic/52372-error-when-sending-mail/
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);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.