Check to check if wp_mail is working properly?

WordPress relies on the PHPMailer class to send email through PHP’s mail function. Since PHP’s mail function returns very little information after execution (only TRUE or FALSE), I suggest temporarily stripping down your mv_optin_mail function to a minimum in order to see if the wp_mail functions works. Example: $mailResult = false; $mailResult = wp_mail( ‘[email protected]’, … Read more

Pluggable function and activation check?

Don’t do the check on activation? Seriously, the best way I can think of is not to check for this on activation, but only in the normal plugin load process. And instead of throwing a warning (I assume you mean a PHP E_WARNING), perhaps putting an admin error box up would make more sense.

WordPress “phpmailer_init” not working for me

Where is the problem? Am I doing something wrong? Your code seems fine to me, so despite I can’t give you a definitive answer on what/where exactly is the problem, I thought these might help you troubleshoot the issue: First and foremost, check your configuration — e.g. did you use the correct (SMTP) username/email, password, … Read more

wp_mail and BCC headers

You could try to debug the output like this: function test_phpmailer_init( $phpmailer ) { echo ‘<pre>’; var_dump( $phpmailer ); echo ‘</pre>’; return $phpmailer; } add_action( ‘phpmailer_init’, ‘test_phpmailer_init’ ); The code in your question is correct, the problem is with your local SMTP application. If you are using a local SMTP server (e.x. Papercut), it only … Read more

How to send an email using wp_mail and using more than one BCC in the header

$headers can be a string or an array, but it may be easiest to use in the array form. To use it, push a string onto the array, starting with “From:”, “Bcc:” or “Cc:” (note the use of the “:”), followed by a valid email address. https://codex.wordpress.org/Function_Reference/wp_mail#Using_.24headers_To_Set_.22From:.22.2C_.22Cc:.22_and_.22Bcc:.22_Parameters In other words: $headers = array( ‘From: [email protected]’, … Read more

How to add headers to outgoing email?

Thanks to the above, I’ve realized my central mistake — I didn’t quite realize that the arguments being passed in were a multi-dimensional array. For now, I’ve re-implemented the function thus: function ws_add_site_header($email) { $email[‘headers’][] = ‘X-WU-Site: ‘ . parse_url(get_site_url(), PHP_URL_HOST) ; return $email; } My reading of the wp_mail() source (see: https://core.trac.wordpress.org/browser/tags/4.4.2/src/wp-includes/pluggable.php#L235) leads me … Read more

Using wp_schedule_single_event with arguments to send email

I think you have mismatch in how you pass arguments and how you expect it to work. You pass array of arguments to schedule and expect your hooked function to receive identical array of arguments. This is not the case. Cron events are processed by do_action_ref_array(), which in turn passes arguments via call_user_func_array(). So your … Read more

Do something after sending email

Using the PHPMailer class with an action callback: I did some digging into the PHPMailer class and found that it supports a custom action. Here’s how the callback is activated with the doCallback() method in the class. There’s also a PHPMailer test on GitHub using this feature via the callbackAction() callback. We can set it … Read more

Using wp_mail with attachments but no attachments received

The $attachment argument for wp_mail takes a file (or array of files) – but the file path has to be fully specified. For example: <?php $attachments = array(WP_CONTENT_DIR . ‘/uploads/file_to_attach.zip’); $headers=”From: My Name <[email protected]>” . “\r\n”; wp_mail(‘[email protected]’, ‘subject’, ‘message’, $headers, $attachments); ?> (see Codex). It seems that your $_POST[‘file’] is probably not specifying the full … Read more

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