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 SMTP plugin. move_uploaded_file($_FILES["cv"]["tmp_name"],WP_CONTENT_DIR .'/uploads/CV/'.basename($_FILES['cv']['name'])); move_uploaded_file($_FILES["lm"]["tmp_name"],WP_CONTENT_DIR .'/uploads/lm/'.basename($_FILES['lm']['name'])); $attachments = array( WP_CONTENT_DIR ."/uploads/CV/".$_FILES["cv"]["name"], WP_CONTENT_DIR ."/uploads/lm/".$_FILES["lm"]["name"] ); this is the code I use for storeing and reaching the attachments and simpli useing the wp_mail function to send it like this: $sent=wp_mail($s, $subject, $message, $headers,$attachments); On …
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 that I found on github that I've included inside my plugin code. The script works well and I can obtain a valid output. The problem is I can't figure out how to generate the ics file and attach it to an email using the wp_mail …
I have set up SMTL like this, add_action( "phpmailer_init", "send_smtp_email" ); function send_smtp_email( $phpmailer ) { ini_set("sendmail_from","[email protected]"); ini_set("sendmail_path","[email protected]"); // Define that we are sending with SMTP $phpmailer->isSMTP(); // The hostname of the mail server $phpmailer->Host = "localhost"; // Use SMTP authentication (true|false) $phpmailer->SMTPAuth = false; // SMTP port number - likely to be 25, 465 or 587 $phpmailer->Port = "25"; // Encryption system to use - ssl or tls $phpmailer->SMTPSecure = "tls"; $phpmailer->From = "[email protected]"; $phpmailer->FromName = "XYZ"; } and …
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 add_filter( 'wp_mail', function( $args ) { $args['message'] = 'Filtered text here'; return $args; }); But how can I only do the latter conditionally? I only want to filter the message when the content type == text/plain. I'm guessing there is a super-simple solution to this, but I haven't worked it out yet.
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, send an email to each of the selected users. /** * Send users a notification of new grower posts */ function notify_growers($post) { // Only notify for grower posts if ( $post->post_type != 'grower_posts' ) return; $post_id = $post->ID; // ...run code once if …
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($recipient, $subject, $body, $headers, $filename); Problem is the email never gets sent out, and any code after the wp_mail call never gets parsed, including a debug statement to dump out the value of $status_wpmail. The jqXHR response sent back to the page reports 'success' however. …
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 WordPress functions or actions. I have checked everything, including using SMTP mail. SMTP mail works same as mail() function and it doesn't send in AJAX mode. This is my functions.php file content: add_action( 'phpmailer_init', 'wpse8170_phpmailer_init' ); function wpse8170_phpmailer_init( PHPMailer $phpmailer ) { $phpmailer->Host = 'godadysmtpsampledomain.secureserver.net'; …
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 the pdf and output it as a string. // Close and output PDF document // This method has several options, check the source code documentation for more information. echo $pdf->Output('S'); The problem is to get this file as an …
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?
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 screenshot. The problem is that when clicking this button Wordpress redirects to the default backend posts list page (https://mysite.test/wp-admin/edit.php). I am making use of the do_action( "admin_post_{$action}" ) hook. When I inspect the page I see Wordpress has removed the tags. …
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','disabling_emails', 10,1); function disabling_emails( $args ){ unset ( $args['to'] ); return $args; }
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, but I cannot access them via the get_user_meta() function. I tried to debug this in front-page and using this get_user_meta() function gets me my custom fields, but in functions.php in my custom function, fields are missing and I get only few fields: (nickname,first_name,last_name,description,rich_editing,syntax_highlighting,comment_shortcuts,admin_color,use_ssl,show_admin_bar_front,locale,wp_capabilities,wp_user_level) add_action( 'user_register', 'so27450945_user_register', …
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 replying to the last email address. $to = "[email protected]"; $subject = "my email subject"; $message = "my email message"; $headers = array(); $headers []= "MIME-Version: 1.0\r\n"; $headers []= "Content-Type: text/html; charset=UTF-8\r\n"; $headers []= "Reply-To: <" . $EmailAddress1 . "> <" …
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, Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque tempus, dui eget luctus accumsan, turpis orci malesuada turpis, eget volutpat ante velit a quam.'; $admin_email = 'Hi Admin, Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque tempus, dui eget luctus accumsan, turpis orci malesuada turpis, eget volutpat ante velit a quam.'; $send_email = array( array( 'to' => …
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 customer but its works with single customer mail. here its my code <form class="formpopup" action="#" method="post"> <div> <label>To</label><input id="customer_to_mail" type="text" class="modalform" style="width: 70%;" value="" name="customer_to_mail" required></div><br> <div><label>Subject</label><input class="modalform" style="width: 70%;" type="text" name="customer_subject" required></div><br> <div class="descr"><label>Description</label><textarea class="modalform" style="width: 70%; height: 150px;" name="customer_description" required></textarea></div><br> <input style="margin: 20px auto; …
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 written a function in my multisite theme's function file to send some notifications to the multisite users. $headers[] = 'Content-Type: text/html; charset=UTF-8'; wp_mail('[email protected]', 'Test','Test', $headers); It send the mails as desired when on the main domain, but it does not send any mails when used in subdomain function files. For example, [email protected] is a registered user …
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 want them to get this activation email. Right now someone with the role "Employee" is getting two emails, the one I want and the extra activation one. Is there a way to deactivate the activation email for a specific user role? Thanks in advance!