Wp_Mail and Contact Form 7

try this one add_filter(‘wp_mail_from’, ‘doEmailFilter’); add_filter(‘wp_mail_from_name’, ‘doEmailNameFilter’); function doEmailFilter($email_address){ if($email_address === “[email protected]”) return ‘[email protected]’; else return $email_address; } function doEmailNameFilter($email_from){ if($email_from === “WordPress”) return ‘MySite.com’; else return $email_from; } This checks if WP is going to send mail as a system (as wordpress@something) and if so, changes to your setting. Otherwise, is using inputs data … Read more

How to send language string in email message body

You have a typo in your code, the function is __() with two underscores. You will also need to configure the textdomain ‘text-domain’ and have a valid translation for the end users’ browser settings for it to not default to english. // use two underscores in the method $message = __(“Hello Admin,”,’text-domain’); // assuming this … Read more

How to send multiple email to different addresses

Ok even your question is difficult to read, here we go with I understand: If you want to send one message to multiple email address you have more than one options but lets see two most used: // FIRST // One message to many addresses, this one is simplest, but every person will see each … Read more

Prevent sending emails on user creation in OOP context?

send_password_change_email and send_email_change_email are the filters used for sending the user an email, if they change their password or an account has been created for them. It is not responsible for the “New user registration on your site” mail. The function that does this is wp_new_user_notification(), which is actually one of the pluggable functions. You … Read more

WordPress wp_mail function not working, returns false

Although wp_mail returns false on failure, it does also contain an action hook to allow you access to error information. If phpmailer fails to send, these lines run: /** * Fires after a phpmailerException is caught. * * @since 4.4.0 * * @param WP_Error $error A WP_Error object with the phpmailerException message, and an array … Read more

Sending a custom form data in email through WP Mail Function

I would suggest using AJAX for this. You could do something like this for the jQuery part: <script type=”text/javascript”> jQuery(document).ready(function($) { // Execute when user clicks on the “Submit” button $(‘#SUBMIT_BUTTON_ID’).on(‘click’, function(e) { e.preventDefault(); var email = $(‘input[name=email]’).val(); var firstname = $(‘input[name=firstname]’).val(); var familyname = $(‘input[name=familyname]’).val(); var other_names = $(‘input[name=other_names]’).val(); var dob_day = $(‘input[name=dob_day]’).val(); var … Read more

Sending mails with wp_mail() to multiple recipients using wp_cron and dynamic email body data

Here’s your problem: $body = file_get_contents( get_stylesheet_directory() . ‘/templates/email/event-creator-notification.php’); file_get_contents literally just gets the contents of that file. There’s no PHP execution. Instead, if you want to get the output of something as a variable, use output buffers, e.g. ob_start(); // everything echo’d after this gets put in the buffer get_template_part( ‘templates/email/event-creator-notification’ ); $body = … Read more

Notify users only on post publish

You could use the transition_post_status hook instead, as it already knows what the current and previous status of the post are. <?php add_action(‘transition_post_status’, ‘wpse_366380_email_on_publish’, 10, 3); function wpse_366380_email_on_publish( $new_status, $old_status, $post ) { // Only if this post was just published, and previously it was either // “auto-draft” (brand new) or “pending” (not yet published) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)