Decided to try to use pear to send my emails and have come up with this code. Installed pear and pear mail.
<?php include "C:/php/pear/Mail.php"; require_once "Mail.php"; $from = "user1@gmail.com>"; $to = "user2@yahoo.com>"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; $host = "ssl://smtp.gmail.com"; $port = "465"; $username = "user1@gmail.com"; $password = "pass"; $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>"); } ?>
and I am getting caught at this line in particular:
$mail = $smtp->send($to, $headers, $body);
Guess I'm wondering what could be causing this line not to run - I am at a bit of a loss here. Opened port 465 in my firewall/router, restarted apache. I've seen some very similar code online, so not sure what makes what I'm doing different. I am on a Windows XP box btw.