WP – not sending email

wp_mail() uses phpMailer which defaults to localhost so if your development server is not configured as a mail server, the email won’t fly. Use the ‘wp_mail_failed’ action hook to get the WP_Error that’s thrown so you can further troubleshoot the problem.

wp_mail() function doesn’t send email in Ajax mode

@T.Todua : Ok and when I use your way it doesn’t deliver the email. It doesn’t send email in Ajax function and it’s my problem exactly add_action( ‘wp_ajax_ABCABCABC’, ‘wpse8170_phpmailer_init’ ); function wpse8170_phpmailer_init() { //it doesn’t send/deliver in a Ajax function wp_mail(“[email protected]”, “test”, “test”); } But when I use wp_mail() in post-back page it works fine … Read more

Using wp_mail in functions.php

You need to supply or line breaks for your header fields. For example: $headers = “From:” . $from . PHP_EOL; Or put the header fields into an array, in which case you don’t need to add the line breaks manually. $headers[] = “From:” . $from; Email headers are not ‘normal’ text. Those line ending are … Read more

upload file with front-end submission and forward the data in an email

In case anyone needs this, here is my solution: if ($_FILES) { function insert_attachment($file_handler, $post_id, $setthumb = ‘false’) { if ($_FILES[$file_handler][‘error’] !== UPLOAD_ERR_OK) __return_false(); require_once(ABSPATH . “wp-admin” . ‘/includes/image.php’); require_once(ABSPATH . “wp-admin” . ‘/includes/file.php’); require_once(ABSPATH . “wp-admin” . ‘/includes/media.php’); $attach_id = media_handle_upload( $file_handler, $post_id ); //get url $attachment_url = wp_get_attachment_url($attach_id); add_post_meta($post_id, ‘_file_paths’, $attachment_url); $attachment_data = … Read more