How to change the replyto/from email.

I know how to change the admin email etc for wordpress but I only want to change the reply to and from email for appointments+ plugin. Customers are replying to the conf/reminders and it's coming to me the admin rather than the dummy user/provider we are using for everything. I've searched and read through what I can find on here but I'm really hoping there is something that can be changed just for the plugin and not have to mess with the WP mail as we have many forms set up and I don't want to affect them.

Thank you!

  • Vaughan
    • Support/SLS MockingJay

    Hi Suzy,

    Hope you're well?

    The from address is usually the admin email address defined in your sites general settings, this is the address that wp_mail() function uses for it's from address.

    You can enhance wp mail functions with SMTP by using a plugin which will give you a lot more control over how emails are sent from your site.

    One of the following plugins should help.

    https://wordpress.org/plugins/wp-mail-bank/screenshots/

    https://wordpress.org/plugins/wp-mail-smtp/

    https://wordpress.org/plugins/easy-wp-smtp/

    https://wordpress.org/plugins/webriti-smtp-mail/

    Hope this helps

  • Suzy
    • Design Lord, Child of Thor

    Thank you for your reply @Vaughan but I won't mess with that area of the site to many things rely on it. I'd like to know if this is something changeable within appointments+. With our forms plugin we are able to specify a reply to from email and I'm hoping this is possible here.

  • Vaughan
    • Support/SLS MockingJay

    Hi,

    Ok, yes I understand now.

    You will need to use a filter for this to change the appointments+ email headers that are sent to wp_mail() function.

    So something like below in your theme functions.php

    add_filter( 'app_message_headers', 'app_custom_header' );
    function app_custom_header() {
             $admin_email = 'your_email@email.com';
    
    		$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    		$content_type = 'text/plain';
    		if (!(defined('APP_EMAIL_DROP_LEGACY_HEADERS') && APP_EMAIL_DROP_LEGACY_HEADERS)) {
    			$message_headers = "MIME-Version: 1.0\n" .
                        "From: {$blogname}" .
                        " <{$admin_email}>\n" .
                        "Reply-To: <" . $blogname . "> <" . $admin_email . ">\n" .
                        "Content-Type: {$content_type}; charset=\"" . get_option('blog_charset') . "\"\n";
    		} else {
    			$message_headers = "MIME-Version: 1.0\n" .
                    "Reply-To: <" . $blogname . "> <" . $admin_email . ">\n" .
    				"Content-Type: {$content_type}; charset=\"" . get_option('blog_charset') . "\"\n"
    			;
    			add_filter('wp_mail_from', create_function('', "return '{$admin_email}';"));
    			add_filter('wp_mail_from_name', create_function('', "return '{$blogname}';"));
    		}
    
            return $message_headers;
    }

    Then simply change this line and add your own email address that you wish to use.

    $admin_email = 'your_email@email.com';

    Hope this helps

  • Adam Czajczyk
    • Support Gorilla

    Hey Suzy,

    I hope you're well today and don't mind me jumping into a conversation :slight_smile:

    This will affect only Appointments+ emails. You can spot the "app_" prefix in the code that @Vaughan gave you. This prefix refers directly to the Appointments+ functions.

    I hope that helped!

    Cheers,
    Adam

  • Suzy
    • Design Lord, Child of Thor

    @Vaughan & @Adam Czajczyk
    So a little hiccup. The code worked perfectly for the reply to but the confirmation/reminder emails are showing all the html. I have that feature enabled in the add-on section. Is there a way to keep that feature and use the filter?

  • Vaughan
    • Support/SLS MockingJay

    Hi,

    Can you try this;

    add_filter( 'app_message_headers', 'app_custom_header' );
    function app_custom_header() {
             $admin_email = 'your_email@email.com';
    
    		$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    		$content_type = apply_filters('app-emails-content_type', 'text/plain');
    		if (!(defined('APP_EMAIL_DROP_LEGACY_HEADERS') && APP_EMAIL_DROP_LEGACY_HEADERS)) {
    			$message_headers = "MIME-Version: 1.0\n" .
                        "From: {$blogname}" .
                        " <{$admin_email}>\n" .
                        "Reply-To: <" . $blogname . "> <" . $admin_email . ">\n" .
                        "Content-Type: {$content_type}; charset=\"" . get_option('blog_charset') . "\"\n";
    		} else {
    			$message_headers = "MIME-Version: 1.0\n" .
                    "Reply-To: <" . $blogname . "> <" . $admin_email . ">\n" .
    				"Content-Type: {$content_type}; charset=\"" . get_option('blog_charset') . "\"\n"
    			;
    			add_filter('wp_mail_from', create_function('', "return '{$admin_email}';"));
    			add_filter('wp_mail_from_name', create_function('', "return '{$blogname}';"));
    		}
    
            return $message_headers;
    }

    Hope this helps

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.