How to make WordPress emails async

Since wp_mail is pluggable, we can selectively override it. I run the following code in my general functionality plugin: /** * Email Async. * * We override the wp_mail function for all non-cron requests with a function that simply * captures the arguments and schedules a cron event to send the email. */ if ( … Read more

Sending HTML email with attachment with wp_mail()

Reference link click here. Using below code you can send the mail with html format. $to = ‘[email protected]’; $subject=”The subject”; $body = ‘The email body content’; $headers = array(‘Content-Type: text/html; charset=UTF-8’); wp_mail( $to, $subject, $body, $headers ); // For attachment $attachments = array( WP_CONTENT_DIR . ‘/uploads/file_to_attach.zip’ ); $headers=”From: My Name <[email protected]>” . “\r\n”; wp_mail( ‘[email protected]’, … Read more

wp_mail attachment not working

Attachments should always use the absolute filesystem path. Also to change the Content-Type of the email you should use the wp_mail_content_type filter. <?php function my_custom_email() { $to = ‘[email protected]’; $subject=”WordPress wp_mail”; $message=” <html> <body> <table rules=”all” style=”border-color: #666;” cellpadding=”10″> <tr>Hello WordPress</tr> </table> </body> </html> “; $attachments = array( WP_PLUGIN_DIR . ‘/my-plugin/uploads/sample_photo_01.jpg’ ); $headers[] = ‘From: … Read more

How to stop the wp_mail function?

Filter ‘phpmailer_init’, not ‘wp_mail’. To prevent sending the mail out reset the PHPMailer object. Prototype (not tested): add_action( ‘phpmailer_init’, ‘wpse_53612_conditional_mail_stop’ ); function wpse_53612_conditional_mail_stop( $phpmailer ) { ! my_condition() and $phpmailer = new stdClass; }

wp_mail very slow

What am i doing wrong here? Many, many things, not all performance related. Lets begin with the critical parts, then conclude on your performance issues and what can be done to mitigate and help AJAX API Firstly, you’re not using the AJAX API, and reinventing the wheel. It’s quite simple: JS: $.post( do_mail_sending.ajaxurl, { action: … Read more

How to email user after inserting the username in database in WordPress

Assuming that $member_details->user_login is already a user in the wp_users table, then you could use the following to get their email address: $user = get_user_by( $member_details->user_login, ‘login’ ); From there, you have the user’s email address and can use wp_mail() to email them: $subject = “My email subject”; $message = “My message body…”; wp_mail( $user->user_email, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)