I have used Mandrill for SMTP and the below code is well worked for me in localhost. But the same code did not work, when I hosted my website in remote.
It displays an error
Smtp->error password not accepted from server 535. Incorrect authenticate data.
This is my code. Please do help me.
public function actionCreate()
{
$model=new Contacts;
if(isset($_POST['Contacts']))
{
$model->attributes=$_POST['Contacts'];
Yii::import('application.extensions.phpmailer.JPhpMailer');
$mail = new JPhpMailer;
$mail->IsSMTP();
$mail->Host = 'smtp.mandrillapp.com';
$mail->Port ='587';
$mail->SMTPAuth = true;
$mail->SMTPSecure="tls";
$mail->Username = 'xxx@gmail.com';
$mail->SMTPDebug = 1;
$mail->SMTPKeepAlive =true;
$mail->Password = 'tshb-mA19EdIvdQf2mO8KA';
$mail->SetFrom($_POST['Contacts']['email'], $_POST['Contacts']['email']);
$mail->Subject = 'New Mail Receiverd';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
$mail->MsgHTML("DASDSAD");
$msgBody="<div><ul>";
foreach($model->attributes as $key=>$value)
{
$msgBody.="<li>".$key." - ".$value."</li>";
}
$msgBody.="</ul></div>";
$mail->MsgHTML($msgBody);
$mail->AddAddress('xxx@gmail.com', 'xxx');
$ret=$mail->Send();
if($model->save())
print "<script type=\"text/javascript\">";
print "alert('Thank you for contacting us.')";
print "</script>";
}
$this->render('create',array(
'model'=>$model,
));
}