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

Support wp_mail_from hook to set From address. #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ The plugin supports using the `wp_mail_from_name` filter for manually setting a
[Can I use the Postmark for WordPress plugin with Divi contact forms?](https://postmarkapp.com/support/article/1128-can-i-use-the-postmark-for-wordpress-plugin-with-divi-contact-forms)

## Changelog
### v.1.14.0
* Support using wp_mail_from hook to set From address. Overriding From address via header still has priority.

### v1.13.4
* Handle special characters in site titles for test emails.
Expand Down
4 changes: 2 additions & 2 deletions postmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Postmark (Official)
* Plugin URI: https://postmarkapp.com/
* Description: Overrides wp_mail to send emails through Postmark
* Version: 1.13.4
* Version: 1.14.0
* Author: Andrew Yates & Matt Gibbs
*/

Expand Down Expand Up @@ -31,7 +31,7 @@ class Postmark_Mail {
*/
public function __construct() {
if ( ! defined( 'POSTMARK_VERSION' ) ) {
define( 'POSTMARK_VERSION', '1.13.4' );
define( 'POSTMARK_VERSION', '1.14.0' );
}

if ( ! defined( 'POSTMARK_DIR' ) ) {
Expand Down
2 changes: 2 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ The plugin supports using the `wp_mail_from_name` filter for manually setting a
1. Postmark WP Plugin Settings screen.

== Changelog ==
= v.1.14.0 =
* Support using wp_mail_from hook to set From address. Overriding From address via header still has priority.

= v1.13.4 =
* Handle special characters in site titles for test emails.
Expand Down
10 changes: 9 additions & 1 deletion wp-mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,17 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
==================================================
*/

// Allow overriding the From address when specified in the headers.
// Default From address specified in plugin settings.
$from = $settings['sender_address'];

// Allow overriding the From address when specified via wp_mail_from hook.
$from_email = apply_filters( 'wp_mail_from', $from_email );

if ( isset( $from_email ) ) {
$from = $from_email;
}

// Allow overriding the From address when specified via header.
if ( isset( $recognized_headers['From'] ) ) {
$from = $recognized_headers['From'];
}
Expand Down