I got little about error syntax error when I am using the PHPMailer library
. I want to define my
- email address
- name
- password
are constant. but when I am using the defined function. it gives me an error. I check out everything. my name email id and password are correct. when I simply define these variable everything are working well.
This is my code
<?php
require '../phpmailer/PHPMailerAutoload.php';
require '../phpmailer/class.phpmailer.php';
require '../phpmailer/class.smtp.php';
require '../phpmailer/class.phpmaileroauth.php';
class mail {
private define("FROM", "3mrwhy@gmail.com");
private define("NAME", "MR WHY");
private define("PASSWORD", "XXXXXXX");
function verfication($email, $name, $subject, $body) {
$mail = new PHPMailer(true);
// Smtp Setting
$mail->IsSMTP();
$mail->Host = 'smtp.gmail.com ';
$mail->Port = '465';
$mail->SMTPAuth = true;
$mail->Username = FROM;
$mail->Password = PASSWORD;
$mail->SMTPSecure = 'ssl';
$mail->From = FROM;
$mail->FromName = NAME;
// message setting
$mail->AddAddress($email, $name);
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AltBody = '';
$result = $mail->Send();
if($result['code'] == '400') {
echo "Message is not send";
}
if($result) {
echo "Email sent";
} else {
echo "something wrong". $mail->errorinfo;
}
}
}
$obj = new mail();
$obj->verfication("abheykumar7033@gmail.com", "Sudhir kumar", "Congrats", "You have created verification mail");
?>