CincoPistolero Posted November 6, 2008 Share Posted November 6, 2008 Hi all, I have a form that captures data and then updates a db. On the same page that it updates the db, I'm trying to get it to email some of the form information. As a test, I put together a simple mail test page to see if it would send email at its most basic form. Alas, it is not sending anything. I've tried multiple email boxes to no avail. My site is hosted on one of the many linux hosting sites out there. I have checked the phpinfo() and it appears that mail is turned on. I am assuming that when the page loads, it reads through the script, and runs the mail function. Can someone review my code below and confirm it is ok or not. This is the php page in its entirety <?php //multiple recipients $to="my@email.net"; //subject $subject="test"; //body $message="test body"; $from="where@sentfrom.com"; $headers="From: $from"; //mail it mail($to, $subject, $message, $headers); echo "Mail Sent."; ?> If the above code looks ok, what else could cause the issue of not mailing? What else should I be looking at. Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/131674-stumped-by-simple-email/ Share on other sites More sharing options...
DeanWhitehouse Posted November 6, 2008 Share Posted November 6, 2008 Try using an email address that is real, and if that doesn't work use one you have registered on the host. Quote Link to comment https://forums.phpfreaks.com/topic/131674-stumped-by-simple-email/#findComment-683894 Share on other sites More sharing options...
CincoPistolero Posted November 6, 2008 Author Share Posted November 6, 2008 the fake emails I used in the code above were to hide the real emails I have been using. Quote Link to comment https://forums.phpfreaks.com/topic/131674-stumped-by-simple-email/#findComment-683899 Share on other sites More sharing options...
DeanWhitehouse Posted November 6, 2008 Share Posted November 6, 2008 You can't use it like that i don't think, if you want to do that look at PHPmailer. Quote Link to comment https://forums.phpfreaks.com/topic/131674-stumped-by-simple-email/#findComment-683903 Share on other sites More sharing options...
rhodesa Posted November 6, 2008 Share Posted November 6, 2008 There is nothing wrong with your script. If it works without the $header variable being passed, then that means your host doesn't allow you to use a "From" address that it doesn't recognize. Setup an account like info@yourdomain.com and use that email as the From. Quote Link to comment https://forums.phpfreaks.com/topic/131674-stumped-by-simple-email/#findComment-683909 Share on other sites More sharing options...
Imad Posted November 6, 2008 Share Posted November 6, 2008 Hmm. add this to the top of your file under the php opening tag: error_reporting(E_ALL); the code seems fine, you might be getting an error because of a php setting set off. Quote Link to comment https://forums.phpfreaks.com/topic/131674-stumped-by-simple-email/#findComment-683910 Share on other sites More sharing options...
DeanWhitehouse Posted November 6, 2008 Share Posted November 6, 2008 There is nothing wrong with your script.If it works without the $header variable being passed, then that means your host doesn't allow you to use a "From" address that it doesn't recognize. Setup an account like info@yourdomain.com and use that email as the From. It could be more than that, it could be like my host which will only allow an email account set up on them to be used, or for all we know the mail feature might be disabled by the host for his account type. Edit: If it works without the $header variable being passed, then that means your host doesn't allow you to use a "From" address that it doesn't recognize. You failed to mention what i did above, that's all i was pointing out, no need to get defensive. Quote Link to comment https://forums.phpfreaks.com/topic/131674-stumped-by-simple-email/#findComment-683914 Share on other sites More sharing options...
rhodesa Posted November 6, 2008 Share Posted November 6, 2008 i said "If it WORKS without the $header variable being passed"... if it doesn't work...even without the $header variable...then mail is most likely not configured properly. Quote Link to comment https://forums.phpfreaks.com/topic/131674-stumped-by-simple-email/#findComment-683919 Share on other sites More sharing options...
CincoPistolero Posted November 6, 2008 Author Share Posted November 6, 2008 First - I added the error checking, it returns nothing. I took out the header tages and just sent the to, subject and message - and I still get nada. Second - I can't control my php.ini file. What setting should I look for on the phpinfo() output to confirm or unconfirm the mail settings. Third - I do all my data gathering and db submission via php, I just want the confirm page to send and email, is there a better way to do this, or another way? Quote Link to comment https://forums.phpfreaks.com/topic/131674-stumped-by-simple-email/#findComment-683931 Share on other sites More sharing options...
CincoPistolero Posted November 6, 2008 Author Share Posted November 6, 2008 I found these settings in my display phpinfo() sendmail_from no value no value sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i SMTP localhost localhost smtp_port 25 25 Quote Link to comment https://forums.phpfreaks.com/topic/131674-stumped-by-simple-email/#findComment-683938 Share on other sites More sharing options...
DeanWhitehouse Posted November 6, 2008 Share Posted November 6, 2008 It seems most of my posts are invisible, did you try anything i said? Quote Link to comment https://forums.phpfreaks.com/topic/131674-stumped-by-simple-email/#findComment-683944 Share on other sites More sharing options...
rhodesa Posted November 6, 2008 Share Posted November 6, 2008 The only other thing I can think of is to check your SPAM filter on your email (if you have one). Is this through a hosting service? If so, you should contact them. Your script is fine. Nothing looks out of the ordinary. The Tech Support there will be able to tell you if they configured the mail improperly or if your messages are being blocked. Who is the hosting with out of curiosity? Quote Link to comment https://forums.phpfreaks.com/topic/131674-stumped-by-simple-email/#findComment-684029 Share on other sites More sharing options...
CincoPistolero Posted November 6, 2008 Author Share Posted November 6, 2008 I just put in a support ticket with my hosting company. I'd rather not name names at this point. thanks for everyones input, I'll update post as soon as I go over my account with support. I did create an account specific to this domain, and it wouldn't email to it either. I'm not even using FROM anymore. Just trying to keep as simple as possible just to prove it can send mail. Quote Link to comment https://forums.phpfreaks.com/topic/131674-stumped-by-simple-email/#findComment-684118 Share on other sites More sharing options...
CincoPistolero Posted November 7, 2008 Author Share Posted November 7, 2008 Funny findings. PHp mail() is working. The script I have put up top does send email to my work account, but does not send to my host account or any yahoo.mail accts. Go figure. Waiting for response back from host as to why? Little hard to test when I am at home working on this and it won't send to any account I have on home machine. Fun. Quote Link to comment https://forums.phpfreaks.com/topic/131674-stumped-by-simple-email/#findComment-684208 Share on other sites More sharing options...
CincoPistolero Posted November 7, 2008 Author Share Posted November 7, 2008 I wonder if my host email acct and my yahoo email need specific header info to accept the message. My outlook express does not contain a spam folder for my host account but my yahoo does and the message doesn't show up there. Quote Link to comment https://forums.phpfreaks.com/topic/131674-stumped-by-simple-email/#findComment-684211 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.