12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- error_reporting(1);
-
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception;
- use PHPMailer\PHPMailer\SMTP;
- use PHPMailer\PHPMailer\OAuth;
-
- require 'PHPMailer/src/Exception.php';
- require 'PHPMailer/src/PHPMailer.php';
- require 'PHPMailer/src/SMTP.php';
- require 'PHPMailer/src/OAuth.php';
-
- $mail = new PHPMailer(true);
-
- //Server settings
- // $mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output
- $mail->isSMTP(); //Send using SMTP
- $mail->Host = 'ssl://smtp.gmail.com'; //Set the SMTP server to send through
- $mail->SMTPAuth = true; //Enable SMTP authentication
- $mail->Username = 'sales@anwisystems.com'; //SMTP username
- $mail->Password = 'Anwisales'; //SMTP password
- $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption
- // $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
- $mail->Port = 587; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
-
- //Recipients
- $mail->setFrom('sales@anwisystems.com', 'Anwi Sales');
- $mail->addAddress('sales@anwisystems.com', 'Anwi'); //Add a recipient
- //$mail->addAddress('ellen@example.com'); //Name is optional
- $mail->addReplyTo('sales@anwisystems.com', 'reply-to-Anwi');
- //$mail->addCC('cc@example.com');
- //$mail->addBCC('bcc@example.com');
-
- //Attachments
- // $mail->addAttachment('/var/tmp/file.tar.gz'); //Add attachments
- // $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); //Optional name
-
- //Send HTML or Plain Text email
- $mail->isHTML(true);
-
- if(!empty($_POST['contactemail'])){
- $contactName=$_POST['contactname'];
- $email=$_POST['contactemail'];
- $phone=$_POST['contactnumber'];
- $message=$_POST['contactmessage'];
- }
-
- $body = "<table><tbody>";
- $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>";
- $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>";
- $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>";
- $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>";
- $body .= "</tbody></table>";
-
- $mail->Subject = "Contact From $contactName";
- $mail->Body = $body;
- // $mail->AltBody = "This is the plain text version of the email content";
-
- try {
- $mail->send();
- echo 1;
- } catch (Exception $e) {
- echo "Mailer Error: " . $mail->ErrorInfo;
- }
-
- ?>
|