pluginbaby Posted August 19, 2006 Share Posted August 19, 2006 [code]<?php$to = '[email protected]';$subject = 'test';$message = 'hello';mail($to, $subject, $message);echo "email send";?>[/code]I used this piece of code to test that an email would be send to my if I run it.I run it and it gives me the message: "email send". When I look in my inbox there is nothing there.I checked if the email address is correct, and it is.I waited 24 hours for the email to arrive, and still nothing.I have send the email more then 1 time, so it should be there...What can the problem be then? Link to comment https://forums.phpfreaks.com/topic/18028-what-is-the-problem/ Share on other sites More sharing options...
Yesideez Posted August 19, 2006 Share Posted August 19, 2006 Have you checked the junk inbox of your hotmail account its being sent to? I've found emails generated by my scripts often end up there. Link to comment https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77210 Share on other sites More sharing options...
pluginbaby Posted August 19, 2006 Author Share Posted August 19, 2006 checked a couple of times, but none of them are in there... :( Link to comment https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77212 Share on other sites More sharing options...
kenrbnsn Posted August 19, 2006 Share Posted August 19, 2006 Most email programs expect to see a "From:" header or they will toss the email down the bit bucket. Add at least the fourth parameter to the mail() function:[code]<?php$to = '[email protected]';$subject = 'test';$message = 'hello';$headers = 'From: [email protected]';if (mail($to, $subject, $message,$headers)) echo "email send";?>[/code]Note: A successful return from the mail() function just means that your message was queued to be sent, not that it was sent successfully.Also, hotmail.com has been notorious for filtering out email messages and not telling about it. If you have another email address you can use to test with, try that one.Ken Link to comment https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77214 Share on other sites More sharing options...
pluginbaby Posted August 19, 2006 Author Share Posted August 19, 2006 Okay, I tried with the "From ..." thing.Still got nothing in my inbox...Anyway, I want to use this for a registration. You register and an activation is send to your email address. If this doesn't work on hotmail, there is no point of building that, since a lot of people I know only have hotmail. :o Link to comment https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77215 Share on other sites More sharing options...
pluginbaby Posted August 19, 2006 Author Share Posted August 19, 2006 I used a yahoo email address, and now I got the email.Is there any way I can solve this problem that hotmail accounts also get the email? Link to comment https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77216 Share on other sites More sharing options...
kenrbnsn Posted August 19, 2006 Share Posted August 19, 2006 If you are using a shared host on a Linux (UNIX) box, you probably also need to use the fifth parameter to the mail() function. This parameter sets the "Return-path:" header. If the domain in that header doesn't match the domain of the address in the "From:" header hotmail.com will toss the email.The fifth parameter looks like:[code]<?php $p5 = '-f [email protected]'; ?>[/code] and is used like [code]<?php mail($to,$subject,$msg,$headers,$p5); ?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77225 Share on other sites More sharing options...
pluginbaby Posted August 19, 2006 Author Share Posted August 19, 2006 okay, I have added the 5th parameter:[code]<?php$to = '[email protected]';$subject = 'test';$message = 'hello';$headers = 'From: [email protected]';$p5 = '-f [email protected]';if (mail($to,$subject,$msg,$headers,$p5)) echo "email send";?>[/code]But when I runned it, I got this error:[quote]Warning: mail() [function.mail]: SAFE MODE Restriction in effect. The fifth parameter is disabled in SAFE MODE. in /srv/www/htdocs/web34/html/test.php on line 8[/quote]What can I do about that then? Link to comment https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77229 Share on other sites More sharing options...
tomfmason Posted August 19, 2006 Share Posted August 19, 2006 here is another example of a simple one. You may want to read up on the use of the headers in the mail. [code=php:0]mail($to, $subject, $message, "From: You<[email protected]>\nX-Mailer: PHP/" . phpversion());[/code]Give this a tryHope this helps,Tom Link to comment https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77231 Share on other sites More sharing options...
pluginbaby Posted August 19, 2006 Author Share Posted August 19, 2006 sorry to dissapoint you but I still haven't got anything in my hotmail inbox or trash can.I think there must be a way of doing it, cause if you register on a forum, you get an email too if you are using a hotmail account.Anyone has some more ideas? Link to comment https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77237 Share on other sites More sharing options...
tomfmason Posted August 19, 2006 Share Posted August 19, 2006 Not sure. I would contact my host if I were you. Do you know what mail server they are using? If not I would send them an email with your issue. This script that I posted is a functional [code=php:0]mail();[/code] format. Is is very basic but should work.Good luck,Tom Link to comment https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77241 Share on other sites More sharing options...
pluginbaby Posted August 19, 2006 Author Share Posted August 19, 2006 well, it does work. But not with a @hotmail adres.When I send it to my [email protected] it works. But when I send it at my [email protected] it doesn't work. What I want is that it works also on the @hotmail.com email address, cause the site where I want to use it for has a lot @hotmail.com email addresses, and if they can't recieve the email, there is no use of me creating this ;)I hope you understand my problem and there is a way of fixing it... Link to comment https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77242 Share on other sites More sharing options...
tomfmason Posted August 19, 2006 Share Posted August 19, 2006 You know I have the same issue. And have yet to fix it.I will do some testing and see what I can come up with.Good Luck,Tom Link to comment https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77244 Share on other sites More sharing options...
pluginbaby Posted August 19, 2006 Author Share Posted August 19, 2006 thank you, it would be wonderful if someone found a solution ;D Link to comment https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77245 Share on other sites More sharing options...
AndyB Posted August 19, 2006 Share Posted August 19, 2006 http://forums.whirlpool.net.au/forum-replies-archive.cfm/484996.html Link to comment https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77246 Share on other sites More sharing options...
tomfmason Posted August 19, 2006 Share Posted August 19, 2006 Ok I tried this and it worked[code=php:0]if ($ccaddress=="" || $ccaddress==" "){ $header="From: $knownsender"; }else{ $header .="From: $knownsender\r\n"; $header .=" Cc: $ccaddress";}// $header.="Bcc: $bcaddress";if (@mail($mailtos, $subject, $message, $header)){ echo "Your Email has been sent.";}else{ echo "There was an error sending your Email";}[/code]$knownsender is an email address that is known to the server. I never thought to use this but it works just fine.Give it a try. Link to comment https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77247 Share on other sites More sharing options...
pluginbaby Posted August 19, 2006 Author Share Posted August 19, 2006 Hmm, I must be doing something wrong then:[code]<?php$mailtos = "[email protected]";$subject = "test";$message = "this is a testingmessage";$knownsender = "[email protected]";if ($ccaddress=="" || $ccaddress==" "){ $header="From: $knownsender";}else{ $header .="From: $knownsender\r\n"; $header .=" Cc: $ccaddress";}// $header.="Bcc: $bcaddress";if (@mail($mailtos, $subject, $message, $header)){ echo "Your Email has been sent.";}else{ echo "There was an error sending your Email";}?>[/code]This is the exact code I executed, but I didn't got any emails at my hotmail account, I was wondering, is the "$knownsender" correct? Link to comment https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77252 Share on other sites More sharing options...
tomfmason Posted August 19, 2006 Share Posted August 19, 2006 Use an email address that is known to the server. Like [email protected] Link to comment https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77254 Share on other sites More sharing options...
kenrbnsn Posted August 19, 2006 Share Posted August 19, 2006 Make sure the domain portion of the "From:" address and the address in the fifth parameter is the same as the domain that is sending the email message.Ken Link to comment https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77272 Share on other sites More sharing options...
pluginbaby Posted August 19, 2006 Author Share Posted August 19, 2006 I did it without the 5th parameter. It works without it to.I set up an email address at my domain called: automailer@....I also changed the subject of my email, maybe MSN sees "test" as a spam subject.Anyway, now it finally arrived. I tested a couple of times and it keeps working.Thank you all of you for helping me out on this one ;D Link to comment https://forums.phpfreaks.com/topic/18028-what-is-the-problem/#findComment-77281 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.