설명 없음
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

contact.php 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. error_reporting(1);
  3. use PHPMailer\PHPMailer\PHPMailer;
  4. use PHPMailer\PHPMailer\Exception;
  5. use PHPMailer\PHPMailer\SMTP;
  6. use PHPMailer\PHPMailer\OAuth;
  7. require 'PHPMailer/src/Exception.php';
  8. require 'PHPMailer/src/PHPMailer.php';
  9. require 'PHPMailer/src/SMTP.php';
  10. require 'PHPMailer/src/OAuth.php';
  11. $mail = new PHPMailer(true);
  12. //Server settings
  13. // $mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output
  14. $mail->isSMTP(); //Send using SMTP
  15. $mail->Host = 'ssl://smtp.gmail.com'; //Set the SMTP server to send through
  16. $mail->SMTPAuth = true; //Enable SMTP authentication
  17. $mail->Username = 'sales@anwisystems.com'; //SMTP username
  18. $mail->Password = 'Anwisales'; //SMTP password
  19. $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption
  20. // $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
  21. $mail->Port = 587; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
  22. //Recipients
  23. $mail->setFrom('sales@anwisystems.com', 'Anwi Sales');
  24. $mail->addAddress('sales@anwisystems.com', 'Anwi'); //Add a recipient
  25. //$mail->addAddress('ellen@example.com'); //Name is optional
  26. $mail->addReplyTo('sales@anwisystems.com', 'reply-to-Anwi');
  27. //$mail->addCC('cc@example.com');
  28. //$mail->addBCC('bcc@example.com');
  29. //Attachments
  30. // $mail->addAttachment('/var/tmp/file.tar.gz'); //Add attachments
  31. // $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); //Optional name
  32. //Send HTML or Plain Text email
  33. $mail->isHTML(true);
  34. if(!empty($_POST['contactemail'])){
  35. $contactName=$_POST['contactname'];
  36. $email=$_POST['contactemail'];
  37. $phone=$_POST['contactnumber'];
  38. $message=$_POST['contactmessage'];
  39. }
  40. $body = "<table><tbody>";
  41. $body .= "<tr><td style='padding:5px 10px;background-color:#F0C500;color:#fff;border-bottom:1px solid #fff;'>Contact Person</td><td style='padding:5px 10px;background-color:#DDDDDD;color:#000;border-bottom:1px solid #fff;'>$contactName</td></tr>";
  42. $body .= "<tr><td style='padding:5px 10px;background-color:#F0C500;color:#fff;border-bottom:1px solid #fff;'>Email</td><td style='padding:5px 10px;background-color:#DDDDDD;color:#000;border-bottom:1px solid #fff;'>$email</td></tr>";
  43. $body .= "<tr><td style='padding:5px 10px;background-color:#F0C500;color:#fff;border-bottom:1px solid #fff;'>Phone</td><td style='padding:5px 10px;background-color:#DDDDDD;color:#000;border-bottom:1px solid #fff;'>$phone</td></tr>";
  44. $body .= "<tr><td style='padding:5px 10px;background-color:#F0C500;color:#fff;border-bottom:1px solid #fff;'>Message</td><td style='padding:5px 10px;background-color:#DDDDDD;color:#000;border-bottom:1px solid #fff;'>$message</td></tr>";
  45. $body .= "</tbody></table>";
  46. $mail->Subject = "Contact From $contactName";
  47. $mail->Body = $body;
  48. // $mail->AltBody = "This is the plain text version of the email content";
  49. try {
  50. $mail->send();
  51. echo 1;
  52. } catch (Exception $e) {
  53. echo "Mailer Error: " . $mail->ErrorInfo;
  54. }
  55. ?>