Jump to content

[SOLVED] mail function simply not working


asmith

Recommended Posts

Hey guys

 

This is a simple question I guess.

I had used mail function in a file that it worked yesterday, but today it is not. I contacted my site admin, he said everything is ok in their end, and I must check again.

 

I wrote another small code :

 

<?php
$headers  = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\nTo: myself<my mail>\r\nFrom: test <test>\r\n";

$mail_sent = mail('one of my mails','test','testing',$headers);

if ($mail_sent) echo "it is working";
else echo "it is not working";

?>

 

It says it is not working, but again no error message for the mail function, so that I don't what's going on. as I've been working with mail() so few, I don't know much about it.

 

any idea? same experience?

Link to comment
Share on other sites

<?php
ini_set ("display_errors", "1");
error_reporting(E_ALL);
$headers  = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\nTo: Monkey <monkey.island@hotmail.com>\r\nFrom: test <test>\r\n";

$mail_sent = mail('monkey.island@hotmail.com','test','testing',$headers);

if ($mail_sent) echo "it is working";
else echo "it is not working";

?>

 

shows no error. and still not sending.

I copies the file in another server and it worked. for sure the problem is my server, but as I can't see any error, I can't tell them what is wrong.

Link to comment
Share on other sites

If the mail() function is returning a false but no php notice or warnings are being produced, that would mean that your mail server is "silently" accepting emails but is not returning the actual error messages.

 

In general, if the To: address is hosted at your mail server or the From: address is hosted at your mail server, the email will be accepted and sent out. Is the actual From: email address you are putting in to the header a valid email address that is hosted on your mail server?

Link to comment
Share on other sites

To: is my mail . I need the info be mailed to me. From: is the email of the username.  I take his email address from database and put it to from: so that when the email is sent to me, I could reply the email, so that I send email to his actual email address.

 

So I gotta say no email , neither to: nor from: is set to my mail server, If I have understand you right.

 

what is my mail server address? Not bad to give it a try.

(so why the file works in other server?  their settings is different from this one probably ? )

Link to comment
Share on other sites

When you say "is not working", do you mean you're script prints "it is not working" or do you mean it prints "it is working" and you never get the email?

 

If it's the latter, then the problem is that sending email to hotmail.com via PHP can be problematic. Get yourself a gmail account and try sending the email there. Or check the SPAM mailbox on hotmail.

 

Ken

Link to comment
Share on other sites

I take his email address from database and put it to from
Use the Reply-To: address is for that. The From: address must be an email address at the sending mail server or at a domain that has an SPF record that says the sending mail server is authorized to send email for.
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.