wordpress - How to send email in php with wp_mail -
i have seen similar code in use on place, can't work...
$to = 'myeamil@gmail.com'; $subject = 'test'; $message = 'test'; $headers = 'just test'; wp_mail( $to, $subject, $message, $headers );
i tried with:
if (wp_mail( $to, $subject, $message )) { echo "success"; } else { echo "fail"; }
nothing gets printed. missing?
i prefer not use plugin this.
this different how have it:
try { $sent = @wp_mail( $to, $subject, $message ); } catch (exception $e) { error_log('oops: ' . $e->getmessage()); // line testing only! } if ( $sent ) { error_log('hooray! email sent!'); // 1 } else { error_log('oh. email not sent.'); // , one, }
oh, , not work on localhost without proper setup.
Comments
Post a Comment