I want to send mail from local server but mail will not send locally. The error is:
SMTP Error: Could not authenticate.
<?php
include_once'mail/class.phpmailer.php';
include_once'mail/class.pop3.php';
include_once'mail/class.smtp.php';
class MailSender{
public static function SendMail($to,$subj,$body,$username){
$mail=new PHPMailer();
$mail->IsSMTP();
//$mail->Host="mail.gmail.com";
$mail->SMTPAuth=true;
$mail->SMTPSecure = 'ssl';
$mail->Host="smtp.gmail.com";
$mail->Port=587;
$mail->Username="rahullodhi3636@gmail.com";
$mail->Password="fdslkfsd";
$mail->SetFrom('rahullodhi3636@gmail.com','Rahul lodhi');
$mail->Subject=$subj;
$mail->MsgHTML($body);
$mail->AltBody="to view the msg";
$address=$to;
$mail->AddAddress($address,$username);
if(!$mail->Send()){
return"Mailer Error :".$mail->ErrorInfo;
}else{
return"message sent";
}
}
}
?>