Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wp_mail_from* filters are ignored #48

Open
markdwhite opened this issue May 15, 2019 · 2 comments
Open

wp_mail_from* filters are ignored #48

markdwhite opened this issue May 15, 2019 · 2 comments
Labels

Comments

@markdwhite
Copy link

It looks like only the From headers are used to override whatever is set in postmark_settings, and that wp_mail_from and wp_mail_from_name are ignored. Is this correct?

This would suggest that we need to append to a From header in some way when we are using Postmark with a plugin that adds filters for wp_mail_from and from_name.

Does this sound about right?

@pgraham3
Copy link
Contributor

Hi @markdwhite,

That is correct - as of right now wp_mail_from and wp_mail_from_name would be ignored with the wp_mail override we do. I can't speak to why that decision was made, as I wasn't involved in the project at the time.

I am hesitant to modify this behavior in case it has some unintended side effects for long time users of the plugin.

Would something like this be what is required to support using those filters with the Postmark for WordPress plugin?

@markdwhite
Copy link
Author

markdwhite commented May 16, 2019

@pgraham3

I totally understand about the need to maintain backwards compatibility. So it probably depends what order of precedence is best for correctly identifying $from.

The example code seems to be allowing the substitution of either/or wp_mail_from and wp_mail_from_name which requires the deconstruction of $from from the header. It might be reasonable to assume that the existence of a wp_mail_from allows for inclusion of wp_mail_from_name, otherwise $from from the header is used and wp_mail_from_name is discarded. So all that might be needed is:

$from = $recognized_headers['From'];

$from_email = apply_filters( 'wp_mail_from', $from_email );
if ( !empty( $from_email ) ) {
    $from = "<${from_email}>";
    $from_name = apply_filters( 'wp_mail_from_name', $from_name );
    if (!empty($from_name)) {
        $from = "${from_name} ${from}";
    }
}

And am I right in thinking that Postmark API will swap in the correct sender name from a Sender Signature if the sender email matches a signature? If so, we gain nothing by prepending the $from_name as it will be overwritten. I think I tested it this way, but could be wrong...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants