How to retrieve the sender email with wp_mail()?
Question
I Have this simple following code :
<?php
//if "email" variable is filled out, send email
if (isset($_POST['email'])) {
//Email information
$to = get_option( 'admin_email' );
$headers = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
//send email
wp_mail($to, $subject, $message, $headers);
//Email response
echo "Thank you for contacting us!";
}
//if "email" variable is not filled out, display the form
else {
?>
<form method="post">
Email: <input name="email" type="text" /><br />
Subject: <input name="subject" type="text" /><br />
Message:<br />
<textarea name="message" rows="15" cols="40"></textarea><br />
<input type="submit" value="Submit" />
</form>
<?php
}
?>
My question is how to retrieve the sender email instead of the generated wp_mail()
from $header wordpress@$sitename
?
Thanks in advance for any help.
0
email, php, wp-mail
3 years
2020-08-24T10:10:20-05:00
2020-08-24T10:10:20-05:00 0 Answers
50 views
0
Leave an answer