Quantcast
Channel: WordPress.org Forums » [WP Mail SMTP by WPForms - The Most Popular SMTP and Email Log Plugin] Support
Viewing all articles
Browse latest Browse all 5030

Postman SMTP on "[Plugin: WP Mail SMTP] Send with AJAX"

$
0
0

I suppose you could add this to your theme's functions.php, but I'm not a theme dev, so don't quote me.

You'll need your endpoint function:

function sendMail() {
    $to = $_POST ['to'];
    $subject = $_POST ['subject'];
    $message = $_POST ['message'];
    wp_mail($to, $subject, $message); // send mail
    wp_send_json_success(); // return and die
}

Then you'll need to hook it into WordPress:

if (is_admin ()) {
    add_action ( 'wp_ajax_MyAwesomeMailFunction', 'sendMail' );
    add_action ( 'wp_ajax_nopriv_MyAwesomeMailFunction', 'sendMail' );
}

.. where MyAwesomeMailFunction is the action you'll use in your Ajax post.

Give the codex a read. https://codex.wordpress.org/AJAX


Viewing all articles
Browse latest Browse all 5030


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>