wp_mail – using a custom field value
Yes, it can work. But you should filter the email in the custom field. Users might have a error in his context or the mail address is wrong. You can filter the email address with filter_var()
Yes, it can work. But you should filter the email in the custom field. Users might have a error in his context or the mail address is wrong. You can filter the email address with filter_var()
it looks like you should use $mypost = get_post($_POST[‘pid’]); $ogg = $mypost->post_title; instead of $ogg = get_post($post->ID, post_title);
WordPress uses by default wp_mail()source which is a PHP function very similar to the native PHP mail. Hence this service is provided by your server/host. This function is, however, pluggable, which means it can be overridden by plugins and custom functions, so it might be slightly different in your case.
wp_mail from Codex Use this example: add_filter( ‘wp_mail_content_type’, ‘set_html_content_type’ ); wp_mail( $mails_to, ‘The subject’, ‘<p>The <em>HTML</em> message</p>’ ); // Reset content-type to avoid conflicts — http://core.trac.wordpress.org/ticket/23578 remove_filter( ‘wp_mail_content_type’, ‘set_html_content_type’ ); function set_html_content_type() { return ‘text/html’; }
There are a couple of problems that may lead to failure of your script. First, you have a check for $mailSent at the top so you can redirect. However, at that point, it is undefined. It would be less likely to be a problem if you move it to where you check it at the … Read more
$post->post_author will return the ID of the post author, which you can then use with the WP_User object to retrieve the username and add to the outgoing email: if (get_option(‘jr_bcc_apply_emails’)==’yes’) : $author = new WP_User( $post->post_author ); $username = $author->user_login; $to = get_option(‘admin_email’); $subject = __(‘[copy] going for “‘, APP_TD).$post->post_title.'”‘; $message .+ ” {$username}”; wp_mail( … Read more
From quick look at your code you seem to be omitting where you are submitting request to. By default it is just current page, which isn’t typically equipped to receive the request. Since you are using wp_ajax_ hook you need to point request at admin-ajax.php endpoint. On admin side the URL is provided in ajaxurl … Read more
$getusers -> $get_users Simple mistake of wrong variable use!
My usual solution for this is a plugin called WP Mail SMTP. The problem with this is that the plugin has not been updated in over 2 years. This means that issues with more recent versions of WordPress (although at present that shouldn’t be the case) and also means you are likely on your own … Read more
Instead of attaching the attachments to body content. Pass it as separate parameter. Like the below one. @wp_mail($to, $subject, $msg, $headers,$mail_attachment); I guess it solves your problem.