File: /var/www/selfanalyse/wp-content/plugins/psychometrics/api/psy_mail_sms_functions.php
<?php
function smtpMail($fromname,$replyto,$title, $subject, $content, $email_id) {
// include("../../../wp-config.php");
global $wpdb;
$PSY_CONFIG = 'wp_psy_config';
$mailCreds = $wpdb->get_row("SELECT username,password,port_no,region_host FROM $PSY_CONFIG where type='Mail' and status='1'");
$mail = new PHPMailer();
$mail->IsSMTP(true); // SMTP
$mail->SMTPAuth = true; // SMTP authentication
$mail->SMTPSecure = 'tls';
$mail->Mailer = "smtp";
$mail->SMTPDebug = false;
$mail->CharSet = "utf-8";
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
// $mail->Host = "email-smtp.us-east-1.amazonaws.com"; // Amazon SES server, note "tls://" protocol
$mail->Host = $mailCreds->region_host; // Amazon SES server, note "tls://" protocol
$mail->Port = $mailCreds->port_no; // set the SMTP port
$mail->Username = $mailCreds->username; // SES SMTP username
$mail->Password = $mailCreds->password;
$mail->SetFrom($fromname, $title);
$mail->AddReplyTo($replyto, $title);
$mail->Subject = $subject;
$mail->MsgHTML($content);
$mail->AddAddress($email_id, $email_id);
if ($mail->Send()) {
return 1;
} else {
return 0;
}
}
//send sms on registration
function sendWelecomeSMS($mobile,$name){
/**get sender id */
$sender_id = senderID('PSY');
/****end */
include_once '/var/www/selfanalyse/wp-content/plugins/psychometrics/api/sendsmsapi.php';
$mnt_message = "Thank you for registering with Self Analyze for Psychometric Test. Kindly proceed to Buy/ Payment section to take the test.";
$encodedMessage = urlencode($mnt_message);
$obj = new Sendsms();
$var = $obj->sendMessage($sender_id, $mobile, $encodedMessage);
}
//send sms on school registration
function sendCredentials($e_mob,$password){
/**get sender id */
$sender_id = senderID('PSY');
/****end */
include_once '/var/www/selfanalyse/wp-content/plugins/psychometrics/api/sendsmsapi.php';
$mnt_message = "Thank you for registering with Self Analyse for Psychometric Test.\nYour username and password for login on selfanalyse is :\nUsername : ".$e_mob."\nPassword : ".$password;
$encodedMessage = urlencode($mnt_message);
$obj = new Sendsms();
$var = $obj->sendMessage($sender_id, $e_mob, $encodedMessage);
}
//send welcome email on registration
function sendWelecomeEmail($email,$name){
include_once '/var/www/selfanalyse/wp-content/plugins/psychometrics/api/PHPMailer-master/PHPMailerAutoload.php';
$subject = 'Thankyou for Regsitration';
$content = '<p>Dear '.$name.'</p>';
$content .= '<p>Thank you for registering with Self Analyze. Kindly continue to make payment to take the test. You will receive a confirmation mail on successful transaction with instructions to proceed further. We look forward to help with your career plans.</p>';
$content .= '<p><strong>Note:Validity for exam access is 15 days from the date of purchase. Ensure to take the test within the next 15 days only.</strong></p>';
$content .= '<p>Warm wishes</p>';
$content .= '<p>Team Self Analyze.</p>';
$fromemail = "info@selfanalyse.com";
$replyto = "info@selfanalyse.com";
$useremail = $email;
smtpMail($fromemail,$replyto,'Team SelfAnalyse',$subject,$content,$useremail);
}
//send welcome email on registration from google
function sendWelecomeEmailGoogle($email,$name,$password){
include_once '/var/www/selfanalyse/wp-content/plugins/psychometrics/api/PHPMailer-master/PHPMailerAutoload.php';
$subject = 'Thankyou for Regsitration';
$content = '<p>Dear '.$name.'</p>';
$content .= '<p>Thank you for registering with Self Analyze. Kindly continue to make payment to take the test. You will receive a confirmation mail on successful transaction with instructions to proceed further. We look forward to help with your career plans.</p>';
$content .= '<p><strong>Note:Validity for exam access is 15 days from the date of purchase. Ensure to take the test within the next 15 days only.</strong></p>';
$content .= '<p>Your user name and password for login on selfanalyse is :-</p>';
$content .= '<p><b>User Name : '.$email.'</b></p>';
$content .= '<p><b>Password : '.$password.'</b></p>';
$content .= '<p>Warm wishes</p>';
$content .= '<p>Team Self Analyze.</p>';
$fromemail = "info@selfanalyse.com";
$replyto = "info@selfanalyse.com";
$useremail = $email;
smtpMail($fromemail,$replyto,'Team SelfAnalyse',$subject,$content,$useremail);
}
//send email on registration from school student
function sendRegEmail($username,$email,$name,$password){
include_once '/var/www/selfanalyse/wp-content/plugins/psychometrics/api/PHPMailer-master/PHPMailerAutoload.php';
$subject = 'Thankyou for Regsitration';
$content = '<p>Dear '.$name.'</p>';
$content .= '<p>You have successfully registered on selfanalyse.com using your username and password you can take the psychometric test plan.</p>';
$content .= '<p>Your user name and password for login on selfanalyse is :-</p>';
$content .= '<p><b>User Name : '.$username.'</b></p>';
$content .= '<p><b>Password : '.$password.'</b></p>';
$content .= '<p>Warm wishes</p>';
$content .= '<p>Team Self Analyse.</p>';
$fromemail = "info@selfanalyse.com";
$replyto = "info@selfanalyse.com";
$useremail = $email;
smtpMail($fromemail,$replyto,'Team SelfAnalyse',$subject,$content,$useremail);
}
//send suucessful purchase sms on plan purchase
function sendTestPurchaseSMS($mobile,$name){
/**get sender id */
$sender_id = senderID('PSY');
/****end */
include_once '/var/www/selfanalyse/wp-content/plugins/psychometrics/api/sendsmsapi.php';
$mnt_message = "Thank you for purchasing online psychometric test. Please refer to the mail sent on registered id for more information.";
$encodedMessage = urlencode($mnt_message);
$obj = new Sendsms();
$var = $obj->sendMessage($sender_id, $mobile, $encodedMessage);
}
//send suucessful purchase email on plan purchase
function sendTestPurchaseEmail($email,$name){
include_once '/var/www/selfanalyse/wp-content/plugins/psychometrics/api/PHPMailer-master/PHPMailerAutoload.php';
$subject = 'Thankyou for Purchasing';
$content = '<p>Dear '.$name.'</p>';
$content .= '<p>A warm welcome Self Analyze’ Psychometric Testing section. You are advised to read and follow all the instructions carefully being given to you before and during the test.</p>';
$content .= '<p>You will require to take the test in one sitting, it takes almost an hour to complete it. </p>';
$content .= '<p>Look for a quiet and comfortable place to take the test, these are series of short but timed tests.</p>';
$content .= '<p>You must attempt in a peaceful environment without any disturbances.</p>';
$content .= '<p>Our tech team is always there to help you in case you encounter any problem while taking the test, click on help button and you will get support.</p>';
$content .= '<p><strong>Note:Validity for exam access is 15 days from the date of purchase. Ensure to take the test within the next 15 days only.</strong></p>';
$content .= '<p>We look forward to help with your career plans</p>';
$content .= '<p>Warm wishes</p>';
$content .= '<p>Team Self Analyze.</p>';
$fromemail = "info@selfanalyse.com";
$replyto = "info@selfanalyse.com";
$useremail = $email;
smtpMail($fromemail,$replyto,'Team SelfAnalyse',$subject,$content,$useremail);
}
//send sms to user on booking session
function sendBookingCounsSMS($mobile,$name)
{
/**get sender id */
$sender_id = senderID('PSY');
/****end */
include_once '/var/www/selfanalyse/wp-content/plugins/psychometrics/api/sendsmsapi.php';
$mnt_message = "Dear ".$name.", we have forwarded your request to book a session with our counsellor, it will be confirmed through a mail shortly.";
$encodedMessage = urlencode($mnt_message);
$obj = new Sendsms();
$var = $obj->sendMessage($sender_id, $mobile, $encodedMessage);
}
//send sms to counselor for user counselling
function sendCounselorSMS($name,$slot_id)
{
// include("../../../wp-config.php");
global $wpdb;
$PSY_COUNSELORS = $wpdb->prefix . PSY_COUNSELORS;
$PSY_SLOT_AVAILABLE = $wpdb->prefix . PSY_SLOT_AVAILABLE;
$bookingDetails = $wpdb->get_row("SELECT c.counselor_mobile,sl.scheduled_date,sl.time_slot_hr,sl.time_slot_min FROM $PSY_SLOT_AVAILABLE as sl INNER JOIN $PSY_COUNSELORS as c on c.counselor_id=sl.counselor_id WHERE sl.id='$slot_id'");
$counselor = $bookingDetails->counselor_name;
$schedule = date('d M, Y', strtotime($bookingDetails->scheduled_date));
$timeFrom = $bookingDetails->time_slot_hr . ':' . $bookingDetails->time_slot_min;
/**get sender id */
$sender_id = senderID('PSY');
/****end */
$mobile = $bookingDetails->counselor_mobile;
$schedule = date('d M, Y', strtotime($bookingDetails->scheduled_date));
$timeFrom = $bookingDetails->time_slot_hr . ':' . $bookingDetails->time_slot_min;
$time = $schedule.'/'.$timeFrom;
include_once '/var/www/selfanalyse/wp-content/plugins/psychometrics/api/sendsmsapi.php';
//$mnt_message = "Dear " . $name . ", we have forwarded your request to book a session with our counsellor, it will be confirmed through a mail shortly.";
$mnt_message = "Dear Counselor, New slot has booked for counselling. \nStudent name is : $name, Session Time is : $time.";
$encodedMessage = urlencode($mnt_message);
$obj = new Sendsms();
$var = $obj->sendMessage($sender_id, $mobile, $encodedMessage);
}
//send email to user on booking session
function sendBookingCounsEmail($slot_id,$user_id){
// include("../../../wp-config.php");
global $wpdb;
$PSY_COUNSELORS = $wpdb->prefix . PSY_COUNSELORS;
$PSY_SLOT_AVAILABLE = $wpdb->prefix . PSY_SLOT_AVAILABLE;
$PSY_USERS_DETAILS = $wpdb->prefix . PSY_USERS_DETAILS;
$bookingDetails = $wpdb->get_row("SELECT c.skype_id,c.counselor_name,sl.scheduled_date,sl.time_slot_hr,sl.time_slot_min FROM $PSY_SLOT_AVAILABLE as sl INNER JOIN $PSY_COUNSELORS as c on c.counselor_id=sl.counselor_id WHERE sl.id='$slot_id'");
$counselor = $bookingDetails->counselor_name;
$schedule = date('d M, Y',strtotime($bookingDetails->scheduled_date));
$timeFrom = $bookingDetails->time_slot_hr.':'.$bookingDetails->time_slot_min;
$skype_id = $bookingDetails->skype_id;
$userDetails = $wpdb->get_row("SELECT first_name,last_name,email_address FROM $PSY_USERS_DETAILS WHERE user_id='$user_id'");
$user_name = $userDetails->first_name.' '.$userDetails->last_name;
$email = $userDetails->email_address;
include_once '/var/www/selfanalyse/wp-content/plugins/psychometrics/api/PHPMailer-master/PHPMailerAutoload.php';
$subject = 'Thankyou for Booking Session';
$content = '<p>Dear '.$user_name.'</p>';
$content .= '<p>A warm welcome Self Analyze’ Counselling Platform. Thank you for booking a session with our Counselor <b>'.$counselor.'</b>.</p>';
$content .= '<p>Your session is confirmed for Date ';
$content .= '<b>'.$schedule.'</b> and Time <b>'.$timeFrom.'</b></p>';
$content .= '<p>It will be a 20- 30 minute online session conducted through Skype. You are advised to download the skype and add Counsellor’s skype id <b>'.$skype_id.'</b> as your contact.</p>';
$content .= '<p>Look for a quiet and comfortable place to take the session. You must be in a peaceful environment without any disturbances during the session.</p>';
$content .= '<p>We look forward to help with your career plans</p>';
$content .= '<p>Warm wishes</p>';
$content .= '<p>Team Self Analyze.</p>';
$fromemail = "info@selfanalyse.com";
$replyto = "info@selfanalyse.com";
$useremail = $email;
smtpMail($fromemail,$replyto,'Team SelfAnalyse',$subject,$content,$useremail);
}
//send email to user on booking session
function sendBookingEmailToCounselor($slot_id,$user_id){
// include("../../../wp-config.php");
global $wpdb;
$PSY_COUNSELORS = $wpdb->prefix . PSY_COUNSELORS;
$PSY_SLOT_AVAILABLE = $wpdb->prefix . PSY_SLOT_AVAILABLE;
$PSY_USERS_DETAILS = $wpdb->prefix . PSY_USERS_DETAILS;
$bookingDetails = $wpdb->get_row("SELECT c.skype_id,c.counselor_name,c.counselor_email,sl.scheduled_date,sl.time_slot_hr,sl.time_slot_min FROM $PSY_SLOT_AVAILABLE as sl INNER JOIN $PSY_COUNSELORS as c on c.counselor_id=sl.counselor_id WHERE sl.id='$slot_id'");
$counselor = $bookingDetails->counselor_name;
$schedule = date('d M, Y',strtotime($bookingDetails->scheduled_date));
$timeFrom = $bookingDetails->time_slot_hr.':'.$bookingDetails->time_slot_min;
$skype_id = $bookingDetails->skype_id;
$userDetails = $wpdb->get_row("SELECT first_name,last_name,email_address FROM $PSY_USERS_DETAILS WHERE user_id='$user_id'");
$user_name = $userDetails->first_name.' '.$userDetails->last_name;
//will be define shortly
$email = $bookingDetails->counselor_email;
include_once '/var/www/selfanalyse/wp-content/plugins/psychometrics/api/PHPMailer-master/PHPMailerAutoload.php';
$subject = 'Thankyou for Booking Session';
$content = '<p>Dear '.$user_name.'</p>';
$content .= '<p>A warm welcome Self Analyze’ Counselling Platform. Thank you for booking a session with our Counselor</p>';
$content .= '<p><b>'.$counselor.'</b>Your session is confirmed for Date</p>';
$content .= '<p><b>'.$schedule.'</b> and Time <b>'.$timeFrom.'</b></p>';
$content .= '<p>It will be a 20- 30 minute online session conducted through Skype. You are advised to download the skype and add Counsellor’s skype id <b>'.$skype_id.'</b> as your contact.</p>';
$content .= '<p>Look for a quiet and comfortable place to take the session. You must be in a peaceful environment without any disturbances during the session.</p>';
$content .= '<p>We look forward to help with your career plans</p>';
$content .= '<p>Warm wishes</p>';
$content .= '<p>Team Self Analyze.</p>';
$fromemail = "info@selfanalyse.com";
$replyto = "info@selfanalyse.com";
$useremail = $email;
smtpMail($fromemail,$replyto,'Team SelfAnalyse',$subject,$content,$useremail);
}
//send otp on forgot password click button to email
function sendOTPForgotEmail($email,$otp){
include_once '/var/www/selfanalyse/wp-content/plugins/psychometrics/api/PHPMailer-master/PHPMailerAutoload.php';
$subject = 'Selfanalyse - OTP confirmation';
$content = '<p>Your OTP for change password request is - '.$otp.'</p>';
$fromemail = "info@selfanalyse.com";
$replyto = "info@selfanalyse.com";
$useremail = $email;
smtpMail($fromemail,$replyto,'Team SelfAnalyse',$subject,$content,$useremail);
}
# send plan purchase sms to mam
function sendTestPurchaseSMSTocounselor($mobile, $plan, $amount, $name)
{
/**get sender id */
$sender_id = senderID('PSY');
/****end */
include_once '/var/www/selfanalyse/wp-content/plugins/psychometrics/api/sendsmsapi.php';
$mnt_message = "Dear Team,\n".$name." has made Online Payment of ".$amount." for ".$plan." Test on Self Analyse.";
$encodedMessage = urlencode($mnt_message);
$obj = new Sendsms();
$var = $obj->sendMessage($sender_id, $mobile, $encodedMessage);
}
# send msg on test completion
function sendTestakenSms($mobile, $name, $exam){
/**get sender id */
$sender_id = senderID('PSY');
/****end */
include_once '/var/www/selfanalyse/wp-content/plugins/psychometrics/api/sendsmsapi.php';
$mnt_message = "Dear Team,\n".$name." has attempted ".$exam." Test on Self Analyse.";
$encodedMessage = urlencode($mnt_message);
$obj = new Sendsms();
$var = $obj->sendMessage($sender_id, $mobile, $encodedMessage);
}