vendredi 1 avril 2016

Force plugin to use wp_mail

I downloaded a theme that has built a plugin for contacts which should send emails through an SMTP server through another plugin (WP Mail SMTP). the problem is that the contact plugin use own function mail() for sending e-mail and does not use wp_mail .

this means that outbound emails are not sent from wordpress email system, and therefore can not be sent through the SMTP plugin (which bypasses the default wp php email system)

This is the contact form code:

I tried to replace mail with wp_mail, but this did not work

<?php

$contact_message = $_POST['contact_message'];

// Redirect back
Header('Location: '. $_POST['contact-url'].'?message='.$contact_message);
echo "<meta charset='utf-8'>";  

// Loading variables from form
$blog_email = $_POST['blog_email'];
$name = $_POST['contact-name'];
$email = $_POST['contact-email'];
$message = $_POST['contact-message'];

// EMAIL TO HOTEL CREW
$headers = 'From: '. $name . '<' . $email . '>' . "\r\n" .
    'Reply-To: '. $name . '<' . $email . '>' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
$subject = 'Message';
$message = 'Name: ' . $name . '
Email: ' . $email . '

' . $message;

$to = $blog_email;

// Send mail
mail($to,$subject,$message,$headers);
// END OF EMAIL TO HOTEL CREW
// ---------------------

exit();

?>

could you give me some advice?

Thanks

Regards, Fabio



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire