hi, i'm trying to have a mail function using gmail server but i keep getting the error :
SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.
this is the code i got
<?php
include("class.phpmailer.php");
include("class.smtp.php");
if(isset($_POST['send'])){
$body=$_POST[email];
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // use ssl
$mail->Host = "ssl://smtp.gmail.com"; // GMAIL's SMTP server
$mail->Port = 465; // SMTP port used by GMAIL server
$mail->Username = "myaccount@gmail.com"; // GMAIL username
$mail->Password = "mypassword"; // GMAIL password
$mail->AddReplyTo("account@domain.com","FirstName LastName"); // Reply email address
$mail->From = "myaccount@gmail.com";
$mail->FromName = "myname"; // Name to appear once the email is sent
$mail->Subject = "testing 123"; // Email's subject
//$mail->Body = "Hello World,<br />This is the HTML BODY<br />"; //HTML Body
$mail->AltBody = "This is a test email"; // optional, comment out and test
$mail->WordWrap = 50; // set word wrap
$mail->MsgHTML($body); // [optional] Send body email as HTML
$mail->AddAddress("account@domain.com"); // email address of recipient
//$mail->AddAttachment("files/files.zip"); // [optional] attachment
$mail->IsHTML(true); // [optional] send as HTML
if(!$mail->Send())
echo "Mailer Error: " . $mail->ErrorInfo;
else
echo "Message sent!";
}
?>