asmith Posted October 29, 2008 Share Posted October 29, 2008 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? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 29, 2008 Share Posted October 29, 2008 Add the following two lines immediately after your first <?php tag to get php to show what error is occurring - ini_set ("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment Share on other sites More sharing options...
asmith Posted October 29, 2008 Author Share Posted October 29, 2008 <?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. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 29, 2008 Share Posted October 29, 2008 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? Quote Link to comment Share on other sites More sharing options...
asmith Posted October 29, 2008 Author Share Posted October 29, 2008 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 ? ) Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted October 29, 2008 Share Posted October 29, 2008 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 Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 29, 2008 Share Posted October 29, 2008 I take his email address from database and put it to fromUse 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.