Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function deliver_mail() {
- //name of button
- require_once "C:/xampp/htdocs/WP/wp-includes/class-phpmailer.php";
- // sanitize form values
- $name = sanitize_text_field( $_POST["name"] );
- $email = sanitize_email( $_POST["email"] );
- $subject = sanitize_text_field( $_POST["subject"] );
- $message = esc_textarea( $_POST["message"] );
- // get the blog administrator's email address
- //$d = ($_POST["hidden"]);
- $headers = "From: $name <$email>" . "\r\n";
- // Localhost
- $mail = new PHPMailer(true);
- $mail->IsSMTP(); // telling the class to use SMTP
- $mail->CharSet = 'UTF-8';
- $mail->SMTPDebug = 0; // enables SMTP debug information (for testing)
- $mail->SMTPAuth = true; // enable SMTP authentication
- $mail->SMTPSecure = "ssl"; // sets the prefix to the servier
- $mail->Host = "mail.gmx.com"; // sets GMX as the SMTP server for example: mail.gmx.com
- $mail->Port = 465; // set the SMTP port for the GMX server
- $mail->Username = $email;
- $mail->Password = 'pass';
- $mail->SetFrom($email, $name);
- $mail->AddAddress($instance['email']);
- //Here has to be accessed $instance['email'] variable from the form() function;
- $mail->Subject = $subject;
- $mail->MsgHTML($message);
- $headers .= "Content-Type: text/html; charset=utf-8";
- $headers .= "Content-Transfer-Encoding: 8bit";
- try {
- $mail->send();
- $msg = "An email has been sent for verfication.";
- $msgType = "success";
- } catch (Exception $ex) {
- $msg = $ex->getMessage();
- $msgType = "warning";
- }
- die();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement