Jump to content

Sending email


doddsey_65

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>");
}
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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);

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.