I am using the following code <?php require_once "Mail.php"; $from = "Web Master <webmaster@example.com>"; $to = "Nobody <nobody@example.com>"; $subject = "Test email using PHP SMTP with SSL\r\n\r\n"; $body = "This is a test email message"; $host = "ssl://secure.emailsrvr.com"; $port = "465"; $username = "webmaster@example.com"; $password = "yourPassword"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'port' => $port, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } ?> PHP: All my messages are getting caught in spam in hotmail but gmail and yahoo is fine. Any help anyone can give??
The problem is likely NOT with your code -- sad to say. 99% of the time hotmail rejects when nobody else does, it's because the server is missing a properly signed SPF record. Really hotmail seems to be the only service that gives a damn about it, everyone else treats it as optional or allows an unsigned/incomplete one to work.
Is there a website where I can check that one? Also not sure if this makes a difference but I am on a shared server.
Anything that does a 'reverse dns' based off the IP address should let you know how the PTR record is going. Question: If you use regular plain old mail() instead of trying to SMTP with PEAR/Mail does it work then? If this works: <?php $to = 'Nobody <nobody@example.com>'; $subject = 'Test email using PHP MAIL'; $body = 'This is a test email/ message'; $headers=implode("\r\n",array( 'From:Web Master <webmaster@example.com>', 'Reply-To:Web Master <webmaster@example.com>', 'X-Mailer: PHP/'.phpversion() )); echo ' <p>',( mail($to,$subject,$body,$headers) ? 'Message successfully sent!' : 'Failed to send mail' ),'</p>'; ?> Code (markup): Then the problem is specific to the SMTP server you are trying to manually connect to... you might try setting it up to use sendmail instead of network logging into SMTP... If the above works, this should work: <?php require_once('Mail.php'); $headers = array ( 'From' => 'Web Master <webmaster@example.com>', 'Reply-To' => 'Web Master <webmaster@example.com>', 'To' => 'Nobody <nobody@example.com>', 'Subject' => 'Test email using PEAR/Mail with Sendmail' ); $body = 'This is a test email message'; $mail = Mail::factory('sendmail'); $send = $mail->send($to, $headers, $body); echo ' <p>',( PEAR::isError($mail) ? $mail->getMessage() : 'Message successfully sent!' ),'</p>'; ?> Code (markup): Unless for some reason your host isn't providing sendmail, in which case find a better host.