email - Does the php mail() function work in Wordpress? -
This is related to another question I posted here, but this is a different matter so I hope people I do not think I am posting again.
I have an email form in Wordpress.
html
& lt; Form action = "id =" contact form "& gt; & Lt; Input type = "text" id = "contact name" placeholder = "name:" & gt; & Lt; Input type = "text" id = "contactEmail" placeholder = "email:" & gt; & Lt; Select id = "form-topic" & gt; & Lt; Options & gt; Subject & lt; / Options & gt; & Lt; Options & gt; Accounting & lt; / Options & gt; & Lt; Options & gt; Bookkeeping & lt; / Options & gt; & Lt; Options & gt; Start & lt; / Options & gt; & Lt; Options & gt; CIS returns & lt; / Options & gt; & Lt; Options & gt; Payroll & lt; / Options & gt; & Lt; Options & gt; Self assessment & lt; / Options & gt; & Lt; Options & gt; Tax Returns & lt; / Options & gt; & Lt; Options & gt; VAT Return & lt; / Options & gt; & Lt; Options & gt; Other & lt; / Options & gt; & Lt; / Select & gt; & Lt; Textarea id = "contact message" rows = "8" cols = "40" placeholder = "message:" & gt; & Lt; / Textarea & gt; & Lt; P id = "submit" & gt; Submit & lt; / P & gt; & Lt; Div id = "status" & gt; & Lt; P & gt; & Lt; / P & gt; & Lt; / Div & gt; & Lt; / Form & gt; jquery
$ j ('# submit'). Click (function () {// var nameVal = $ j ('# contactForm #contactName') .val (); var emailVal = $ j ('# contactForm #contactEmail'). Val (); var messageVal = $ j ('# ContactForm #contactMessage'). Val (); // $ j.post ('wp-content / code / contactEngine.php', {theName: nameVal, email: emailVal, message: messagewall}, function (data) {$ J ("# position p"). Html (data); $ j ("(data index ('thanks') == 0) {document.forms [0] .reset ();}}};} ) php
& lt; php $ errors = array (); $ required_field = array ('name', 'Email', 'message'); foreign currency ($ required_filld $ as field name) {if ((($ ($! POST [$ fieldname]]] || Empty ($ _ POST [$ filename])) {$ errors [] = $ field name;}} if (empty ($ errors)) {$ name_field = trim (strip slot ($ _ POST ['name']); $ Name = Explosion ('', $ name_field); $ Firstname = ucfirst ($ name [0]); $ email_field = trim (stripeslash ($ _ POST ['e-mail']); $ message = trim (stripslash $ _ POST ['message'])); // $ = "info@ttmt.org.uk"; $ Theme = "email from website"; $ Body = "From: $ name_field \ nEmail: $ email_field \ nMessage: \ n $ message"; // mail ($ $ to $ $ theme, $ body); // wp_mail ($ $ $ theme $ $); "Thank You $ First Name"; } Else {echo "Please complete all fields."; }? & Gt; php is in a folder in the wp-content folder, so jquery is easy to access it.
$ j.post ('wp -content / code / contactEngine.php', {theName: nameVal, e-mail: emailVal, theMessage: messageVal}, function (data) {< Code> variables reach PHP and an answer resonates back if the form is completed.
The actual email is not sent - what is the php mail () forward wordpress Works in.
I tried the wp_mail () function but this script completely closes and I do not get it.
I know that contact form 7 like Im There are plugins but I do not think they will work with this site.
This is a single page site with a custom post type, I'm not calling any content that I think That I want to work with Contact Form 7.
PHP mail function is completely free from WordPress It's built into a PHP function, and in principle it's working on all platforms. New.
The only thing that block in my mind may OM have a problem with your server configuration that you hsoting mail function, or it was not set up properly.
See that this example works in a single file ():
& lt; From php $ = 'nobody@example.com'; $ Theme = 'subject'; $ Message = 'hello'; $ Headers = 'From: webmaster@example.com' "\ r \ n" 'Answer: webmaster@example.com' "\ r \ n" 'X-Mailer: PHP /' phpversion (); Mail ($ $ $ $ theme, $ message, $ headers); ? & Gt;
Comments
Post a Comment