diff options
author | Yehuda Hassine <yehuda@myinbox.in> | 2019-04-19 01:22:45 +0300 |
---|---|---|
committer | Yehuda Hassine <yehuda@myinbox.in> | 2019-04-19 01:22:45 +0300 |
commit | dad9828e8c866e50d6e44aebd103f1ab97409a5b (patch) | |
tree | ecdc83e649fcafe5e6ed792317ef6760670d451b /Postman/PostmanWpMail.php | |
parent | 663b48bdb1ef0469b467fbf28f7074b13743234a (diff) | |
download | Post-SMTP-dad9828e8c866e50d6e44aebd103f1ab97409a5b.zip |
add message id + twitter widget
Diffstat (limited to 'Postman/PostmanWpMail.php')
-rw-r--r-- | Postman/PostmanWpMail.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Postman/PostmanWpMail.php b/Postman/PostmanWpMail.php index ab766f0..5228fdd 100644 --- a/Postman/PostmanWpMail.php +++ b/Postman/PostmanWpMail.php @@ -41,6 +41,9 @@ if ( ! class_exists( 'PostmanWpMail' ) ) { // initialize for sending $this->init(); + // Apply critical headers + $headers = $this->apply_default_headers( (array)$headers ); + // build the message $postmanMessage = $this->processWpMailCall( $to, $subject, $message, $headers, $attachments ); @@ -55,6 +58,35 @@ if ( ! class_exists( 'PostmanWpMail' ) ) { return $this->sendMessage( $postmanMessage, $log ); } + /** + * @param array $headers + * @return array $headers + */ + private function apply_default_headers( $headers ) { + + $headers[] = 'Message-ID: ' . $this->createMessageId(); + + return $headers; + } + + /** + * Creates the Message-ID + * + * @return string + */ + public function createMessageId() { + + $id = md5(uniqid(time())); + + if (isset($_SERVER["SERVER_NAME"])) { + $hostName = $_SERVER["SERVER_NAME"]; + } else { + $hostName = php_uname('n'); + } + + return $id . '@' . $hostName; + } + /** * Builds a PostmanMessage based on the WordPress wp_mail parameters * |