admin管理员组文章数量:1130349
I have a custom HTML form with input types and checkboxes. When I submit this form I want to send a mail will all the form details from the same php. How do I send the email from WordPress? I am pretty new and would thank for ur help.
I have a custom HTML form with input types and checkboxes. When I submit this form I want to send a mail will all the form details from the same php. How do I send the email from WordPress? I am pretty new and would thank for ur help.
Share Improve this question edited Oct 25, 2017 at 17:50 cybmeta 20.7k5 gold badges47 silver badges58 bronze badges asked Oct 25, 2017 at 17:15 SouravSourav 431 gold badge1 silver badge7 bronze badges3 Answers
Reset to default 7wp_mail is the function you are looking for.
You can take the posted form data ($_POST['email'], for example) and then use it to build and execute the wp_mail function. The example below was taken from https://developer.wordpress/reference/functions/wp_mail/#user-contributed-notes
$to = $_POST['email']; //[email protected]
$subject = 'The subject';
$body = 'The email body content';
$headers = array('Content-Type: text/html; charset=UTF-8');
wp_mail( $to, $subject, $body, $headers );
Also the above script would need to check for malicious attacks or bad input from the user but the wp_mail function will allow you to send email.
Source: https://developer.wordpress/reference/functions/wp_mail/
If you don't want to write your own code (and the mail form), consider a 'contact form' plugin. I use (and recommend) the Contact Form 7 plugin. It allows you to create any form, customize the look/feel/fields, and the mail that is sent out. Very powerful and popular plugin. Lots of other plugins available to add additional fields.
The only minor issue is sparse and sometimes hard-to-find (and sometimes older) technical documentation (like available filters). But I've worked around that.
One simple way to post a form is to use a form backend service like https://www.formkeep
All you have to do is modify the action tag in your form and backend service will store the data and provide ways to integrate data with the other systems.
Here's a sample for how to modify the form html. You would just replace "example token" with a key provided by the formkeep service
<form accept-charset="UTF-8" action="https://formkeep/f/exampletoken" method="POST">
I have a custom HTML form with input types and checkboxes. When I submit this form I want to send a mail will all the form details from the same php. How do I send the email from WordPress? I am pretty new and would thank for ur help.
I have a custom HTML form with input types and checkboxes. When I submit this form I want to send a mail will all the form details from the same php. How do I send the email from WordPress? I am pretty new and would thank for ur help.
Share Improve this question edited Oct 25, 2017 at 17:50 cybmeta 20.7k5 gold badges47 silver badges58 bronze badges asked Oct 25, 2017 at 17:15 SouravSourav 431 gold badge1 silver badge7 bronze badges3 Answers
Reset to default 7wp_mail is the function you are looking for.
You can take the posted form data ($_POST['email'], for example) and then use it to build and execute the wp_mail function. The example below was taken from https://developer.wordpress/reference/functions/wp_mail/#user-contributed-notes
$to = $_POST['email']; //[email protected]
$subject = 'The subject';
$body = 'The email body content';
$headers = array('Content-Type: text/html; charset=UTF-8');
wp_mail( $to, $subject, $body, $headers );
Also the above script would need to check for malicious attacks or bad input from the user but the wp_mail function will allow you to send email.
Source: https://developer.wordpress/reference/functions/wp_mail/
If you don't want to write your own code (and the mail form), consider a 'contact form' plugin. I use (and recommend) the Contact Form 7 plugin. It allows you to create any form, customize the look/feel/fields, and the mail that is sent out. Very powerful and popular plugin. Lots of other plugins available to add additional fields.
The only minor issue is sparse and sometimes hard-to-find (and sometimes older) technical documentation (like available filters). But I've worked around that.
One simple way to post a form is to use a form backend service like https://www.formkeep
All you have to do is modify the action tag in your form and backend service will store the data and provide ways to integrate data with the other systems.
Here's a sample for how to modify the form html. You would just replace "example token" with a key provided by the formkeep service
<form accept-charset="UTF-8" action="https://formkeep/f/exampletoken" method="POST">
本文标签: emailHow do i send mail with custom Form Data using WordPress
版权声明:本文标题:email - How do i send mail with custom Form Data using WordPress 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749234698a2337082.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论