Please help me, I'm new to PHP, and since the last 5 hours I have been trying to send mail and am now really tired. Thanks.
Here is my code. I am using a Gmail account.
include("class.phpmailer.php");
$mail = new PHPMailer();
$body = $mail->getFile('contents.html');
$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "hussaintalha@gmail.com";
$mail->Password = "xxxxxxxx";
$mail->AddReplyTo("hussaintalha@gmail.com","First Last");
$mail->From = "hussaintalha@gmail.com.com";
$mail->FromName = "First Last";
$mail->Subject = "PHPMailer Test Subject via gmail";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->WordWrap = 50;
$mail->MsgHTML($body);
$mail->AddAddress("hussaintalha@gmail.com", "John Doe");
$mail->AddAttachment("images/phpmailer.gif");
$mail->IsHTML(true);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
When I run my file, I get this error:
Warning: fopen (contents.html) [function.fopen]: could not open stream: there is no such file or directory in D: \ xampplite \ HTDOCS \ WebEng \ class.phpmailer.php on line 1870
Warning: fsockopen () [function.fsockopen]: cannot connect to ssl: //smtp.gmail.com: 465 (Can't find ssl socket transport - did you forget to enable it when you configured PHP?) In D: \ xampplite \ HTDOCS \ WebEng \ class.smtp.php on line 122 Mailer Error: SMTP Error: Failed to connect to the SMTP host.