doddsey_65 Posted November 19, 2009 Share Posted November 19, 2009 I have found a few scripts that show me how to do it but none of them work, i never get the email. I dont know if it matters that im trying to send the email to hotmail address but i have tried gmail aswell and it doesnt work. How would i go about this? The email is a welcome email for when they register so i dont need any forms. Cheers Quote Link to comment https://forums.phpfreaks.com/topic/182193-sending-email/ Share on other sites More sharing options...
premiso Posted November 19, 2009 Share Posted November 19, 2009 Are you running on localhost or a hosted webserver? If localhost you need a mail server to send email from. You can, however, use GMail as your mail server if the localhost is the case, search google for phpGMailer for a script that will allow you to send emails using GMails server. Aside from that, if it is on a hosted webserver with a mail server it is getting filtered as spam, most email clients such as Hotmail GMail and Yahoo filter emails that come from sites as spam and this is not avoidable, unfortunately. The only way to fix it is if your hosted webserver fixes their IP address that sends the mail and make it show up on their MX record, as I believe that is how most of those email clients check if a message is "valid". Not 100% sure on the MX record IP, but that is what I have found with my own server. Quote Link to comment https://forums.phpfreaks.com/topic/182193-sending-email/#findComment-961328 Share on other sites More sharing options...
doddsey_65 Posted November 19, 2009 Author Share Posted November 19, 2009 im using a hosted server. ive checked the spam box in hotmail and it isnt there either. or do you mean it wont even go there? Quote Link to comment https://forums.phpfreaks.com/topic/182193-sending-email/#findComment-961329 Share on other sites More sharing options...
mikesta707 Posted November 19, 2009 Share Posted November 19, 2009 Can you show us the code you used? Quote Link to comment https://forums.phpfreaks.com/topic/182193-sending-email/#findComment-961333 Share on other sites More sharing options...
doddsey_65 Posted November 19, 2009 Author Share Posted November 19, 2009 Can you show us the code you used? Here it is: <?php $to = "myemail@hotmail.com"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; if (mail($to, $subject, $body)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/182193-sending-email/#findComment-961334 Share on other sites More sharing options...
premiso Posted November 19, 2009 Share Posted November 19, 2009 im using a hosted server. ive checked the spam box in hotmail and it isnt there either. or do you mean it wont even go there? It would not even go there for Hotmail and Yahoo, GMail tends to be more lienent so it should at least show up there. Posting the code will help us to see if maybe you have your mail function setup wrong, as it could be as simple as that Seeing your code, you may want to try adding some Mail Headers to your mail and see if that helps. Here are some common mail headers that may help (note not the CC/BCC but the Reply-To/From.) I would also look over the mail function at php.net as it does have some other items you can add such as under "Additional Parameters" etc. Finally, contact your webhost, see what headers they suggest sending with your mail, as that can help as well. Quote Link to comment https://forums.phpfreaks.com/topic/182193-sending-email/#findComment-961341 Share on other sites More sharing options...
doddsey_65 Posted November 19, 2009 Author Share Posted November 19, 2009 okay all i want to do atm is see if the email gets hthrough, so additional stuff can be held back for the min, what do i need my host to do so the email does go through? Quote Link to comment https://forums.phpfreaks.com/topic/182193-sending-email/#findComment-961345 Share on other sites More sharing options...
premiso Posted November 19, 2009 Share Posted November 19, 2009 what do i need my host to do so the email does go through? Just ask them the recommended code to send email using PHP. Some hosts have a certain way for you to send emails and they can also tell you of issues with certain providers. I would contact them anyways and ask them for the proper method to send email using PHP using their host. Quote Link to comment https://forums.phpfreaks.com/topic/182193-sending-email/#findComment-961349 Share on other sites More sharing options...
PFMaBiSmAd Posted November 19, 2009 Share Posted November 19, 2009 so additional stuff can be held back for the min Not necessarily. For example, the lack of a specific From: address might be causing the mail server at your host to simply discard the email and not even attempt to send it. Which of the two messages 'Message successfully sent!'/'Message delivery failed...' is being output by the posted code? FYI: A TRUE status from the mail() function just means that there was a sending mail server and it accepted the email to be sent. It does not mean that it was actually sent. What does adding the following two lines of code immediately after the first opening <?php tag show - ini_set("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/182193-sending-email/#findComment-961362 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.