php mail() does not work?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Sindarin
Forum Regular
Posts: 521
Joined: Tue Sep 25, 2007 8:36 am
Location: Greece

php mail() does not work?

Post by Sindarin »

I tried this simple mail script on 2 servers but it says the delivery failed. Both servers use PHP5.

Code: Select all

<?php
$to = "mymail@mydomain.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>");
 }
?>
User avatar
Jaxolotl
Forum Contributor
Posts: 137
Joined: Mon Nov 13, 2006 4:19 am
Location: Argentina and Italy

Re: php mail() does not work?

Post by Jaxolotl »

did you check the smtp configuration on your php.ini?
User avatar
Sindarin
Forum Regular
Posts: 521
Joined: Tue Sep 25, 2007 8:36 am
Location: Greece

Re: php mail() does not work?

Post by Sindarin »

sendmail_from and sendmail_path has no value in the Windows server.

sendmail_from has the value of php@mail14.awardspace.com and sendmail_path is /usr/sbin/sendmail -oi -t in the Linux one.

The smtp port is 25 and both use localhost as SMTP value.
User avatar
Sindarin
Forum Regular
Posts: 521
Joined: Tue Sep 25, 2007 8:36 am
Location: Greece

Re: php mail() does not work?

Post by Sindarin »

I found the solution with my own host. Problem was the host required authentication, that is a valid "from" header to the script and an inbox created with that email.

Problems on the Windows server still occur though, the server throws the error:
Warning: mail() [function.mail]: SMTP server response: 421 4.1.0 Dropping connection due to an error on this server in D:\Sites\send.php on line 8
User avatar
Jaxolotl
Forum Contributor
Posts: 137
Joined: Mon Nov 13, 2006 4:19 am
Location: Argentina and Italy

Re: php mail() does not work?

Post by Jaxolotl »

:drunk: , good!!! scuse me but I was smashed down with a lot of work the last week and I didn't even open the forum.

Namarië
Post Reply