wp_mail attachment not working in wordpress

You don’t need to know the file names before, you’ll have access to them. I saw you using $subject = $_POST[‘subject’]; – this means the subject will be the value of the input with the name of “subject”. In your case, this one : <input id=”subject” class=”form-control” name=”subject” type=”text” /></div> We can use the same … Read more

wp_mail sending only once inside foreach loop

Sometimes the mail port can get clogged up, so I usually add a brief sleep(10) in the for-loop. The 10 seconds is arbitrary, but it works for my purposes. foreach($entries as $key=>$entry){ $email = array( ‘[email protected]’ ); $subject = “Documents Requested”; $headers = array(‘Content-Type: text/html; charset=UTF-8’); $message = getDMVemailMessage($entries[$key][‘id’]); $sent = sendDMVNotifyEmail($email, $subject, $message, $headers); … Read more

wp_mail vs mail functions and header arrays

Both the mail() function in PHP and wp_mail() in WordPress do support passing an array or string of headers, but the difference is: With mail(), the array keys are the header names and its values are the respective header values, e.g. array( ‘Content-type’ => ‘text/html; charset=utf-8’ ). wp_mail() on the other hand, expects that the … Read more

WordPress is not sending the 2nd email in the same request

The issue was not caused by WordPress. It was caused by a plugin. In this particular case, I checked the plugins installed looking for anything that could modify the mail behavior. I disabled the plugin “Email Templates” and started receiving all the messages normally. Then I noted that there was an update available for that … Read more