summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Postman/Postman-Mail/Zend-1.12.10/Mail.php4
-rw-r--r--Postman/PostmanLogMeta.php76
-rw-r--r--Postman/PostmanOptions.php3
-rw-r--r--Postman/PostmanUtils.php15
4 files changed, 91 insertions, 7 deletions
diff --git a/Postman/Postman-Mail/Zend-1.12.10/Mail.php b/Postman/Postman-Mail/Zend-1.12.10/Mail.php
index b2204f7..d597ea7 100644
--- a/Postman/Postman-Mail/Zend-1.12.10/Mail.php
+++ b/Postman/Postman-Mail/Zend-1.12.10/Mail.php
@@ -365,7 +365,7 @@ class Postman_Zend_Mail extends Postman_Zend_Mime_Message
}
$mp = new Postman_Zend_Mime_Part($txt);
- $mp->encoding = $encoding;
+ $mp->encoding = apply_filters( 'post_smtp_content_transfer_encoding', $encoding, Postman_Zend_Mime::TYPE_TEXT);
$mp->type = Postman_Zend_Mime::TYPE_TEXT;
$mp->disposition = Postman_Zend_Mime::DISPOSITION_INLINE;
$mp->charset = $charset;
@@ -406,7 +406,7 @@ class Postman_Zend_Mail extends Postman_Zend_Mime_Message
}
$mp = new Postman_Zend_Mime_Part($html);
- $mp->encoding = $encoding;
+ $mp->encoding = apply_filters( 'post_smtp_content_transfer_encoding', $encoding, Postman_Zend_Mime::TYPE_HTML );
$mp->type = Postman_Zend_Mime::TYPE_HTML;
$mp->disposition = Postman_Zend_Mime::DISPOSITION_INLINE;
$mp->charset = $charset;
diff --git a/Postman/PostmanLogMeta.php b/Postman/PostmanLogMeta.php
new file mode 100644
index 0000000..8a05b3a
--- /dev/null
+++ b/Postman/PostmanLogMeta.php
@@ -0,0 +1,76 @@
+<?php
+
+class PostmanLogMeta {
+
+ public $log_meta_type = 'post_smtp_logs';
+
+ private $meta_fields = array(
+ 'success',
+ 'from_header',
+ 'to_header',
+ 'cc_header',
+ 'bcc_header',
+ 'reply_to_header',
+ 'transport_uri',
+ 'original_to',
+ 'original_subject',
+ 'original_message',
+ 'original_headers',
+ 'session_transcript'
+ );
+
+ function install_table() {
+
+ global $wpdb;
+
+ $sql = "CREATE TABLE `{$this->log_meta_type}_{$wpdb->prefix}_{$this->log_meta_type}` (

+ `meta_id` bigint(20) NOT NULL AUTO_INCREMENT,

+ `post_smtp_id` bigint(20) NOT NULL DEFAULT '0',

+ `meta_key` varchar(255) DEFAULT NULL,
 `meta_value` longtext,

+ PRIMARY KEY (`meta_id`),

+ KEY `post_smtp_id` (`post_smtp_id`),

+ KEY `meta_key` (`meta_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
";
+
+ dbDelta( $sql );
+ }
+
+ function migrate_data() {
+ $args = array(
+ 'post_type' => 'postman_sent_mail',
+ 'posts_per_page' => -1,
+ );
+
+ $logs = new WP_Query($args);
+
+ $failed_records = 0;
+ foreach ( $logs->posts as $log ) {
+
+ foreach ( $this->meta_fields as $key ) {
+ $value = $this->get_meta( $log->ID, $key, true );
+
+ if ( $this->add_meta( $log->ID, $key, $value ) ) {
+ delete_post_meta( $log->ID, $key );
+ } else {
+ $failed_records++;
+ }
+ }
+ }
+ }
+
+ function add_meta( $post_id = 0, $meta_key = '', $meta_value = '' ) {
+ return add_metadata( $this->log_meta_type, $post_id, $meta_key, $meta_value );
+ }
+
+ function update_meta( $post_id = 0, $meta_key = '', $meta_value = '' ) {
+ return update_metadata( $this->log_meta_type, $post_id, $meta_key, $meta_value );
+ }
+
+ function get_meta( $post_id = 0, $meta_key = '', $single = false ) {
+ return get_metadata( $this->log_meta_type, $post_id, $meta_key, $single );
+ }
+
+ function delete_meta( $post_id = 0, $meta_key = '' ) {
+ return delete_metadata( $this->log_meta_type, $post_id, $meta_key );
+ }
+
+} \ No newline at end of file
diff --git a/Postman/PostmanOptions.php b/Postman/PostmanOptions.php
index b6eaaf4..af88b18 100644
--- a/Postman/PostmanOptions.php
+++ b/Postman/PostmanOptions.php
@@ -174,10 +174,9 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
if ( is_multisite() ) {
$network_options = get_site_option( self::POSTMAN_NETWORK_OPTIONS );
+ $blog_id = get_current_blog_id();
if ( isset( $network_options['post_smtp_global_settings'] ) ) {
$blog_id = apply_filters( 'post_smtp_default_site_option', 1 );
- } elseif ( $options && isset( $network_options['post_smtp_allow_overwrite'] ) ) {
- $blog_id = get_current_blog_id();
}
switch_to_blog($blog_id);
diff --git a/Postman/PostmanUtils.php b/Postman/PostmanUtils.php
index 8c7081f..7a443de 100644
--- a/Postman/PostmanUtils.php
+++ b/Postman/PostmanUtils.php
@@ -447,7 +447,7 @@ class PostmanUtils {
}
public static function getServerName() {
- $result = 'localhost.localdomain';
+ $host = 'localhost.localdomain';
if (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER)) {
$host = $_SERVER['SERVER_NAME'];
@@ -459,9 +459,18 @@ class PostmanUtils {
// as final option - if ip returned or hostname without extension (not valid dns name)
$extension = pathinfo( $host, PATHINFO_EXTENSION );
- if ( filter_var( $result, FILTER_VALIDATE_IP ) || empty( $extension ) ) {
+ if ( filter_var( $host, FILTER_VALIDATE_IP ) || empty( $extension ) ) {
$siteurl = get_bloginfo('url');
- $host = parse_url($siteurl, PHP_URL_HOST);
+ $temp_host = parse_url( $siteurl, PHP_URL_HOST);
+
+ $dnsr = dns_get_record( $temp_host, DNS_A );
+ $ip = gethostbyname( $temp_host );
+
+ foreach ( $dnsr as $record ) {
+ if ( $record['host'] == $temp_host && $record['ip'] == $ip ) {
+ $host = $temp_host;
+ }
+ }
}
return str_replace('www.', '', $host );