Advertisement
Guest User

Untitled

a guest
Jan 1st, 2018
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.36 KB | None | 0 0
  1. <?php
  2. require '/PHPMailer/PHPMailerAutoload.php';
  3. require '/PHPMailer/extras/Security.php';
  4.  
  5. define('SMTP_HOST', 'smtp.gmail.com'); // Hostname of the mail server
  6. define('SMTP_USERNAME', 'dXXXXX@gmail.com'); // Username for SMTP authentication any valid email created in your domain
  7. define('SMTP_PASSWORD', 'XXXXXX'); // Password for SMTP authentication
  8. define('SMTP_PORT', 465); // Port of the SMTP like to be 25, 80, 465 or 587
  9.  
  10. // To address who will receive this email
  11. $to = 'dXXXXXX@gmail.com';
  12.  
  13. $security = new Security();
  14.  
  15. // This IF condition is for improving security and Prevent Direct Access to the Mail Script.
  16. if (isset($_POST['name']) AND isset($_POST['email']) AND isset($_POST['subject']) AND isset($_POST['message']))
  17. {
  18.  
  19.     echo "my email $email";
  20.    
  21.     // Collect POST data from form
  22.     $name = $security->xss_clean($_POST['name']);
  23.     $email = $security->xss_clean($_POST['email']);
  24.     // $subject = $security->xss_clean($_POST['subject']);
  25.     // $services = ($_POST['services'] <> '') ? implode(',', $security->xss_clean($_POST['services'])) : '-';
  26.     // $project_class = ($_POST['project_class'] <> '') ? $security->xss_clean($_POST['project_class']) : '-';
  27.     $message = $security->xss_clean($_POST['message']);
  28.  
  29.     // Prefedined Variables
  30.     $set_from = 'KORDA Notification Mailer';
  31.     $subject = 'KORDA: Message from ' . $name . '!';
  32.  
  33.     // Collecting all content in HTML Table
  34.     $content = '<table width="100%">
  35.    <tr><td colspan="2"><strong>Contact Details:</strong></td></tr>
  36.    <tr><td valign="top">Name:</td><td>' . $name . '</td></tr>
  37.    <tr><td valign="top">Email:</td><td>' . $email . '</td></tr>
  38.    <tr><td valign="top">Message:</td><td>' . $message . '</td></tr>
  39.    </table> ';
  40.  
  41.     $mail = new PHPMailer;
  42.     $mail->isSMTP();
  43.     // $mail->SMTPDebug = 1;
  44.     // $mail->Debugoutput = 'html';
  45.     $mail->Host = SMTP_HOST;
  46.     $mail->Port = SMTP_PORT;
  47.     $mail->SMTPSecure = 'tls';
  48.     // $mail->SMTPAutoTLS = false;
  49.     $mail->SMTPAuth = TRUE;
  50.     $mail->Username = SMTP_USERNAME;
  51.     $mail->Password = SMTP_PASSWORD;
  52.  
  53.     $mail->setFrom(SMTP_USERNAME, $set_from);
  54.     $mail->addAddress($to);
  55.  
  56.     $mail->Subject = $subject;
  57.     $mail->msgHTML($content);
  58.  
  59.     // Send the message
  60.     $send = false;
  61.    
  62.     if ($mail->send())
  63.     {
  64.         $send = true;
  65.     }
  66.  
  67.     echo json_encode($send);
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement