Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

Questions tagged [wp-mail]

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

0
votes
1answer
22 views

Adding a button to send email to a user in WordPress Admin Users table

I would like to add a button for each user in the user page in wordpress admin area that will send an email to that specific user when clicked. The code adds the action link "Send Verification Email" ...
0
votes
1answer
25 views

wp_mail function ends up in spam?

I created a wp_mail function which I use to send an email when a specific button is pressed. This works great, except that it will always end up in the spam instead of the inbox. This is the function:...
0
votes
1answer
31 views

Generate and send ICS file through WordPress

I'm writing a custom plugin for reservations. I need to generate an .ics file that needs to be sent to a predefined email address. I've tried some library like ZContent iCalendar and a PHP script ...
0
votes
1answer
24 views

phpmailer_init ignored on REST calls

For testing purposes I've set up a mailtrap (dummy SMTP server) to catch all mail in and out of my local site. To do so, I hooked its configuration in the theme's functions.php like this: function ...
0
votes
2answers
16 views

add_action( 'publish_pelicula', 'post_published_notification', 10, 2 ); does not trigger propperly

I'm trying to send an Email before a post "type:pelicula" is submited, but it does not enter to the function post_published_notification, here is the code: <?php /** * Plugin Name: VRlife Alertas ...
0
votes
1answer
36 views

WordPress wp_mail function not working, returns false

I am sending email with the wp_mail() function but it is not working. It is returning false. Also it is not giving any error in the server log. This is my code: $mailResult = false; ...
0
votes
1answer
24 views

wp_mail doesn't work when logged in?

I am having trouble with a wp_mail function I created, which sends an email when I press a button. It does work great when you do this logged out. But as soon as I am logged in it stops working. It is ...
1
vote
1answer
49 views

Redirect to another page after submission using wp_mail

I'm trying to redirect to user to another page after the form has been submitted using wp_mail. // Hooking up our functions to WordPress filters add_filter( 'wp_mail_from', 'wpb_sender_email' ); ...
1
vote
0answers
20 views

Multisite not using subdomains as hostname in from address when sending emails

I have a Multisite installation where I'm facing somekind of bug relating the hostname used when WordPress sends emails (I've test it with WordPress admin emails and Contact Form 7). For example, if ...
0
votes
1answer
48 views

Why do WordPress emails to multiple recipients include \n in the list

All emails from WordPress are not going to multiple emails for some reason. They have been entered in separated by commas. However when I check the mail log the recipient list is like this: ...
0
votes
1answer
26 views

Premature end of script headers: wp-mail.php?

I haven't edited wp-mail.php at all. I'm using the default WordPress file. I'm trying the whole submit post by email function that we know in settings (using gmail and pop3, if that's relevant). I ...
0
votes
1answer
43 views

Can I use shortcodes in mail body

Can I put any type of custom shortcode for some content in mail body? eg: $to = "test@test.com"; $subject = "Test Email"; $packages = do_shortcode('[test id="0000"]'); $message = $packages; // ...
0
votes
1answer
51 views

Attach a external file as attachement using wp_mail

I am trying to attach external file link (doc file) as attachment but not able to so .. no attachment is being attached.. $email_attachment = array('https://ucarecdn.com/8aa17c61-bd55-4311-8b45-...
0
votes
0answers
18 views

Allow user to add the php code in wp_mail()

I have an email triggered like below. I want a user to be able to customize the content. I want to provide the user to be able to put esc_html($user->display_name) somehow may some thing with a ...
0
votes
2answers
152 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 "...
1
vote
1answer
92 views

On form submission how to send 2 email to different users

I have created a custom php form and on its submission email is sent to user but i want to send email to admin as well to keep admin up-to-date about form submissions on website using wp_mail. <...
0
votes
1answer
143 views

wp_mail not sending attachment

My mail function is as follows add_action('wp_ajax_order_processing', 'order_processing'); function order_processing(){ include 'mail-translations.php'; require_once( ABSPATH . 'wp-admin/includes/...
1
vote
2answers
92 views

How to do string attachment with wp_mail

I'm using a gift card plugin for my woocommerce shop and I would like to add a generated pdf file to allow customers to download the gift card as a pdf. The idea is to use TCpdf or Fpdf to generate ...
0
votes
1answer
66 views

Retrive acf fields in publish_post action for wp_mail

I have a custom post type called "Envios". In it I've created a Custom Meta box which allows to select users and posts. When one of this custom post types is published it sends an email to the ...
0
votes
1answer
40 views

get_post_meta not working with variable as a post_id for dynamically get the postid

I would like to use the get_post_meta to pull a value from a CPT dynamically and then send a email. The problem is that the get_post_meta($post->ID, ... part of the code does not pull the email ...
2
votes
2answers
44 views

How to set up gmail SMTP in Wordpress

I'm trying to set up an smtp gmail server to send emails from my wordpress site. This is what I've got in my wp-config.php: define( 'SMTP_USER', 'myaddress@gmail.com' ); // Username to use for ...
0
votes
1answer
45 views

How can I configure an SMTP Server?

I'm trying to follow the instructions here: https://gist.github.com/butlerblog/7e4dbafcbc61b15505ee8ca90510f1e7 But I'm getting confused. I'm not sure what arguments to pass where. Here is what I ...
0
votes
2answers
20 views

Include content post Wordpress - Email notification

I have this mail notification for new post. All the new post contain arround 100 words and no pictures, so I would like to include in the notification the post content and if is possible, the number ...
0
votes
1answer
30 views

Different query result on local and server

I create plugin to sent list post yesterday and today via wp_mail() to member from WordPress multisite, at localhost the result of list post delivery successful. But at live server, the result of ...
0
votes
1answer
12 views

Email me when front posting or update post

In my site, users can submit post at front-end. And I want to be informed by email when users submit or update post. I searched some codes about this. I'll use wp_main function. function ...
1
vote
0answers
24 views

User invite email not delivered - related to subdomain?

I have a problem where, on a new install of WordPress, I want to add a new user, but the user is not receiving the email with the confirmation link. I've done some research and understand that this ...
1
vote
2answers
153 views

How to restrict sending email twice in wp_mail

I have created an Add / Remove Dynamic input fields. I am using wp_mail(); to send mails. I have restricted the first user from receiving mail. I want to send mail to other users. Everything is ...
0
votes
2answers
47 views

restrict current user from receiving email using wp_mail

I have create a code through which current user can add other users in his project. These users are only shown on the project page. They will not have any right to modify the project. Once these ...
1
vote
2answers
35 views

How to Mail User after inserting Username in database in WordPress

I have following piece of code, which inserts usernames and other details of users in the database. After inserting the usernames I want to email them using wp_mail();. I am unable to do so. How to do....
1
vote
2answers
315 views

Unable to prevent function using save_post firing twice

I am using save_post for a function to send an email when a post is updated by a user. This is firing twice and I am aware this is due to the post revisions and autosaves. I have tried to prevent ...
0
votes
0answers
199 views

Send data url string as an attachment in wp_email

We have a data url string of png image file here and we can pass it via ajax to a php function via button click. Now is it possible to convert it back as image file and add as an attachment to ...
0
votes
1answer
58 views

How to send the checkbox value to email

HTML of form is given below <?php for($i=$start;$i < $end ;++$i) { if($emails[$i]!=""){ $userId=$emails[$i]['...
0
votes
1answer
282 views

Multisite - SMTP not working on other network sites

I have WP Mail SMTP plugin setup on multisite, the email is sent from the parent site successfully, however, when trying the same or another email from the child site gives me following error: ...
1
vote
1answer
330 views

Email Attachment from Form Submit

I am currently encountering a very strange problem. With the help of two existing wordpress functions (wp_handle_upload and wp_mail) and a form that uses some custom ajax functionality to process my ...
0
votes
1answer
15 views

wp_mail doesnt work inside transition_comment_status

i need to send a notification for a visitor that got hes comment published. So, i created this function /************************************************* ** COMMENT APPROVED HOOK *******************...
2
votes
1answer
54 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 ...
0
votes
1answer
39 views

Sending HTML email containing custom fields to site users from WordPress

I am looking to send out emails to users in my WordPress site/system. I want to have emails that say something like: You have X credits remaining to fulfill Y. Your deadline is Z. X,Y,Z would be ...
0
votes
2answers
246 views

How dynamically change wp_mail behaviour, sending html or plain text based on conditions?

I have several forms that send mails. Some of the mails should be sent as html, others as plain text. Right now I set the html option like this: add_action( 'phpmailer_init', 'mailer_config', 10, 1); ...
0
votes
0answers
309 views

How to attach file with wp_mail(). [duplicate]

I have a custom form by which i try to send email with a file attachment but attachment not send. I don't know well how it works. When i pass $attachment variable, email not working . Email is working ...
0
votes
1answer
65 views

Prevent sending emails on user creation in OOP context?

I need to block any user creation email on the site, and I tried overriding any pluggable function that is responsible for mail sending. The only thing that works is $this->loader->add_filter( '...
0
votes
1answer
333 views

wp_mail() not sending emails with ajax

I am using wp_mail() to send email using ajax. My mail code is as follow. add_action( 'wp_ajax_send_confirmation_email', 'wpse_sendmail' ); add_action( 'wp_ajax_nopriv_send_confirmation_email', '...
0
votes
1answer
152 views

wp_mail send email twice inside function updated_postmeta

I make a custom function so when postmeta updated to specific value i send custom email use wp_mail. email successfully send but it create twice at same time. here my code function ...
1
vote
0answers
392 views

Using wp_mail() function outside of Wordpress and through PHP CLI

I am developing a simple PHP script that will send emails to users. The script is located outside of WP directory and its run through a cronjob. Example cron job call: php /PATH/TO/SCIRPT/script.php &...
1
vote
1answer
51 views

Wordpress is executing URL in code when called via wp_mail()

I have written a custom plugin (that creates a custom post type) and allows any user to submit a new post from a form on my website. To prevent bots, I have setup an e-mail confirmation code which ...
0
votes
1answer
134 views

Filter wp_mail based on content type

I can current filter the content type of the wp_mail function: add_filter( 'wp_mail_content_type', function( $content_type ) { return 'text/html'; }); And I can filter the message content ...
1
vote
2answers
3k views

How to add line breaks to $email['body'] when using auto_core_update_email hook

I am using the auto_core_update_email hook to modify the auto update email sent by WordPress. However I cannot figure out how to add line breaks to the email body. Here's my code: function ...
2
votes
1answer
272 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 ...
0
votes
0answers
92 views

wordpress wp mail not changing sender mail

im using wp_mail to create contact page my email var is $subject = 'hello'; $html = 'message here'; $admin_email = 'admin@yahoo.com'; $email = 'email@yahoo.com'; $headers = array('Content-Type: text/...
0
votes
1answer
240 views

Repeated headers in wp_mail

I am passing a custom header multiple times, for tagging reasons, to wp_mail(), but only the last instance of the header is actually getting sent. It appears that wp_mail() is filtering the custom ...
0
votes
1answer
549 views

Pass return-path additional parameter in wp_mail

Our server is currently automatically setting the return path as {serverusername@serverhostname.tld}. When sending an email in PHP, I can override this by doing the following: $return = '<bounce@...