Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #2561

Re: sending email

From "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid>
Newsgroups comp.lang.php
Subject Re: sending email
Date 2011-07-15 08:32 +0200
Organization http://alvaro.es/
Message-ID <ivomuv$4mn$1@dont-email.me> (permalink)
References <fa536de2-d437-45c1-809e-a50cf60eaa12@glegroupsg2000goo.googlegroups.com>

Show all headers | View raw


El 15/07/2011 6:33, cerr escribió/wrote:
> I wrote following test script:
> <?php
>   $to = "myself@gmail.com";
>   $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?

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 
client).

- 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, 
$additional_headers:

	'From: John Doe <john@example.com'

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

	'-fjohn@example.com'

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.


-- 
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--

Back to comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

sending email cerr <ron.eggler@gmail.com> - 2011-07-14 21:33 -0700
  Re: sending email Geoff Muldoon <geoff.muldoon@trap.gmail.com> - 2011-07-15 15:06 +1000
  Re: sending email "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-07-15 08:32 +0200

csiph-web