Re: No SMTP server? Can't get mail()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 21, 2011 at 10:45:46AM +0700, Paul S wrote:

> I am having problems with mail(). The problem is that the email just never
> gets there. Mail appears to be working. To start, I am investigating the
> SMTP server. I can't understand some things.
> 
> 1) I am sure that the smtp server is and is set to "localhost", but I want
> to verify this ...
> 
> -------------------------------------------------------------------------------------------
> error_reporting(E_ALL);
> echo 'display_errors = ' . ini_get('display_errors') . "\n";
> echo 'register_globals = ' . ini_get('register_globals') . "\n";
> echo "<br><br>";
> echo "SMTP host: " . ini_get("smtp");
> echo "SMTP port: " . ini_get("smtp_port");
> echo "Sendmail From: " . ini_get("sendmail_from");
> 
>    gets:
> 
> 1 1
> 
> SMTP host:
> SMTP port: 25
> Sendmail_from:
> Notice: Use of undefined constant sendmail_from - assumed 'sendmail_from'
> in /home/
> 
> Obviously SMTP is defined (?? because it is not undefined?), but nothing
> is echo'd for SMTP. WHY?

Think CASE-SENSITIVE. Check instead for SMTP, not smtp.

sendmail_from is not defined on my machine either, for what it's worth.

> -------------------------------------------------------------------------------------------
> -------------------------------------------------------------------------------------------
>     then ...
> 
> ini_set( smtp, "localhost" );
> 
>     gets:
> 
> Notice: Use of undefined constant smtp - assumed 'smtp' in /home/ ...
> SMTP host:
> SMTP port: 25
> Sendmail_from:
> -------------------------------------------------------------------------------------------
> Strange, SMTP was defined before ????, and it still won't echo.
> -------------------------------------------------------------------------------------------

Again, think case-sensitive. smtp is not a valid ini variable. SMTP is.

> -------------------------------------------------------------------------------------------
>       Both
> 
> error_reporting(E_ALL);
> ini_set( sendmail_from, "<sendmailfrom>@<localhost>" );
> echo "SMTP host: " . ini_get("smtp");
> echo "SMTP port: " . ini_get("smtp_port");
> echo "Sendmail From: " . ini_get("sendmail_from");
> $return = mail('<another user>@<localhost>', 'Test', 'Test');

The above is not a valid email address, as it contains a space. Not to
mention, I'm not real sure about the brackets. Just use a regular email
address without all the other stuff, as: jimbob@xxxxxxxxxxxx

> var_dump($return);
> 
>      and
> 
> error_reporting(E_ALL);
> ini_set( sendmail_from, "<sendmailfrom>@<localhost>" );
> ini_set( smtp, "localhost" );
> echo "SMTP host: " . ini_get("smtp");
> echo "SMTP port: " . ini_get("smtp_port");
> echo "Sendmail From: " . ini_get("sendmail_from");
> $return = mail('<another user>@<localhost>', 'Test', 'Test');
> var_dump($return);
> 
>      return
> 
> no other errors
> 
> SMTP host:
> SMTP port: 25
> Sendmail_from: <sendmailfrom>@<localhost>
> 
> and
> 
> bool(true)

Although the documentation isn't entirely clear, I suspect that the
return of true from the mail() function only means that the smtp server
accepted the email for delivery. The smtp server on localhost still has
to connect with the remote server and the remote server has to accept
the mail for delivery. I suspect the return of true only means that the
origin/localhost mailserver accepts the email. It can still fail beyond
there.

> 
> Yet NO EMAIL is ever received/returned at the local email address or when
> outside email addresses are used, and never when mail() is seemingly
> successfully used in a script.
> 
> WHY can't I echo the SMTP address being USED? What am I doing wrong?
> (Please note that phpinfo IS DISABLED ON MY SERVER BECAUSE IT IS A
> SECURITY THREAT)
> 
> How am I going to get this emailing straightened out?

I haven't seen a real email address used yet in your examples. Use a
real address, and not a "localhost" one. A localhost address is likely
not a valid one.

Paul

-- 
Paul M. Foster
http://noferblatz.com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux