489495df
Path : /home3/mandnweb/mariananjie.co.uk/ |
Current < : /home3/mandnweb/mariananjie.co.uk/sendmail.php |
<?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; require 'PHPMailer/src/Exception.php'; require 'PHPMailer/src/PHPMailer.php'; require 'PHPMailer/src/SMTP.php'; $form_type = $_POST['form_type']; $from = 'Mariana Njie '; if($form_type == 1){ $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $message = $_POST['message']; $services = $_POST['services']; $subject = "Contact Form - Mariana Njie"; $body_content = 'Name: '. $name . '<br>' . 'Email Address: '. $email . '<br>Phone: ' . $phone . '<br> Services: ' . $services . '<br>Message: ' . $message ; }elseif($form_type == 2){ $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $business_name = $_POST['business_name']; $business_type = $_POST['business_type']; $business_address = $_POST['business_address']; $reason = $_POST['reason']; $subject = "Become a Member - Mariana Njie"; $body_content = 'Name: '. $name . '<br>' . 'Email Address: '. $email . '<br>Phone: ' . $phone . '<br>Business Name: ' . $business_name . '<br>Business Type: ' . $business_type . '<br>Full Business Address: <br>' . $business_address . '<br>Reason for wanting to become a member: <br>' . $reason; }elseif($form_type == 3){ $name = 'Subscriber'; $email = $_POST['email']; $subject = "Newsletter Subscribed"; $body_content = 'Email Address: '. $email . '<br> Please add this email as your subscriber.<br>'; }elseif($form_type == 4){ $name = $_POST['name']; $jobpost_title = $_POST['jobpost_title']; $jobpost_id = $_POST['jobpost_id']; $email = $_POST['email']; $phone = $_POST['phone']; $birthday = $_POST['birthday']; $message = $_POST['message']; $file_tmp = $_FILES['uploadcv']['tmp_name']; $file_name = $_FILES['uploadcv']['name']; $subject = "Mariana Njie Job Application - " . $name; $body_content = 'Name: '. $name . '<br>' . 'Email Address: '. $email . '<br>Phone: ' . $phone . '<br>Job Post Title: '. $jobpost_title . '<br>' . '<br>Job post ID: '. $jobpost_id . '<br>' . '<br>Birthday: '. $birthday . '<br>Message: <br>' . $message; }elseif($form_type == 5){ $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $message = $_POST['message']; $subject = "Post a Job - Mariana Njie"; $body_content = 'Name: '. $name . '<br>' . 'Email Address: '. $email . '<br>Phone: ' . $phone . '<br>Message: ' . $message ; }elseif($form_type == 6){ $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $message = $_POST['message']; $birthday = $_POST['birthday']; $location = $_POST['location']; $interested_in = $_POST['interested_in']; $file_tmp = $_FILES['uploadcv']['tmp_name']; $file_name = $_FILES['uploadcv']['name']; $subject = "Qualified Candidates - Mariana Njie"; $body_content = 'Name: '. $name . '<br>' . 'Email Address: '. $email . '<br>Phone: ' . $phone . '<br>Birthday'. $birthday. '<br>Location '. $location . '<br>Im interested in'. $interested_in . '<br>Message: ' . $message ; }else{ $data = array( "success" => false); echo json_encode($data); die(); } //Limit length and strip HTML tags $name = substr(strip_tags($name), 0, 255); //Create a new PHPMailer instance $mail = new PHPMailer(true); //Tell PHPMailer to use SMTP $mail->isSMTP(); $mail->SMTPDebug = 3; //Set the hostname of the mail server $mail->Host = 'mail.mariananjie.co.uk'; // if your network does not support SMTP over IPv6 //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission $mail->SMTPKeepAlive = true; $mail->Mailer = 'smtp'; $mail->SMTPSecure = 'tls'; $mail->Port = 587; //Set the encryption mechanism to use - STARTTLS or SMTPS $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; //Whether to use SMTP authentication $mail->SMTPAuth = true; //Username to use for SMTP authentication - use full email address for gmail $mail->Username = 'support@mariananjie.co.uk'; //Password to use for SMTP authentication $mail->Password = ')%lBP)b+8j!u'; $mail->setFrom('support@mariananjie.co.uk', $from); //Set an alternative reply-to address $mail->addReplyTo($email, $name); //Set who the message is to be sent to info@mariananjie.com info@mandncentre.com mariana@mariananjie.com $mail->addAddress('info@mariananjie.com', $from . $subject); $mail->addAddress('mariana@mariananjie.com', $from . $subject); // $mailer->isHTML(true); //Set the subject line $mail->Subject = $subject; //Read an HTML message body from an external file, convert referenced images to embedded, //convert HTML into a basic plain-text alternative body $mymessage = $body_content; if(isset($_FILES["uploadcv"])){ if($_FILES["uploadcv"]["size"] > 0){ $mymessage .= '<br><br> See attachment below'; $mail->AddAttachment($file_tmp, $file_name); }else{ $mymessage .= '<br><br> No attachment'; // $data = array( "success" => false); //echo json_encode($data); //die(); } }else{ $mymessage .= '<br><br> No attachment'; } $mail->msgHTML($mymessage); //$mail->msgHTML($request); //Replace the plain text body with one created manually $mail->AltBody = 'This is a plain-text message body'; //Attach an image file //$mail->addAttachment('images/phpmailer_mini.png'); //send the message, check for errors if($form_type == 3){ $servername = "localhost"; $username = "mandnweb_mandnrecruit"; $password = "mandnrecruit$@12"; $dbname = "mandnweb_app_mariananjie"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die('error connect'); } $sql = "INSERT INTO client_leads (title, contact_person, email, phone, lead_source, lead_status, industry, company, website, no_of_employees, created_by, address, city, postal_code, notes)VALUES ('', '','$email', '', 'Newsletter Form', 0, '','','',0,0, '','','','Subscribed from website newsletter form.')"; if ($conn->query($sql) === TRUE) { }else{ $msg = 'error table'; } if ($mail->send()) { } // $conn->close(); $data = array( "success" => true, "msg" => $conn->error); }else{ if (!$mail->send()) { //echo 'Mailer Error: ' . $mail->ErrorInfo; $data = array( "success" => false); } else { //echo 'Message sent!'; //Section 2: IMAP //Uncomment these to save your message in the 'Sent Mail' folder. $data = array( "success" => true); } } echo json_encode($data); die(); ?>