Questions tagged [wp-mail]

wp_mail() is a wrapper for PHPMailer which is a wrapper for PHP’s mail() function.

Filter by
Sorted by
Tagged with
41
votes
4answers
78k views

Is there a way to send HTML formatted emails with Wordpress' wp_mail function?

Is there an action_hook or something similar that could help me achieve this? I tried adding markup in a PHP string variable and just fired off an email with the wp_mail function like so: $email_to =...
37
votes
7answers
18k views

Sending multipart (text/html) emails via wp_mail() will likely get your domain banned

Summary Because of a bug in WP Core, sending multipart emails (html/text) with wp_mail() (to reduce chance of emails ending up in spam folders) will ironically result with your domain being blocked ...
32
votes
5answers
30k views

Why won't wp_mail() let me set the From: header when plain old PHP mail() will?

When I use wp_mail( $to, $subject, $message, $headers ) (with values in place, of course), the email gets sent with a from name and email that isn't set anywhere I can find (not even in PHP or Apache ...
21
votes
1answer
5k views

What is the advantage of using wp_mail?

What is the advantage of using wp_mail() over mail(). Codex says they're similar, but they seem to be very similar.
18
votes
3answers
41k views

What's the easiest way to setup SMTP settings programmatically?

Assume we have blank WP site and we want to setup SMTP settings programmatically in our plugin or theme. What's the easiest way to do it without changing core files?
11
votes
1answer
2k views

Do something after sending email

I want to do something after WordPress sent an email. For example, after sending "Reset Password" email using wp_mail() function.
10
votes
1answer
39k views

Using wp_mail with attachments but no attachments received

I have been looking at multiple examples including this one. I get the email no problem but there are no attachments. Am I missing the content/type of file type? All the examples I've seen uses only ...
9
votes
8answers
83k views

WordPress refuses to send mail, “…your host may have disabled the mail() function”

I recently implemented a comment area on my website and tried to get the email notification to work. It doesn't seem to want to send email notifications when new comments are made. Just to see if ...
8
votes
3answers
3k views

How to add headers to outgoing email?

I want to add an additional header to outgoing emails on my sites, so I can easily determine which site sent a given email. (I put a standard functionality plugin on all of my sites, so this is easy ...
6
votes
2answers
8k views

Using wp_schedule_single_event with arguments to send email

I'm trying to schedule a pseudo cron job to send an email after a set amount of time utilizing a WordPress plugin. So far, I've been able to make this code run when I hard code the email address and ...
6
votes
1answer
43k views

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

I have this code part that's responsible for getting the variables from the contact form - and and sending an email to me, and my friends from work. add_action('wp_ajax_nopriv_submit_contact_form', '...
6
votes
1answer
8k views

wp_mail and BCC headers

I'm using WP 3.3.1 I am trying to add BCC onto the headers of an email I'm sending out, but the BCC is not being added. public $from = "sender@example.com"; public $replyTo = "sender@example.com"; ...
6
votes
1answer
336 views

Pluggable function and activation check?

Plugin is defining pluggable wp_mail() function. My idea was to check if function is defined already and throw warning if other plugin beat me to it. However this warning causes issues on activation. ...
5
votes
2answers
1k views

Using WordPress templating for HTML emails

I am working on a plugin that needs to send out an email after a form submission. I am using wp_mail() for this and it works fine. My problem is that in my code the HTML is generated by a bunch of ...
5
votes
1answer
669 views

Send attachments via wp_mail from temporary folder

Is it possible to send attachment via wp_mail, using temporary file, instad of uploading them to any actual folder on server? For example: <input type="file" name="file"> $attachment[] = $...
4
votes
2answers
24k views

how to set from address according to the form input email address for wp_mail()?

I am trying to create form and send it to my e-mail address using wp_mail. my wp_mail() code is: if($_POST["submit"]) { $to="my email"; $subject ="My subject"; $sender=$_POST["...
4
votes
2answers
13k views

wp_mail script with jQuery post

I need to send an email from a page when a form is submitted. I thought I'd use jQuery post but I'm not really sure where to start. Would I use wp_mail()? And if so how could it be called? Sorry if ...
4
votes
1answer
7k views

wp_mail is undefined

I am writing a plugin that opens up a form to invite people to a website by email and want to use wp_mail(). Whenever I use the wp_mail() function in any file in my plugin folder I always end up with:...
4
votes
3answers
7k views

How to apply the “retrieve_password_message” filter?

I would like to change the body of the password reset email that WP sends out with something more friendly. I am trying to use the "retrieve_password_message" filter but I am messing it up. Can ...
4
votes
2answers
4k views

wp_mail - Remove sitename from email subject

Can someone tell me how to remove site name from the email subject. As of now my email subject looks like this: [sitename] - Subject goes here I want it to look like this: Subject goes here I ...
4
votes
3answers
3k views

How do I override the Message-ID header of wp_mail function?

I have a custom notification function for our comments editor, who prefers to have all comments from one article threaded together in her email client. To achieve this, I'm creating a custom message-...
4
votes
1answer
5k views

Adding an Attachment to Contact Form Using wp_mail

Would anyone be kind enough to explain to me how to attach an uploaded file to an email generated using wp_mail? I've built the form but all the questions I can find online refer to attaching a pre-...
4
votes
1answer
1k views

Using wp_mail() - verify that email was sent?

When using wp_mail(), is there any way to verify that the email was sent correctly?
4
votes
1answer
431 views

Wordpress new user / forgot password emails are broken

I have no idea why it does this - I checked my mu-plugins, functions.php, there's currently nothing that alters emails. (Note that I translated these by heart, words might not be the same but links ...
3
votes
1answer
6k views

Email sent from WordPress has HTML tags

Instead of: Hello, Thank you dfasdfasdfasdf asdf asdf asdfas dfs Please, feelasdf asdf asdf The email that arrives in my mailbox looks like the following: <p>Hello,</p> <p>&...
3
votes
1answer
11k views

Multiple email recipient using wp_mail()

I want to define multiple recipients email address outside the array. like $adminmail = get_option(admin_email); $adminmail2 = like an email address; $multiple_recipients = array($adminmail,$...
3
votes
2answers
9k views

Reset Password - change from name and email address

When the password reset goes out, the name is 'WordPress' and the from address is wordpress@domain.com. I need to change these to the company name. I'm running WordPress 3.8 multisite and have done ...
3
votes
2answers
2k views

wp_mail function timing out

I have the following function. This is part of a membership-based site. When a post of the type "message" is moved to Publish status, it should send an email to all users who belong (custom user meta) ...
3
votes
1answer
7k views

Fatal error: Call to undefined function wp_mail()

I am using a plugin wordpress-simple-paypal-shopping-cart for my cart requirement. I am trying to send an email through this plugin when some payment is made by using IPN. My code : $invoiceProducts ...
3
votes
1answer
642 views

Send an email when custom post type category is changed

This is the first time I've attempted to write an action hook. My CPT has 4 categories. I'm trying to make WP automatically sends an email notification when the category is changed. By change I ...
3
votes
1answer
1k views

How to override the email function by using filters? [closed]

Is there a do_action() or an add_filter() that I can implement to use my own send mail function instead of Elegant Theme's wp_mail() function in their Divi theme? I want to intercept the Divi emailer ...
3
votes
1answer
2k views

Different wp_mail_from and wp_mail_from_name for specific situations

I'm wondering how to create differents wp_mail_from and wp_mail_from_name for specific actions that use the built-in mail system in Wordpress. For example, when a new comment comes, notify the user ...
3
votes
2answers
1k views

Mail will not send in HTML

Okay, I've got the following issue. I'm trying to send a mail in HTML format. I made a class that returns an HTML string, and that works great. When I pass that html-mail as $message in my function, ...
3
votes
1answer
46 views

Claim Listing functionality - how to send email to users when their claim has been approved or denied

We have a claim listing plugin, it allows items(posts) to be claimed by users. It requires the user to "register" in order to claim that item therefore they have to enter a username and their email. ...
3
votes
1answer
1k views

How to allow specific extensions and file size to wp_mail attachment?

I am trying to create a form with an attachment option that will be sent to an email when the form is submitted on a wordpress site. My codes work fine and it sends email in a HTMKL table format to ...
2
votes
4answers
67k views

Check to check if wp_mail is working properly?

I'm trying to use wp_mail (testing on local machine) but no mail is received. The php.ini has smtp_port = 25 set and the php mail() is working so far. how can I check if wp_mail is working what can ...
2
votes
3answers
17k views

Include HTML template file in wp_mail

I'm using wp_mail() to send an HTML email. But there's quite a lot of HTML code in the email, so rather than including all the code in my wp_mail() function, is it possible to have the code in a ...
2
votes
2answers
405 views

Email reply to multiple email addresses not working

I want that email reply should be received at multiple email address. But it is not working for me. I have tried different ways but none of these working for me. I am trying this header but it is only ...
2
votes
2answers
2k views

If new comment posted in custom post - send notification to custom email from custom field

I have custom post type "Art masters". Each post is master's profile. In their profiles isset custom fiels name "master_email". I need to send for master email notification every time if new ...
2
votes
1answer
233 views

Intercepting wp_mail() to view contents

I'm looking for a way to hook into the mail function before it sends so I can var_dump the output. Are there any action hooks with the mail message that I can hook into? I'm having trouble finding the ...
2
votes
1answer
4k views

How to use 'phpmailer_init' SMTP settings only on certain 'wp_mail' actions?

Is there a conditional check I can run for phpmailer_init or a wp_mail parameter that let's me apply my custom phpmailer_init SMTP settings only on specific wp_mail actions or does phpmailer_init ...
2
votes
1answer
8k views

wp_mail() is not working in localhost

I'm trying to test wp_mail() in my local. When I var dump wp_mail,I get Boolean false.This is my code $to = "abcd@gmail.com"; $subject = 'my subject'; $message = 'I would like to work ...
2
votes
1answer
3k views

Mail not sent when I set HTML headers

$subject = get_the_title(); $sender_name = get_bloginfo('name'); $blog_url = get_bloginfo('url'); $to = 'myemail@mydomainname.com'; $subject = 'the subject'; $message = 'hello'; $headers = '...
2
votes
1answer
381 views

Comment Email Notification for CPT Comments

I have a WordPress site where users can create new support tickets through submitting a form that posts to a Custom Post Type. I would now like WordPress to email users when there is a comment on the ...
2
votes
3answers
3k views

Error when requesting password reset email - wp authentication

I get the following error whenever a user tries to request a password reset email: The e-mail could not be sent. Possible reason: your host may have disabled the mail() function. As per ...
2
votes
1answer
529 views

Joining confirmation email

When a super admin adds a network user to a blog via wp-admin/user-new.php where does that confirmation email come from? How do I change? It says incorrectly comes from Wordpress@example.com ...
2
votes
1answer
110 views

How to setup SMTP for only one specific wp_mail()

I just want to setup SMTP for a specific instance of wp_mail(). I have tested plugins like "Easy WP SMTP" and also checked how to set up SMTP manually but all these apply to the entire site and then ...
2
votes
1answer
6k views

How to create a CSV on the fly and send as an attachment using wp_mail?

I'm trying to create a CSV file from a form submission and send that file automatically by email to a specific user. The email itself is sending fine, but I can't get the attachment to go through. Is ...
2
votes
2answers
17k views

wp_mail() is not working on server

I am breaking my head from last 1 hour but not getting any idea that what's going wrong with my code... I am developing my own plugin and I am using wp_mail() function for sending mail in that but it'...
2
votes
2answers
375 views

How to use wp_mail in CPT page

I have a CPT and inside the CPT I have a contact form. The contact form directly sends to WordPress dashboard, Now I'm trying to implement when a user submits the contact form they will receive a "...