Skip to content

Commit d11ddcc

Browse files
author
Patrick Graham
committed
Support wp_mail_from hook to set From address.
#48
1 parent fad8e4a commit d11ddcc

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ The plugin supports using the `wp_mail_from_name` filter for manually setting a
9292
[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)
9393

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

9698
### v1.13.4
9799
* Handle special characters in site titles for test emails.

postmark.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Postmark (Official)
44
* Plugin URI: https://postmarkapp.com/
55
* Description: Overrides wp_mail to send emails through Postmark
6-
* Version: 1.13.4
6+
* Version: 1.14.0
77
* Author: Andrew Yates & Matt Gibbs
88
*/
99

@@ -31,7 +31,7 @@ class Postmark_Mail {
3131
*/
3232
public function __construct() {
3333
if ( ! defined( 'POSTMARK_VERSION' ) ) {
34-
define( 'POSTMARK_VERSION', '1.13.4' );
34+
define( 'POSTMARK_VERSION', '1.14.0' );
3535
}
3636

3737
if ( ! defined( 'POSTMARK_DIR' ) ) {

readme.txt

+2
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ The plugin supports using the `wp_mail_from_name` filter for manually setting a
103103
1. Postmark WP Plugin Settings screen.
104104

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

107109
= v1.13.4 =
108110
* Handle special characters in site titles for test emails.

wp-mail.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,17 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
149149
==================================================
150150
*/
151151

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

155+
// Allow overriding the From address when specified via wp_mail_from hook.
156+
$from_email = apply_filters( 'wp_mail_from', $from_email );
157+
158+
if ( isset( $from_email ) ) {
159+
$from = $from_email;
160+
}
161+
162+
// Allow overriding the From address when specified via header.
155163
if ( isset( $recognized_headers['From'] ) ) {
156164
$from = $recognized_headers['From'];
157165
}

0 commit comments

Comments
 (0)