SMTP Mailer - Version 1.0.5

Version Description

  • SMTP Mailer is now compatible with WordPress 4.9.
Download this release

Release Info

Developer naa986
Plugin Icon 128x128 SMTP Mailer
Version 1.0.5
Comparing to
See all releases

Code changes from version 1.0.2 to 1.0.5

Files changed (2) hide show
  1. main.php +34 -22
  2. readme.txt +24 -7
main.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
  /*
3
  Plugin Name: SMTP Mailer
4
- Version: 1.0.2
5
- Plugin URI: http://wphowto.net/smtp-mailer-plugin-for-wordpress-1482
6
  Author: naa986
7
- Author URI: http://wphowto.net/
8
  Description: Configure a SMTP server to send email from your WordPress site
9
  Text Domain: smtp-mailer
10
  Domain Path: /languages
@@ -16,8 +16,8 @@ if (!defined('ABSPATH')){
16
 
17
  class SMTP_MAILER {
18
 
19
- var $plugin_version = '1.0.2';
20
- var $phpmailer_version = '5.2.14';
21
  var $plugin_url;
22
  var $plugin_path;
23
 
@@ -78,7 +78,7 @@ class SMTP_MAILER {
78
  'smtp-mailer-settings&action=test-email' => __('Test Email', 'smtp-mailer'),
79
  'smtp-mailer-settings&action=server-info' => __('Server Info', 'smtp-mailer'),
80
  );
81
- $url = "http://wphowto.net/smtp-mailer-plugin-for-wordpress-1482";
82
  $link_text = sprintf(wp_kses(__('Please visit the <a target="_blank" href="%s">SMTP Mailer</a> documentation page for usage instructions.', 'smtp-mailer'), array('a' => array('href' => array(), 'target' => array()))), esc_url($url));
83
  echo '<div class="wrap"><h2>SMTP Mailer v' . SMTP_MAILER_VERSION . '</h2>';
84
  echo '<div class="update-nag">'.$link_text.'</div>';
@@ -223,7 +223,9 @@ class SMTP_MAILER {
223
  }
224
  $smtp_password = '';
225
  if(isset($_POST['smtp_password']) && !empty($_POST['smtp_password'])){
 
226
  $smtp_password = sanitize_text_field($_POST['smtp_password']);
 
227
  $smtp_password = base64_encode($smtp_password);
228
  }
229
  $type_of_encryption = '';
@@ -442,6 +444,10 @@ if(!function_exists('wp_mail') && is_smtp_mailer_configured()){
442
  $to = $atts['to'];
443
  }
444
 
 
 
 
 
445
  if ( isset( $atts['subject'] ) ) {
446
  $subject = $atts['subject'];
447
  }
@@ -562,10 +568,10 @@ if(!function_exists('wp_mail') && is_smtp_mailer_configured()){
562
  }
563
 
564
  // Empty out the values that may be set
565
- $phpmailer->ClearAllRecipients();
566
- $phpmailer->ClearAttachments();
567
- $phpmailer->ClearCustomHeaders();
568
- $phpmailer->ClearReplyTos();
569
 
570
  // From email and name
571
  // If we don't have a name from the input headers
@@ -607,17 +613,23 @@ if(!function_exists('wp_mail') && is_smtp_mailer_configured()){
607
  */
608
  $from_name = apply_filters( 'wp_mail_from_name', $from_name );
609
 
610
- $phpmailer->setFrom( $from_email, $from_name, false );
 
 
 
 
 
 
 
611
 
612
- // Set destination addresses
613
- if ( !is_array( $to ) )
614
- $to = explode( ',', $to );
615
 
616
  // Set mail's subject and body
617
  $phpmailer->Subject = $subject;
618
  $phpmailer->Body = $message;
619
 
620
- // Use appropriate methods for handling addresses, rather than treating them as generic headers
621
  $address_headers = compact( 'to', 'cc', 'bcc', 'reply_to' );
622
 
623
  foreach ( $address_headers as $address_header => $addresses ) {
@@ -716,7 +728,7 @@ if(!function_exists('wp_mail') && is_smtp_mailer_configured()){
716
 
717
  // Set whether it's plaintext, depending on $content_type
718
  if ( 'text/html' == $content_type )
719
- $phpmailer->IsHTML( true );
720
 
721
  // If we don't have a charset from the input headers
722
  if ( !isset( $charset ) )
@@ -736,17 +748,17 @@ if(!function_exists('wp_mail') && is_smtp_mailer_configured()){
736
  // Set custom headers
737
  if ( !empty( $headers ) ) {
738
  foreach ( (array) $headers as $name => $content ) {
739
- $phpmailer->AddCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
740
  }
741
 
742
  if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) )
743
- $phpmailer->AddCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) );
744
  }
745
 
746
  if ( !empty( $attachments ) ) {
747
  foreach ( $attachments as $attachment ) {
748
  try {
749
- $phpmailer->AddAttachment($attachment);
750
  } catch ( phpmailerException $e ) {
751
  continue;
752
  }
@@ -758,13 +770,13 @@ if(!function_exists('wp_mail') && is_smtp_mailer_configured()){
758
  *
759
  * @since 2.2.0
760
  *
761
- * @param PHPMailer &$phpmailer The PHPMailer instance, passed by reference.
762
  */
763
- //do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
764
 
765
  // Send!
766
  try {
767
- return $phpmailer->Send();
768
  } catch ( phpmailerException $e ) {
769
 
770
  $mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' );
1
  <?php
2
  /*
3
  Plugin Name: SMTP Mailer
4
+ Version: 1.0.5
5
+ Plugin URI: https://wphowto.net/smtp-mailer-plugin-for-wordpress-1482
6
  Author: naa986
7
+ Author URI: https://wphowto.net/
8
  Description: Configure a SMTP server to send email from your WordPress site
9
  Text Domain: smtp-mailer
10
  Domain Path: /languages
16
 
17
  class SMTP_MAILER {
18
 
19
+ var $plugin_version = '1.0.5';
20
+ var $phpmailer_version = '5.2.22';
21
  var $plugin_url;
22
  var $plugin_path;
23
 
78
  'smtp-mailer-settings&action=test-email' => __('Test Email', 'smtp-mailer'),
79
  'smtp-mailer-settings&action=server-info' => __('Server Info', 'smtp-mailer'),
80
  );
81
+ $url = "https://wphowto.net/smtp-mailer-plugin-for-wordpress-1482";
82
  $link_text = sprintf(wp_kses(__('Please visit the <a target="_blank" href="%s">SMTP Mailer</a> documentation page for usage instructions.', 'smtp-mailer'), array('a' => array('href' => array(), 'target' => array()))), esc_url($url));
83
  echo '<div class="wrap"><h2>SMTP Mailer v' . SMTP_MAILER_VERSION . '</h2>';
84
  echo '<div class="update-nag">'.$link_text.'</div>';
223
  }
224
  $smtp_password = '';
225
  if(isset($_POST['smtp_password']) && !empty($_POST['smtp_password'])){
226
+ //echo "password: ".$_POST['smtp_password'];
227
  $smtp_password = sanitize_text_field($_POST['smtp_password']);
228
+ $smtp_password = wp_unslash($smtp_password); // This removes slash (automatically added by WordPress) from the password when apostrophe is present
229
  $smtp_password = base64_encode($smtp_password);
230
  }
231
  $type_of_encryption = '';
444
  $to = $atts['to'];
445
  }
446
 
447
+ if ( !is_array( $to ) ) {
448
+ $to = explode( ',', $to );
449
+ }
450
+
451
  if ( isset( $atts['subject'] ) ) {
452
  $subject = $atts['subject'];
453
  }
568
  }
569
 
570
  // Empty out the values that may be set
571
+ $phpmailer->clearAllRecipients();
572
+ $phpmailer->clearAttachments();
573
+ $phpmailer->clearCustomHeaders();
574
+ $phpmailer->clearReplyTos();
575
 
576
  // From email and name
577
  // If we don't have a name from the input headers
613
  */
614
  $from_name = apply_filters( 'wp_mail_from_name', $from_name );
615
 
616
+ try {
617
+ $phpmailer->setFrom( $from_email, $from_name, false );
618
+ } catch ( phpmailerException $e ) {
619
+ $mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' );
620
+ $mail_error_data['phpmailer_exception_code'] = $e->getCode();
621
+
622
+ /** This filter is documented in wp-includes/pluggable.php */
623
+ do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_error_data ) );
624
 
625
+ return false;
626
+ }
 
627
 
628
  // Set mail's subject and body
629
  $phpmailer->Subject = $subject;
630
  $phpmailer->Body = $message;
631
 
632
+ // Set destination addresses, using appropriate methods for handling addresses
633
  $address_headers = compact( 'to', 'cc', 'bcc', 'reply_to' );
634
 
635
  foreach ( $address_headers as $address_header => $addresses ) {
728
 
729
  // Set whether it's plaintext, depending on $content_type
730
  if ( 'text/html' == $content_type )
731
+ $phpmailer->isHTML( true );
732
 
733
  // If we don't have a charset from the input headers
734
  if ( !isset( $charset ) )
748
  // Set custom headers
749
  if ( !empty( $headers ) ) {
750
  foreach ( (array) $headers as $name => $content ) {
751
+ $phpmailer->addCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
752
  }
753
 
754
  if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) )
755
+ $phpmailer->addCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) );
756
  }
757
 
758
  if ( !empty( $attachments ) ) {
759
  foreach ( $attachments as $attachment ) {
760
  try {
761
+ $phpmailer->addAttachment($attachment);
762
  } catch ( phpmailerException $e ) {
763
  continue;
764
  }
770
  *
771
  * @since 2.2.0
772
  *
773
+ * @param PHPMailer $phpmailer The PHPMailer instance (passed by reference).
774
  */
775
+ do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
776
 
777
  // Send!
778
  try {
779
+ return $phpmailer->send();
780
  } catch ( phpmailerException $e ) {
781
 
782
  $mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' );
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: naa986
3
  Donate link: https://wphowto.net/
4
  Tags: smtp, mail, mailer, phpmailer, wp_mail, email
5
- Requires at least: 4.7
6
- Tested up to: 4.7
7
- Stable tag: 1.0.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -14,7 +14,13 @@ Configure a SMTP server to send email from your WordPress site. Configure the wp
14
 
15
  [SMTP Mailer](https://wphowto.net/smtp-mailer-plugin-for-wordpress-1482) plugin allows you to configure a mail server which handles all outgoing email from your website. It takes control of the wp_mail function and use SMTP instead.
16
 
17
- = SMTP Mailer Settings =
 
 
 
 
 
 
18
 
19
  * **SMTP Host**: Your outgoing mail server (e.g. smtp.gmail.com).
20
  * **SMTP Authentication**: Whether to use SMTP authentication when sending an email (True/False). If you choose to authenticate you will also need to provide your username and password.
@@ -25,7 +31,7 @@ Configure a SMTP server to send email from your WordPress site. Configure the wp
25
  * **From Email Address**: The email address to be used as the From Address when sending an email.
26
  * **From Name**: The name to be used as the From Name when sending an email.
27
 
28
- = SMTP Mailer Test Email =
29
 
30
  Once you have configured the settings you can send a test email to check the functionality of the plugin.
31
 
@@ -33,7 +39,7 @@ Once you have configured the settings you can send a test email to check the fun
33
  * **Subject**: Subject of the email.
34
  * **Message**: Email body.
35
 
36
- = Known Compatibility =
37
 
38
  SMTP Mailer should work with any plugin that uses the WordPress Mail function. However, It has been tested with the following form and contact form plugins:
39
 
@@ -61,13 +67,24 @@ Yes.
61
 
62
  == Screenshots ==
63
 
64
- For screenshots please visit the [SMTP Mailer](https://wphowto.net/smtp-mailer-plugin-for-wordpress-1482) plugin page
 
65
 
66
  == Upgrade Notice ==
67
  none
68
 
69
  == Changelog ==
70
 
 
 
 
 
 
 
 
 
 
 
71
  = 1.0.2 =
72
  * SMTP Mailer now supports the "wp_mail_failed" hook which fires after a phpmailerException is caught.
73
  * Added a new option to bypass this error on some servers where the SSL certificate is not properly configured - Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed.
2
  Contributors: naa986
3
  Donate link: https://wphowto.net/
4
  Tags: smtp, mail, mailer, phpmailer, wp_mail, email
5
+ Requires at least: 4.8
6
+ Tested up to: 5.1
7
+ Stable tag: 1.0.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
14
 
15
  [SMTP Mailer](https://wphowto.net/smtp-mailer-plugin-for-wordpress-1482) plugin allows you to configure a mail server which handles all outgoing email from your website. It takes control of the wp_mail function and use SMTP instead.
16
 
17
+ https://www.youtube.com/watch?v=7O_jgtykcEk&rel=0
18
+
19
+ === Requirements ===
20
+
21
+ * A self-hosted website running on [WordPress hosting](https://wphowto.net/best-cheap-wordpress-hosting-1689)
22
+
23
+ === SMTP Mailer Settings ===
24
 
25
  * **SMTP Host**: Your outgoing mail server (e.g. smtp.gmail.com).
26
  * **SMTP Authentication**: Whether to use SMTP authentication when sending an email (True/False). If you choose to authenticate you will also need to provide your username and password.
31
  * **From Email Address**: The email address to be used as the From Address when sending an email.
32
  * **From Name**: The name to be used as the From Name when sending an email.
33
 
34
+ === SMTP Mailer Test Email ===
35
 
36
  Once you have configured the settings you can send a test email to check the functionality of the plugin.
37
 
39
  * **Subject**: Subject of the email.
40
  * **Message**: Email body.
41
 
42
+ === Known Compatibility ===
43
 
44
  SMTP Mailer should work with any plugin that uses the WordPress Mail function. However, It has been tested with the following form and contact form plugins:
45
 
67
 
68
  == Screenshots ==
69
 
70
+ 1. SMTP Mailer Settings
71
+ 2. SMTP Mailer Test Email Tab
72
 
73
  == Upgrade Notice ==
74
  none
75
 
76
  == Changelog ==
77
 
78
+ = 1.0.5 =
79
+ * SMTP Mailer is now compatible with WordPress 4.9.
80
+
81
+ = 1.0.4 =
82
+ * Updated the mail() function by setting its minimum requirements to WordPress 4.8.
83
+ * "phpmailer_init" action hook is now enabled so it can be used by other plugins.
84
+
85
+ = 1.0.3 =
86
+ * Fixed a bug where an apostrophe in the password would cause SMTP authentication failure.
87
+
88
  = 1.0.2 =
89
  * SMTP Mailer now supports the "wp_mail_failed" hook which fires after a phpmailerException is caught.
90
  * Added a new option to bypass this error on some servers where the SSL certificate is not properly configured - Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed.