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
2 votes
2 answers
3k 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 ...
3 votes
1 answer
2k 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 ...
0 votes
2 answers
2k views

Email always ends up in spam

I created a function which I use to send an email when a specific button is pressed. This works great, except that it always ends up in spam instead of the inbox. This is the function: function ...
2 votes
2 answers
2k views

Processing a subscription form with POST method?

I am trying to integrate a ‘subscribe to newsletter’ feature on my wordpress blog Users just need to enter their name and email address, hit subscribe. This is then supposed to send me an email and I ...
0 votes
2 answers
1k views

wp_mail doen't send mails whit attachment

On my site I hava two forms witch send email. The one whit no attachment needed is sent correnctly, but the other ony witch has an attachment does not get sent. I am using SMTP config whit Postman ...
0 votes
1 answer
2k 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
1 answer
1k views

How to send email with wp_mail() with from email taken from contact form instead of the host?

I have set up SMTL like this, add_action( "phpmailer_init", "send_smtp_email" ); function send_smtp_email( $phpmailer ) { ini_set("sendmail_from","xyz@gmail.com"); ini_set("sendmail_path","xyz@gmail....
0 votes
1 answer
903 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 ...
0 votes
2 answers
1k 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', '...
2 votes
2 answers
3k views

Send specific users an email when posts are published

I've got the following code, which is supposed to run when a new post is published for the first time, check if a custom field 'specific_users' has data (this uses Advanced Custom Fields), and if so, ...
1 vote
1 answer
615 views

wp_mail() inside AJAX handler never returns

We have an AJAX handler called by jQuery.ajax() that takes a document stored on the server and mails it to the user. At the bottom there is a call to wp_mail like so: $status_wpmail = wp_mail($...
0 votes
1 answer
671 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
0 answers
5 views

Get page permalink in contact form

<?php function leverage_handle_ajax_request() { if ( ! empty( $_POST ) ) { require_once( plugin_dir_path( __FILE__ ) . 'recaptcha.php' ); if ( isset( $_POST['section'] ) &...
0 votes
3 answers
2k views

wp_mail() function doesn't send email in Ajax mode

When I use the wp_mail() or mail() function in AJAX, the function doesn't work and doesn't send email. When I use these functions simply in my functions.php file it works fine. It's not related to ...
1 vote
3 answers
2k 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 ...
23 votes
3 answers
52k views

How to set SMTP 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?
1 vote
1 answer
30 views

Send email button in custom post type backend

I've added a button in the backend of my custom post type editor. I want to send an email using wp_mail() when admin user click a button. I've added this custom form and button to a meta box. See ...
0 votes
1 answer
35 views

How to disable wp_mail for all users except for admins?

I am using the following code to disable wp_mail however how do I disable it only for non-admins. Any user with admin privileges should still receive their emails. add_filter('wp_mail','...
0 votes
1 answer
2k views

Custom user registration fields in user_register hook

I am trying to send an email to administrator with user_register action hook and wp_mail() function when a new user registers. I created some custom registration fields and I want send them via e-mail,...
3 votes
3 answers
969 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
1 answer
1k views

wp_mail send multiple emails in a loop

I'm very confused with wp_mail(). Here my code. function email_notification_for_admin_and_customer( $order_data ) { $subject_email = 'Subject LOREM IPSUM'; $customer_email = 'Hi Customer, ...
1 vote
0 answers
27 views

How to send bulk messages using wp mail function?

I was working in custom plugin development. I have created customer table in woocommerce and create form to reminder customer for new offers. I am using wp mail function to send multiple email to ...
1 vote
1 answer
2k views

wp_mail() not sending email in multisite subdomain

I have a multisite enabled WordPress configuration. My main domain is like http://www.example.com, with several subdomains like http://test1.example.com, http://test2.example.com, and so on. I have ...
0 votes
1 answer
73 views

How to disable activation email to specific user role?

I'm using Ultimate Member to manage my user roles. I have the Activation Emails active and it sends to new subscribers as expected. But when a user with role "Employee" subscribes, I don't ...
0 votes
1 answer
1k views

Send email daily using `wp_mail`

I want to send email daily 12:54pm using wp_mail function, but it send mail continuously. Plz suggest what is wrong? <?php $timeg = date( 'g:ia', current_time( 'timestamp', 0 )); $timem = '12:...
0 votes
1 answer
24 views

wp_mail Allow Remote Attachments from CDN

I came across a problem with WP_Mail for sending form submissions with file attachments. Our site uses a CDN, so everything uploaded to the site, whether images and media by site builders or documents ...
0 votes
0 answers
63 views

Using wp_mail to send email?

I have certain instances where I want to send emails to both user and admin accordingly using wp_mail. The first instance is when a new user is created. The following code is used to create users: //...
0 votes
1 answer
593 views

wp_mail sends email twice inside function updated_postmeta

I made a custom function so when postmeta updated to a specific value I send custom email use wp_mail(). Email sends successfully, but it creates two at the same time. Here my code: function ...
0 votes
1 answer
15 views

Email alert with wp_cron and wp_mail if new data (external API) - Pseudo code

I would like to check twice daily if there is some new data published and send me an email if this is the case. In pseudo code here what I thought I could do: Get new list of movies (external API ...
0 votes
0 answers
21 views

How to properly use wp_mail() in my own plugin?

I have advanced work on my Wordpress plugin, now I need to add wp_mail(). I read this tutorial https://www.sitepoint.com/build-your-own-wordpress-contact-form-plugin-in-5-minutes/ and this tutorial ...
43 votes
9 answers
25k 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 ...
0 votes
0 answers
24 views

Using SMTP Function instead of Plugin (functions.php)

While this works just fine, I am concerned that it poses a security threat. Does it? add_action( 'phpmailer_init', 'send_email_using_smtp' ); function bsend_email_using_smtp( $phpmailer ) { $phpmailer-...
2 votes
2 answers
539 views

wp_mail not running inside Cron

The wp_mail() function is not running when scheduled in a cron function. I have added the following function: add_filter( 'cron_schedules', 'isa_add_every_one_minutes' ); function ...
0 votes
0 answers
20 views

Wordpress doesn't work properly with non standard domain names - PHPMailer fails when initialising

While debugging Wordpress password reset functionality in a test environment on a local macbook, Wordpress would get stuck when sending emails. Basically, before sending emails, a check is done in wp-...
0 votes
1 answer
61 views

Using WP_Mail on MacOS 12 (Monterey - M1) [closed]

On a brand new Macbook running Monterey (M1), as PHP was removed by Apple on OS 12, I have removed all "AMP" preinstalled by Apple and installed HomeBrew "AMP" (with PHP 7.4), ...
0 votes
0 answers
20 views

Wordpress woocommerce new order email not working

I am using woocommerce thank you page hook to trigger functionality for a custom task and in that function I have used 2 wp_mail() methods to send custom mails. This is all working good, However when ...
0 votes
1 answer
33 views

Add Server Side validation in Ajax mail form

I'm building a form that takes fields values and send them via wp_mail to the post author. It works, but I want to add a server side validation to improve security. I don't know where to add my ...
0 votes
0 answers
32 views

How to send automatic response after form submission without plugin

I create an ajax form and I well received the email. Now, I just want to do like CF7, send an automatic response to the sender to notify him that I well received the form. Which function used or which ...
1 vote
2 answers
2k views

Send notification to the admin when new custom post is submitted

I have a cpt called "auto" and i make a frontend form to create new post with "pending" status. After the post submission i would receive an email with a notification of the new post. function ...
0 votes
0 answers
66 views

comment_post (if comment is approved OR $comment_approved === 1) not working?

I am working on a code through which I can send emails to the user when his/her comments get approved. then I get to know about comment_post. but it is not working. comment_post is working for the ...
0 votes
0 answers
33 views

Using two different outgoing email services, can it be done?

Is there any way I can make Wordpress use more than one outgoing email service, and have all emails from a particular plug-in (such as WooCommerce, for example) use one system, and everything else on ...
0 votes
0 answers
103 views

How can admins to be notified of changes when users change their WP profiles?

I'm using the code below that I found in another thread. When a user makes changes to their profile, this snippet sends an email notification that something has been changed. I'd like to amend this so ...
0 votes
1 answer
750 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
1 answer
38 views

wp-mail attachment is not sent for no reason?

I'm using wp-mail to send an image. The problem is that it does not attach the image ! Here is $attachment_img string : https://example.com/wp-content/uploads/2021/10/example.jpg So the path is ...
5 votes
4 answers
4k 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
0 answers
46 views

Sending email through Ajax without page refresh hangs on admin_ajax.php

I have this test page on a website - https://piclits.com/test-slideshow/ It displays a bunch of images/PICLITS and grabs them randomly from a folder 12 at a time into a slideshow. I want to email the ...
0 votes
1 answer
3k views

Warning: include(): https:// wrapper is disabled in the server configuration by allow_url_include=0

I am trying to make a email template for my wordpress site. So I tried to include the HTML mockup that was given to me, but instead of putting it directly on the same file, I would like to include() ...
1 vote
1 answer
458 views

how to send an email with wp_mail with an image on the email body

I can send emails using wp_mail, however any image on the body will not be display on the email received. Is there any way of sending an image within the message this is the code used to send emails: $...
0 votes
0 answers
145 views

wp_mail email sends twice

I created a button on a User's page. It sends an alert email to the admin. It was sending the same email to me 5 times... but I have made some changes. Now it is sending the same email twice. I have ...
2 votes
2 answers
12k 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 ...

1
2 3 4 5
7