include 'phpmailer/class.phpmailer.php'; $this->mail = new PHPMailer(); $this->mail->IsSMTP(); $this->mail->SMTPAuth = true; $this->mail->Host = 'mail.yourdomain.com'; $this->mail->Port = 587; $this->mail->SMTPSecure = 'tls'; $this->mail->Username = 'user@yourdomain.com'; $this->mail->Password = 'password'; $this->mail->SetFrom("noreply@yourdomain.com", 'Name'); $this->mail->AddAddress($to,$name); $this->mail->CharSet = 'UTF-8'; $this->mail->Subject = $subject; $this->mail->MsgHTML($html_message); if($this->mail->Send()) { return json_encode(array('status'=>1,'message'=>'Success')); } else { return json_encode(array('status'=>0,'message'=>$this->mail->ErrorInfo)); }