Skip to content

Commit

Permalink
Support wp_mail_from hook to set From address.
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Graham committed Mar 22, 2021
1 parent fad8e4a commit d11ddcc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
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

0 comments on commit d11ddcc

Please sign in to comment.