Sending email with PHP

Associate
Joined
6 Mar 2009
Posts
495
Ok guys i am trying to send an email with PHP but does seem to be working.

Here is the Code -
Code:
$to = "[email protected]";
$subject = "TEST";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";

Basically i have an if Statement and when it equals the statement i want it to send an email. I am getting the echo statement saying "Mail Sent", but email not sending.

Have read somewhere that you may have to edit the SMTP setting in the php.ini file.

Amy suggestions??

Cheers
 
i have noticed that hotmail are bit of *insert swear words*.. when i try sending a test to hotmail, it doesnt go there. if you google, other people also seem to have problems with sending emails to hotmail accounts.

I also looked at the email error logs and found that hotmail had either blacklisted my domain or the ISP..
 
As mentioned, it's probably the mail software on the server that is either not sending or is getting blocked. Do you know what server you are expecting the mail to go out via? If the server with your PHP on is delivering mail directly, then it needs to be set up correctly, with a proper hostname with reverse DNS.

You could use PHPMailer instead, and that allows you to bypass whatever settings you have on the server and specify SMTP settings directly in the PHP. And it has some other nice features.
 
Back
Top Bottom