sending email

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi There,

I wrote following test script:
 $to = "";
 $subject = "Test";
 $body = "This is a test!";
 if (mail($to, $subject, $body)) {
   echo("<p>Message successfully sent!<br><FORM><INPUT TYPE=\"button\"
VALUE=\"Back\" onClick=\"history.go(-1);return true;\"></FORM></p>");
  } else {
   echo("<p>Message delivery failed...</p>");
and i get Message successfully sent! but no email ever arrives in my inbox, why
not? What am i dong wrong?

Thank you!

Re: sending email says...
Quoted text here. Click to load it

Look in your server's sendmail/smtp logs,  most smtp servers these days
might spam-bot out your message after it has successfully passed through
the PHP stage without some additional well-formed headers like "from:"
(you have this set in your php.ini?)


Re: sending email

Quoted text here. Click to load it

Yep, the missing "from:" part was the problem, exactly!
Thank you!


Re: sending email

El 15/07/2011 6:33, cerr escribió/wrote:
Quoted text here. Click to load it

PHP (or any other programming language for what it matters) has no way
to know whether an e-mail message was successfully delivered or not.
When mail() returns TRUE it basically means that it was able to contact
the mail server and hand it the message. After that, there are many
additional steps.

In your case, you are omitting at least two important pieces of information:

- You don't set a "From:" header (the address displayed by the e-mail

- You don't set an envelop address (the address where failure
notifications will be sent).

The first one can be set with mail()'s fourth parameter,

    'From: John Doe <'

The second one can be set with the fifth parameter, $additional_parameters:


The envelope address is not optional so your server is probably filling
it with some bogus info. That (and the lack of "From") is likely to make
spam filters reject your message.

-- - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:
-- Mi web de humor satinado:

Site Timeline