From 263bc7987e090b0b25d241fa6951f32b8eb2552f Mon Sep 17 00:00:00 2001 From: yehudah Date: Tue, 17 Oct 2017 12:11:01 +0000 Subject: = 1.7.6 - 2017-10-17 * Missing sendgrid files * Fixed: Localization slug * Minor typo --- Postman/Postman-Mail/PostmanMyMailConnector.php | 176 ++++++++++++------------ 1 file changed, 87 insertions(+), 89 deletions(-) (limited to 'Postman/Postman-Mail/PostmanMyMailConnector.php') diff --git a/Postman/Postman-Mail/PostmanMyMailConnector.php b/Postman/Postman-Mail/PostmanMyMailConnector.php index 203fbf5..151deed 100644 --- a/Postman/Postman-Mail/PostmanMyMailConnector.php +++ b/Postman/Postman-Mail/PostmanMyMailConnector.php @@ -1,182 +1,181 @@ ' )) { + if ( ! defined( 'MYMAIL_VERSION' ) || version_compare( MYMAIL_POSTMAN_REQUIRED_VERSION, MYMAIL_VERSION, '>' ) ) { // no-op } else { // create an instance of the Logger - $this->logger = new PostmanLogger ( get_class ( $this ) ); - $this->logger->debug ( 'Starting' ); - - add_filter ( 'mymail_delivery_methods', array ( + $this->logger = new PostmanLogger( get_class( $this ) ); + $this->logger->debug( 'Starting' ); + + add_filter( 'mymail_delivery_methods', array( &$this, - 'delivery_method' + 'delivery_method', ) ); - add_action ( 'mymail_deliverymethod_tab_postman', array ( + add_action( 'mymail_deliverymethod_tab_postman', array( &$this, - 'deliverytab' + 'deliverytab', ) ); - - if (mymail_option ( 'deliverymethod' ) == MYMAIL_POSTMAN_ID) { - add_action ( 'mymail_initsend', array ( + + if ( mymail_option( 'deliverymethod' ) == MYMAIL_POSTMAN_ID ) { + add_action( 'mymail_initsend', array( &$this, - 'initsend' + 'initsend', ) ); - add_action ( 'mymail_presend', array ( + add_action( 'mymail_presend', array( &$this, - 'presend' + 'presend', ) ); - add_action ( 'mymail_dosend', array ( + add_action( 'mymail_dosend', array( &$this, - 'dosend' + 'dosend', ) ); - add_action ( 'MYMAIL_POSTMAN_cron', array ( + add_action( 'MYMAIL_POSTMAN_cron', array( &$this, - 'reset' + 'reset', ) ); } } } - + /** * initsend function. * * uses mymail_initsend hook to set initial settings * * @access public - * @param mixed $mailobject + * @param mixed $mailobject * @return void */ - public function initsend($mailobject) { - $this->logger->trace ( 'initsend' ); + public function initsend( $mailobject ) { + $this->logger->trace( 'initsend' ); // disable dkim $mailobject->dkim = false; } - + /** * presend function. * * uses the mymail_presend hook to apply setttings before each mail * * @access public - * @param mixed $mailobject + * @param mixed $mailobject * @return void */ - public function presend($mailobject) { - + public function presend( $mailobject ) { + // embedding images doesn't work $mailobject->embed_images = false; - + // use pre_send from the main class // need the raw email body to send so we use the same option - $mailobject->pre_send (); + $mailobject->pre_send(); } - + /** * dosend function. * * uses the mymail_dosend hook and triggers the send * * @access public - * @param mixed $mailobject + * @param mixed $mailobject * @return void */ - public function dosend($mailobject) { - $this->logger->trace ( 'dosend' ); - $this->logger->trace ( $mailobject->mailer ); - + public function dosend( $mailobject ) { + $this->logger->trace( 'dosend' ); + $this->logger->trace( $mailobject->mailer ); + // create a PostmanWpMail instance - $postmanWpMail = new PostmanWpMail (); - $postmanWpMail->init (); - + $postmanWpMail = new PostmanWpMail(); + $postmanWpMail->init(); + // create a PostmanMessage instance - $message = $postmanWpMail->createNewMessage (); - $message->addHeaders ( $mailobject->headers ); - $message->setBodyTextPart ( $mailobject->mailer->AltBody ); - $message->setBodyHtmlPart ( $mailobject->mailer->Body ); - $message->setBody ( $mailobject->mailer->AltBody . $mailobject->mailer->Body ); - $message->setSubject ( $mailobject->subject ); - $message->addTo ( $mailobject->to ); - $message->setReplyTo ( $mailobject->reply_to ); - $message->setAttachments ( $mailobject->attachments ); - + $message = $postmanWpMail->createNewMessage(); + $message->addHeaders( $mailobject->headers ); + $message->setBodyTextPart( $mailobject->mailer->AltBody ); + $message->setBodyHtmlPart( $mailobject->mailer->Body ); + $message->setBody( $mailobject->mailer->AltBody . $mailobject->mailer->Body ); + $message->setSubject( $mailobject->subject ); + $message->addTo( $mailobject->to ); + $message->setReplyTo( $mailobject->reply_to ); + $message->setAttachments( $mailobject->attachments ); + // create a PostmanEmailLog instance - $log = new PostmanEmailLog (); - + $log = new PostmanEmailLog(); + // send the message and store the result - $mailobject->sent = $postmanWpMail->sendMessage ( $message, $log ); - + $mailobject->sent = $postmanWpMail->sendMessage( $message, $log ); + // give error message back to MyMail - $result = apply_filters ( 'postman_wp_mail_result', null ); - if (! $mailobject->sent) { - $mailobject->set_error ( $result ['exception']->getMessage () ); + $result = apply_filters( 'postman_wp_mail_result', null ); + if ( ! $mailobject->sent ) { + $mailobject->set_error( $result ['exception']->getMessage() ); } } - + /** * reset function. * * resets the current time * * @access public - * @param mixed $message + * @param mixed $message * @return array */ public function reset() { - update_option ( '_transient__mymail_send_period_timeout', false ); - update_option ( '_transient__mymail_send_period', 0 ); + update_option( '_transient__mymail_send_period_timeout', false ); + update_option( '_transient__mymail_send_period', 0 ); } - + /** * delivery_method function. * * add the delivery method to the options * * @access public - * @param mixed $delivery_methods + * @param mixed $delivery_methods * @return void */ - public function delivery_method($delivery_methods) { - $delivery_methods [MYMAIL_POSTMAN_ID] = __ ( 'Postman SMTP', Postman::TEXT_DOMAIN ); + public function delivery_method( $delivery_methods ) { + $delivery_methods [ MYMAIL_POSTMAN_ID ] = __( 'Postman SMTP', Postman::TEXT_DOMAIN ); return $delivery_methods; } - + /** * deliverytab function. * @@ -186,9 +185,9 @@ if (! class_exists ( 'PostmanMyMailConnector' )) { * @return void */ public function deliverytab() { - apply_filters ( 'print_postman_status', null ); + apply_filters( 'print_postman_status', null ); } - + /** * activate function. * @@ -196,12 +195,12 @@ if (! class_exists ( 'PostmanMyMailConnector' )) { * @return void */ public function activate() { - if (defined ( 'MYMAIL_VERSION' ) && version_compare ( MYMAIL_POSTMAN_REQUIRED_VERSION, MYMAIL_VERSION, '<=' )) { - mymail_notice ( sprintf ( __ ( 'MyMail: Change the delivery method in the %s!', Postman::TEXT_DOMAIN ), sprintf ( '%s', __ ( 'Settings', 'postman-smtp' ) ) ), '', false, 'delivery_method' ); - $this->reset (); + if ( defined( 'MYMAIL_VERSION' ) && version_compare( MYMAIL_POSTMAN_REQUIRED_VERSION, MYMAIL_VERSION, '<=' ) ) { + mymail_notice( sprintf( __( 'MyMail: Change the delivery method in the %s!', Postman::TEXT_DOMAIN ), sprintf( '%s', __( 'Settings', 'postman-smtp' ) ) ), '', false, 'delivery_method' ); + $this->reset(); } } - + /** * deactivate function. * @@ -209,12 +208,11 @@ if (! class_exists ( 'PostmanMyMailConnector' )) { * @return void */ public function deactivate() { - d; - if (defined ( 'MYMAIL_VERSION' ) && function_exists ( 'mymail_option' ) && version_compare ( MYMAIL_POSTMAN_REQUIRED_VERSION, MYMAIL_VERSION, '<=' )) { - if (mymail_option ( 'deliverymethod' ) == MYMAIL_POSTMAN_ID) { - mymail_update_option ( 'deliverymethod', 'simple' ); + if ( defined( 'MYMAIL_VERSION' ) && function_exists( 'mymail_option' ) && version_compare( MYMAIL_POSTMAN_REQUIRED_VERSION, MYMAIL_VERSION, '<=' ) ) { + if ( mymail_option( 'deliverymethod' ) == MYMAIL_POSTMAN_ID ) { + mymail_update_option( 'deliverymethod', 'simple' ); /* Translators where %s is the name of the page */ - mymail_notice ( sprintf ( __ ( 'MyMail: Change the delivery method in the %s!', Postman::TEXT_DOMAIN ), sprintf ( '%s', __ ( 'Settings', 'postman-smtp' ) ) ), '', false, 'delivery_method' ); + mymail_notice( sprintf( __( 'MyMail: Change the delivery method in the %s!', Postman::TEXT_DOMAIN ), sprintf( '%s', __( 'Settings', 'postman-smtp' ) ) ), '', false, 'delivery_method' ); } } } -- cgit v1.2.3