mail() function in PHP

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
Randolph
Forum Newbie
Posts: 8
Joined: Mon May 22, 2006 7:26 am

mail() function in PHP

Post by Randolph »

Hey guys,

3rd post. w00t! :twisted: :twisted:

I'm having trouble with the mail() function in PHP. We are running PHP on MS IIS 6.0, and the SMTP mail server runs on a different server than the web server. I entered the IP address of the SMTP server into the php.ini, but I am still not getting any success with the mail function. It appears to work, but I never receive any mail.

1) Is there a error syntax I can use to debug this? E.g., if it doesn't send mail, say why such as "Server not found"

2) Has anyone worked in a multi-server environment and had this problem?

Your input is always greatly appreciated.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: mail() function in PHP

Post by Chris Corbyn »

Randolph wrote:Hey guys,

3rd post. w00t! :twisted: :twisted:

I'm having trouble with the mail() function in PHP. We are running PHP on MS IIS 6.0, and the SMTP mail server runs on a different server than the web server. I entered the IP address of the SMTP server into the php.ini, but I am still not getting any success with the mail function. It appears to work, but I never receive any mail.

1) Is there a error syntax I can use to debug this? E.g., if it doesn't send mail, say why such as "Server not found"

2) Has anyone worked in a multi-server environment and had this problem?

Your input is always greatly appreciated.
Turn error reporting on full:

Code: Select all

error_reporting(E_ALL);
If there's no errors, check your SMTP logs to see that the mail actually sent to the server.

If it's getting that far it's likely being blocked as spam wrongly. That's because the headers often look funny. You could try something like phpMailer or Swift (see signature) if you want better debugging and handling without mail().
Post Reply