<?php require_once('phpmailer/class.phpmailer.php'); require_once('phpmailer/class.smtp.php'); $mail = new PHPMailer(); //$mail->SMTPDebug = 3; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'just55.justhost.com'; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = 'themeforest@ismail-hossain.me'; // SMTP username $mail->Password = 'AsDf12**'; // SMTP password $mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 465; // TCP port to connect to $message = ""; $status = "false"; if( $_SERVER['REQUEST_METHOD'] == 'POST' ) { if( $_POST['form_name'] != '' AND $_POST['form_email'] != '' AND $_POST['form_sex'] != '' AND $_POST['form_branch'] != '' AND $_POST['form_message'] != '' ) { $name = $_POST['form_name']; $email = $_POST['form_email']; $sex = $_POST['form_sex']; $job_branch = $_POST['form_branch']; $message = $_POST['form_message']; $subject = isset($subject) ? $subject : 'New Message | Become a Volunteer'; $botcheck = $_POST['form_botcheck']; $toemail = 'spam.thememascot@gmail.com'; // Receiver Email Address $toname = 'ThemeMascot'; // Receiver Name if( $botcheck == '' ) { $mail->SetFrom( $email , $name ); $mail->AddReplyTo( $email , $name ); $mail->AddAddress( $toemail , $toname ); $mail->Subject = $subject; $name = isset($name) ? "Name: $name<br><br>" : ''; $email = isset($email) ? "Email: $email<br><br>" : ''; $sex = isset($sex) ? "Sex: $sex<br><br>" : ''; $job_branch = isset($job_branch) ? "Branch: $job_branch<br><br>" : ''; $message = isset($message) ? "Message: $message<br><br>" : ''; $referrer = $_SERVER['HTTP_REFERER'] ? '<br><br><br>This Form was submitted from: ' . $_SERVER['HTTP_REFERER'] : ''; $body = "$name $email $sex $job_branch $message $referrer"; //mail attachment if ( isset( $_FILES['form_attachment'] ) && $_FILES['form_attachment']['error'] == UPLOAD_ERR_OK ) { $mail->IsHTML(true); $mail->AddAttachment( $_FILES['form_attachment']['tmp_name'], $_FILES['form_attachment']['name'] ); } $mail->MsgHTML( $body ); $sendEmail = $mail->Send(); if( $sendEmail == true ): $message = 'We have <strong>successfully</strong> received your Message and will get Back to you as soon as possible.'; $status = "true"; else: $message = 'Email <strong>could not</strong> be sent due to some Unexpected Error. Please Try Again later.<br /><br /><strong>Reason:</strong><br />' . $mail->ErrorInfo . ''; $status = "false"; endif; } else { $message = 'Bot <strong>Detected</strong>.! Clean yourself Botster.!'; $status = "false"; } } else { $message = 'Please <strong>Fill up</strong> all the Fields and Try Again.'; $status = "false"; } } else { $message = 'An <strong>unexpected error</strong> occured. Please Try Again later.'; $status = "false"; } $status_array = array( 'message' => $message, 'status' => $status); echo json_encode($status_array); ?>