summaryrefslogtreecommitdiff
path: root/Postman/PostmanWpMail.php
diff options
context:
space:
mode:
Diffstat (limited to 'Postman/PostmanWpMail.php')
-rw-r--r--Postman/PostmanWpMail.php32
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
*