Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*error_reporting(E_ALL);
- ini_set("display_errors", 1);
- */
- require_once 'vendor/autoload.php';
- /**
- * Simple contact file for sending emails
- */
- header("Content-Type: application/json");
- if (isset($_POST) && count($_POST) > 0) {
- $name = '';
- $email = '';
- $phone = '';
- $company = '';
- $designation = '';
- $billing_name = '';
- $billing_email = '';
- $billing_phone = '';
- $billing_company = '';
- $address_line1 = '';
- $address_line2 = '';
- $city = '';
- $state = '';
- $country = '';
- $pincode = '';
- $isValid = true;
- if (empty($_POST['form_name']) or empty($_POST['form_email']) or empty($_POST['form_phone'])
- or empty($_POST['form_company']) or empty($_POST['billing_name']) or empty($_POST['billing_email']) or empty($_POST['billing_phone']) or empty($_POST['billing_company'])) {
- $isValid = false;
- }
- function test_input($data) {
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- return $data;
- }
- if ($isValid) {
- $name = test_input($_POST['form_name']);
- $email = test_input($_POST['form_email']);
- $phone = test_input($_POST['form_phone']);
- $company = test_input($_POST['form_company']);
- $designation = test_input($_POST['form_designation']);
- $billing_name = test_input($_POST['billing_name']);
- $billing_email = test_input($_POST['billing_email']);
- $billing_phone = test_input($_POST['billing_phone']);
- $billing_company = test_input($_POST['billing_company']);
- $address_line1 = test_input($_POST['address_line1']);
- $address_line2 = test_input($_POST['address_line2']);
- $city = test_input($_POST['city']);
- $state = test_input($_POST['state']);
- $country = test_input($_POST['country']);
- $pincode = test_input($_POST['pincode']);
- $mail = new PHPMailer;
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->SMTPOptions = [
- 'ssl' => [
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => true,
- ],
- ];
- $mail->Host = 'mail.lyotalk.com'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'web@lyotalk.com'; // SMTP username
- $mail->Password = 'lyotalk@123'; // SMTP password
- $mail->SMTPSecure = ''; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 587;
- $mail->setFrom('web@lyotalk.com', 'Lyotalk Ireland 2017');
- $mail->addAddress('web@biotrains.com.test-google-a.com', 'Lyotalk Ireland 2017'); // Add a recipient
- //var_dump($_FILES);die();
- $mail->isHTML(true);
- $mail->Subject = "Registration of Lyotalk Ireland - 2017";
- $body = 'Hi I am '.$name.' and have mailed for '.$mail->Subject.'.<br>
- <b>Delegate Details : </b>
- Name : '.$name.'<br>
- Email : '.$email.'<br>
- Phone : '.$phone.'<br>
- Company : '.$company.'<br>
- Designation : '.$designation.'<br>
- <b>Billing Details : </b>
- Billing Name : '.$billing_name.'<br>
- Billing Email : '.$billing_email.'<br>
- Billing Phone : '.$billing_phone.'<br>
- Billing Company : '.$billing_company.'<br>
- Address Line 1 : '.$address_line1.'<br>
- Address Line 2 : '.$address_line2.'<br>
- City : '.$city.'<br>
- State : '.$state.'<br>
- Country : '.$country. '<br>
- Pincode : '.$pincode;
- $mail->Body = nl2br($body);
- $msg = ["msg" => "Email sent successfully!"];
- if (!$mail->send()) {
- $msg["msg"] = "Failed to send email - " . $mail->ErrorInfo;
- }
- header("Location: http://www.lyotalk.com/"); /* Redirect browser */
- } else {
- echo json_encode(["msg" => "Some fields are missing!"]);
- }
- } else {
- echo json_encode(["msg" => "Somethings wrong!"]);
- }
- ?>
Add Comment
Please, Sign In to add comment