Jump to content

Recommended Posts

No idea why this isn't sending any emails. Can someone help me out?

 

$username = mysql_real_escape_string($_POST['user_name']);
$md5pass = md5(mysql_real_escape_string($_POST['password']));

//Contact Info
$fname = mysql_real_escape_string(strip($_POST['first_name']));
$lname = mysql_real_escape_string(strip($_POST['last_name']));

$result = mysql_query($sql, $cn) or header( 'Location: http://www.website.com/error.php?msg=registerfail' );

$get_id = mysql_query("select id from table where email='".$email."' and date_joined=".$date_joined, $cn);

while($get = mysql_fetch_row($get_id)){
	foreach($get as $g_id){
		$id = $g_id;
	}
}

if($result){
	$headers = "From: noreply@website.com" . "\n" .
		"Reply-To: support@website.com" . "\n" .
		"X-Mailer: PHP/" . phpversion() ."\n".
		"X-Priority: 1 (Higuest)\n";
	$message = "Thanks for registering with Website, ".$fname." ".$lname.
	".\n\nBefore you can login, you must verify your account by clicking on the following link:\n".
	"http://www.website.com/verify.php?ver=".$verify_key."&id=".$id."\n\n\nwww.website.com";
	$mail_success = mail($email, "Thank you for registering at Website", $message, $headers);
	if(!$mail_success){ header( 'Location: http://www.website.com/error.php?msg=emailfail' ); }
	header( 'Location: http://www.website.com/login.php' );
	exit();
}
else{
	header( 'Location: http://www.website.com/error.php?msg=emailfail' );
	exit();
}

Link to comment
https://forums.phpfreaks.com/topic/173015-need-some-help-with-mail-function/
Share on other sites

whats happening when you run this? does the error message pop up?

 

btw this line

"X-Priority: 1 (Higuest)\n";

 

what I'd assume is the word highest is spelled wrong. IDK if that would screw things up but you probably want to have that spelled right

well if the mail function didn't run false, than it is indeed sending the mail. Perhaps check your spam folder, or double check the send to address to make sure everything's value is as expected

 

However, I do not see anywhere in that code where you set the $email variable

hmmm thats weird.. Try talking to the admins that run your server or something. Maybe you were blacklisted from every mail site ever, though I don't see that as being probable... Try sending a simple plain text email. or delete some of the headers. I'm pretty much at a loss at this point.

Plain text emails aren't working either.

 

$mail_success = mail("myemail@yahoo.com", "Thank you for registering at Website", "test");

 

Not even this bit of code works...

 

 

Edit: Ahh...sorry folks, looks like the problem lies with the server host. They are having problems with one of their mail servers so no mail is going through right now. Sorry for wasting your time. Go ahead and delete this if you want.

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.