• Resolved Garrett Hyder

    (@garrett-eclipse)


    Hello,

    I noticed with my Woocommerce and other emails generated by Plugins or my theme which are of the html context type have their Name/Email replaced when they shouldn’t be affected by WP Better Emails.

    These sender options should only come into effect on plain text emails as they’re the only ones to be picked up by the plugin.

    Thanks

    https://www.ads-software.com/plugins/wp-better-emails/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Garrett Hyder

    (@garrett-eclipse)

    Resolved this myself in fork;
    https://github.com/garrett-eclipse/wp-better-emails

    Just added remove_filters to the set_content_type method so the Sender Options only affect plain text emails.

    /**
    		 * Always set content type to HTML
    		 *
    		 * @since 0.1
    		 * @param string $content_type
    		 * @return string $content_type
    		 */
    		function set_content_type( $content_type ) {
    			// Only convert if the message is text/plain and the template is ok
    			if ( $content_type == 'text/plain' && $this->check_template() === true ) {
    				$this->send_as_html = true;
    				return $content_type = 'text/html';
    			} else {
    				$this->send_as_html = false;
    				remove_filter( 'wp_mail_from_name',    array( $this, 'set_from_name' ) );
    				remove_filter( 'wp_mail_from',         array( $this, 'set_from_email' ) );
    			}
    			return $content_type;
    		}
    Plugin Author Nicolas Lemoine

    (@nlemoine)

    As answered on Github, this change may fit in your case but it does not make sense at all.

    The problem with sender name and adresse is that it’s not easy to guess if the email is a default/system one (lost password, etc.) or a notification with custom parameters (comment notification, etc.).

    The only way I think about is checking the “from” email address against the default one: [email protected] and only apply changes if the default one is met.

    Thread Starter Garrett Hyder

    (@garrett-eclipse)

    Thanks @hellonico,

    I checked out your latest approach in 0.3 and believe that hits the nail on the head for me as I didn’t want the from information replaced on the emails generated by wordpress and other plugins. Turns out they’re all using non-default emails which coincides with your update and means these settings won’t override this.

    So please close out my git ticket, etc. as this approach resolves the issues I was experiencing.

    Appreciated

    Thread Starter Garrett Hyder

    (@garrett-eclipse)

    Another thought on this.
    Currently with 0.3 you’re doing a check for if it’s a default email address.
    Would be an idea to provide an override all checkbox with those options which if toggled with apply the filters always rather than just at [email protected]
    Thanks

    Plugin Author Nicolas Lemoine

    (@nlemoine)

    Hi Garrett,

    Thanks for the suggestion, I thought about this checkbox too. I’ll do it in the next release.

    Cheers.

    Thread Starter Garrett Hyder

    (@garrett-eclipse)

    Thanks @hellonico, looking forward to it. I appreciate all your support. Cheers

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Providing Name/Email in Sender Options overrides on HTML Emails’ is closed to new replies.