Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once 'db_connect.php';
- require 'phpmailer/PHPMailerAutoload.php';
- $mail = new PHPMailer;
- function sendFormEmail($mail, $to, $subject, $senderName, $senderEmail, $message, $sendCopy) {
- $_SESSION['token'] = random_string(50);
- $subject = filter_var($subject, FILTER_SANITIZE_STRING);
- $senderName = filter_var($senderName, FILTER_SANITIZE_STRING);
- $senderEmail = filter_var($senderEmail, FILTER_SANITIZE_EMAIL);
- $message = filter_var($_POST['body'], FILTER_SANITIZE_STRING);
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'mail.privateemail.com'; // Specify main and backup SMTP servers
- $mail->SMTPDebug = 2;
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'my-email'; // SMTP username
- $mail->Password = 'my-pass'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 25; // TCP port to connect to
- $mail->setFrom('webmaster@mysite.com', 'mysite.com');
- $mail->addAddress('my-email', 'me');
- $mail->addReplyTo($senderEmail, $senderName);
- $mail->Subject = "mysite.com: " . $subject;
- $mail->Body = "<h1>You've received a message through the contact form at mysite.com: </h1><br><p style='white-space: pre-wrap;'>" . $message . "</p>";
- $mail->AltBody = "You've received a message through the contact form at mysite.com: " . $message;
- if($mail->send()) {
- return "wooho!";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement