Add wp-smtp

Signed-off-by: Adrian Nöthlich <git@promasu.tech>
This commit is contained in:
2019-09-06 18:26:43 +02:00
parent ea85457cbf
commit 903dfaf264
19 changed files with 587 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 732 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 988 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

View File

@@ -0,0 +1,106 @@
msgid ""
msgstr ""
"Project-Id-Version: WP-SMTP Languages\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-10-07 00:39+0800\n"
"PO-Revision-Date: 2013-10-07 00:39+0800\n"
"Last-Translator: 夜光 <berttung(#)gmail.com>\n"
"Language-Team: 玻璃泉BoLiQuan.COM <berttung(#)gmail.com>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-KeywordsList: __;_e\n"
"X-Poedit-Basepath: .\n"
"X-Poedit-Language: English\n"
"X-Poedit-Country: CHINA\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-SearchPath-0: D:\\xampp\\htdocs\\wordpress\\wp-content\\plugins\\wp-smtp\n"
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp-smtp.php:66
msgid "Settings"
msgstr "设置"
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp_smtp_admin.php:21
msgid "The field \"From\" must be a valid email address!"
msgstr "“发件人地址”必须是一个有效的电子邮件地址!"
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp_smtp_admin.php:24
msgid "The field \"SMTP Host\" can not be left blank!"
msgstr "“SMTP服务器地址”不能为空"
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp_smtp_admin.php:27
msgid "Options saved."
msgstr "设置已保存。"
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp_smtp_admin.php:47
msgid "Message sent!"
msgstr "邮件已发送!"
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp_smtp_admin.php:54
msgid "Some errors occurred!"
msgstr "发生了一些错误!"
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp_smtp_admin.php:57
msgid "The fields \"To\" \"Subject\" \"Message\" can not be left blank when testing!"
msgstr "测试时“收件地址”“邮件标题”“邮件正文”均不能为空!"
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp_smtp_admin.php:80
msgid "From"
msgstr "发件人地址"
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp_smtp_admin.php:90
msgid "From Name"
msgstr "发件人昵称"
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp_smtp_admin.php:100
msgid "SMTP Host"
msgstr "SMTP服务器地址"
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp_smtp_admin.php:110
msgid "SMTP Secure"
msgstr "SMTP加密方式"
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp_smtp_admin.php:131
msgid "SMTP Port"
msgstr "SMTP端口"
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp_smtp_admin.php:141
msgid "SMTP Authentication"
msgstr "SMTP认证"
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp_smtp_admin.php:157
msgid "Username"
msgstr "认证用户名 (完整邮件地址)"
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp_smtp_admin.php:167
msgid "Password"
msgstr "认证密码"
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp_smtp_admin.php:177
msgid "Delete Options"
msgstr "禁用时自动删除设置"
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp_smtp_admin.php:182
msgid "Delete options while deactivate this plugin."
msgstr "当禁用此插件时自动删除此插件的设置数据."
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp_smtp_admin.php:190
msgid "Save Changes"
msgstr "保存更改"
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp_smtp_admin.php:199
msgid "To:"
msgstr "收件地址:"
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp_smtp_admin.php:209
msgid "Subject:"
msgstr "邮件标题:"
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp_smtp_admin.php:219
msgid "Message:"
msgstr "邮件正文:"
#: D:\xampp\htdocs\wordpress\wp-content\plugins\wp-smtp/wp_smtp_admin.php:230
msgid "Send Test"
msgstr "发送测试"

View File

@@ -0,0 +1,109 @@
=== WP SMTP ===
Contributors: yehudah
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=yehuda@myinbox.in&item_name=Donation+for+WPSMTP
Tags: wp smtp,smtp,mail,email,phpmailer,mailer,wp mail,gmail,yahoo,mail smtp,ssl,tls
License: GPLv2
Requires at least: 2.7
Tested up to: 5.2
Stable tag: 1.1.10
WP SMTP can help us to send emails via SMTP instead of the PHP mail() function.
== Description ==
WP SMTP can help us to send emails via SMTP instead of the PHP mail() function.
It adds a settings page to "Dashboard"->"Settings"->"WP SMTP" where you can configure the email settings.
There are some examples on the settings page, you can click the corresponding icon to view (such as "Gmail""Yahoo!""Microsoft""163""QQ").
If the field "From" was not a valid email address, or the field "SMTP Host" was left blank, it will not reconfigure the wp_mail() function.
= Do you want more advanced SMTP mailer? =
* Built-in **importer for WP SMTP settings**.
* Universal SMTP for every service.
* SMTP ports are blocked? API support - A method for sending emails via HTTP for Gmail, Sendgrid, Mailgun, and Mandrill.
* Credentials can be configured inside wp-config.php insted of the DB.
* Built-in mail logger with the option to resend and filter.
* Built-in alert function when emails are faling, you can get notified by Email, Slack or pushover.
* Ports checker for any blocking issue.
**Check Post SMTP:**
[https://wordpress.org/plugins/post-smtp/](https://wordpress.org/plugins/post-smtp/)
= CREDITS =
WP SMTP plugin was originally created by BoLiQuan. It is now owned and maintained by Yehuda Hassine.
= Usage =
1. Download and extract `wp-smtp.zip` to `wp-content/plugins/`
2. Activate the plugin through the 'Plugins' menu in WordPress.
3. "Dashboard"->"Settings"->"WP SMTP"
4. There are some examples on the settings page, you can click the corresponding icon to view.(such as "Gmail""Yahoo!""Microsoft""163""QQ")
5. For more information of this plugin, please visit: [Plugin Homepage](https://wpsmtpmail.com/ "WP SMTP").
== Installation ==
1. Download and extract `wp-smtp.zip` to `wp-content/plugins/`
2. Activate the plugin through the 'Plugins' menu in WordPress.
3. "Dashboard"->"Settings"->"WP SMTP"
4. There are some examples on the settings page, you can click the corresponding icon to view.(such as "Gmail""Yahoo!""Microsoft""163""QQ")
5. For more information of this plugin, please visit: [Plugin Homepage](https://wpsmtpmail.com/ "WP SMTP").
== Changelog ==
= 1.1.10 =
New maintainer - yehudah
https://wpsmtpmail.com/v1-1-10-wp-smtp-is-back/
* Code structure and organize.
* Credentials can now be configured inside wp-config.php
= 1.1.9 =
* Some optimization
= 1.1.7 =
* Using a nonce to increase security.
= 1.1.6 =
* Add Yahoo! example
* Some optimization
= 1.1.5 =
* Some optimization
= 1.1.4 =
* If the field "From" was not a valid email address, or the field "Host" was left blank, it will not reconfigure the wp_mail() function.
* Add some reminders.
= 1.1.3 =
* If "SMTP Authentication" was set to no, the values "Username""Password" are ignored.
= 1.1.2 =
* First release.
== Screenshots ==
1. "Gmail.com" settings
2. "Yahoo.com" settings
3. "Live.com" settings
4. "163.com" settings
5. "QQ.com" settings
== Frequently Asked Questions ==
You can sumbit it in https://wordpress.org/support/plugin/wp-smtp, if It's urgent like a bug submit it here: https://wpsmtpmail.com/contact/
== Upgrade Notice ==
Please visit http://boliquan.com/wp-smtp/

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -0,0 +1,113 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/*
Plugin Name: WP SMTP
Description: WP SMTP can help us to send emails via SMTP instead of the PHP mail() function.
Version: 1.1.10
Author: Yehuda Hassine
Text Domain: wp-smtp
Domain Path: /lang
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
/*
* The plugin was originally created by BoLiQuan
*/
class WP_SMTP {
private $wsOptions, $phpmailer_error;
public function __construct() {
$this->setup_vars();
$this->hooks();
}
public function setup_vars(){
$this->wsOptions = get_option( 'wp_smtp_options' );
}
public function hooks() {
register_activation_hook( __FILE__ , array( $this,'wp_smtp_activate' ) );
register_deactivation_hook( __FILE__, array( $this, 'wp_smtp_deactivate' ) );
add_filter( 'plugin_action_links', array( $this, 'wp_smtp_settings_link' ), 10, 2 );
add_action( 'init', array( $this,'load_textdomain' ) );
add_action( 'phpmailer_init', array( $this,'wp_smtp' ) );
add_action( 'wp_mail_failed', array( $this, 'catch_phpmailer_error' ) );
add_action( 'admin_menu', array( $this, 'wp_smtp_admin' ) );
}
function wp_smtp_activate(){
$wsOptions = array();
$wsOptions["from"] = "";
$wsOptions["fromname"] = "";
$wsOptions["host"] = "";
$wsOptions["smtpsecure"] = "";
$wsOptions["port"] = "";
$wsOptions["smtpauth"] = "yes";
$wsOptions["username"] = "";
$wsOptions["password"] = "";
$wsOptions["deactivate"] = "";
add_option( 'wp_smtp_options', $wsOptions );
}
function wp_smtp_deactivate() {
if( $this->wsOptions['deactivate'] == 'yes' ) {
delete_option( 'wp_smtp_options' );
}
}
function load_textdomain() {
load_plugin_textdomain( 'wp-smtp', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' );
}
function wp_smtp( $phpmailer ) {
if( ! is_email($this->wsOptions["from"] ) || empty( $this->wsOptions["host"] ) ) {
return;
}
$phpmailer->Mailer = "smtp";
$phpmailer->From = $this->wsOptions["from"];
$phpmailer->FromName = $this->wsOptions["fromname"];
$phpmailer->Sender = $phpmailer->From; //Return-Path
$phpmailer->AddReplyTo($phpmailer->From,$phpmailer->FromName); //Reply-To
$phpmailer->Host = $this->wsOptions["host"];
$phpmailer->SMTPSecure = $this->wsOptions["smtpsecure"];
$phpmailer->Port = $this->wsOptions["port"];
$phpmailer->SMTPAuth = ($this->wsOptions["smtpauth"]=="yes") ? TRUE : FALSE;
if( $phpmailer->SMTPAuth ){
$phpmailer->Username = $this->wsOptions["username"];
$phpmailer->Password = $this->wsOptions["password"];
}
}
function catch_phpmailer_error( $error ) {
$this->phpmailer_error = $error;
}
function wp_smtp_settings_link($action_links,$plugin_file) {
if( $plugin_file == plugin_basename( __FILE__ ) ) {
$ws_settings_link = '<a href="options-general.php?page=' . dirname( plugin_basename(__FILE__) ) . '/wp-smtp.php">' . __("Settings") . '</a>';
array_unshift($action_links,$ws_settings_link);
}
return $action_links;
}
function wp_smtp_admin(){
add_options_page('WP SMTP Options', 'WP SMTP','manage_options', __FILE__, array( $this, 'wp_smtp_page') );
}
function wp_smtp_page(){
require_once __DIR__ . '/wp_smtp_admin.php';
}
}
new WP_SMTP();
?>

View File

@@ -0,0 +1,259 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
// Catch the SMTP settings
if (isset($_POST['wp_smtp_update']) && isset($_POST['wp_smtp_nonce_update'])) {
if (!wp_verify_nonce(trim($_POST['wp_smtp_nonce_update']), 'my_ws_nonce')) {
wp_die('Security check not passed!');
}
$this->wsOptions = array();
$this->wsOptions["from"] = sanitize_email( trim( $_POST['wp_smtp_from'] ) );
$this->wsOptions["fromname"] = sanitize_text_field( trim( $_POST['wp_smtp_fromname'] ) );
$this->wsOptions["host"] = sanitize_text_field( trim( $_POST['wp_smtp_host'] ) );
$this->wsOptions["smtpsecure"] = sanitize_text_field( trim( $_POST['wp_smtp_smtpsecure'] ) );
$this->wsOptions["port"] = is_numeric( trim( $_POST['wp_smtp_port'] ) ) ? trim( $_POST['wp_smtp_port'] ) : '';
$this->wsOptions["smtpauth"] = sanitize_text_field( trim( $_POST['wp_smtp_smtpauth'] ) );
$this->wsOptions["username"] = defined( 'WP_SMTP_USER' ) ? WP_SMTP_USER : sanitize_text_field( trim( $_POST['wp_smtp_username'] ) );
$this->wsOptions["password"] = defined( 'WP_SMTP_PASS' ) ? WP_SMTP_PASS : sanitize_text_field( trim( $_POST['wp_smtp_password'] ) );
$this->wsOptions["deactivate"] = ( isset($_POST['wp_smtp_deactivate'] ) ) ? sanitize_text_field( trim( $_POST['wp_smtp_deactivate'] ) ) : '';
update_option("wp_smtp_options", $this->wsOptions);
if ( ! is_email($this->wsOptions["from"] ) ) {
echo '<div id="message" class="updated fade"><p><strong>' . __("The field \"From\" must be a valid email address!", "WP-SMTP") . '</strong></p></div>';
} elseif (empty($this->wsOptions["host"])) {
echo '<div id="message" class="updated fade"><p><strong>' . __("The field \"SMTP Host\" can not be left blank!", "WP-SMTP") . '</strong></p></div>';
} else {
echo '<div id="message" class="updated fade"><p><strong>' . __("Options saved.", "WP-SMTP") . '</strong></p></div>';
}
}
// Catch the test form
if ( isset( $_POST['wp_smtp_test'] ) && isset( $_POST['wp_smtp_nonce_test'] ) ) {
if ( ! wp_verify_nonce( trim( $_POST['wp_smtp_nonce_test'] ), 'my_ws_nonce' ) ) {
wp_die('Security check not passed!');
}
$to = sanitize_text_field( trim( $_POST['wp_smtp_to'] ) );
$subject = sanitize_text_field( trim( $_POST['wp_smtp_subject'] ) );
$message = sanitize_textarea_field(trim( $_POST['wp_smtp_message'] ) );
$status = false;
$class = 'error';
if ( ! empty( $to ) && is_email( $to ) && ! empty( $subject ) && ! empty( $message ) ) {
try {
$result = wp_mail( $to, $subject, $message );
} catch (Exception $e) {
$status = $e->getMessage();
}
} else {
$status = __( 'Some of the test fields are empty or an invalid email supplied', 'wp-smtp' );
}
if ( ! $status ) {
if ( $result === true ) {
$status = __( 'Message sent!', 'wp-smtp' );
$class = 'success';
} else {
$status = $this->phpmailer_error->get_error_message();
}
}
echo '<div id="message" class="notice notice-' . $class . ' is-dismissible"><p><strong>' . $status . '</strong></p></div>';
}
$ws_nonce = wp_create_nonce('my_ws_nonce');
?>
<div class="wrap">
<h1>
WP SMTP
<span style="margin-left:10px; vertical-align:middle;">
<a href="<?php echo plugins_url('screenshot-1.png', __FILE__); ?>" target="_blank"><img
src="<?php echo plugins_url('/img/gmail.png', __FILE__); ?>" alt="Gmail" title="Gmail"/></a>
<a href="<?php echo plugins_url('screenshot-2.png', __FILE__); ?>" target="_blank"><img
src="<?php echo plugins_url('/img/yahoo.png', __FILE__); ?>" alt="Yahoo!" title="Yahoo!"/></a>
<a href="<?php echo plugins_url('screenshot-3.png', __FILE__); ?>" target="_blank"><img
src="<?php echo plugins_url('/img/microsoft.png', __FILE__); ?>" alt="Microsoft" title="Microsoft"/></a>
<a href="<?php echo plugins_url('screenshot-4.png', __FILE__); ?>" target="_blank"><img
src="<?php echo plugins_url('/img/163.png', __FILE__); ?>" alt="163" title="163"/></a>
<a href="<?php echo plugins_url('screenshot-5.png', __FILE__); ?>" target="_blank"><img
src="<?php echo plugins_url('/img/qq.png', __FILE__); ?>" alt="QQ" title="QQ"/></a>
</span>
</h1>
<form action="" method="post" enctype="multipart/form-data" name="wp_smtp_form">
<table class="form-table">
<tr valign="top">
<th scope="row">
<?php _e('From', 'wp-smtp'); ?>
</th>
<td>
<label>
<input type="email" name="wp_smtp_from" value="<?php echo $this->wsOptions["from"]; ?>" size="43"
style="width:272px;height:24px;" required/>
</label>
</td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e('From Name', 'wp-smtp'); ?>
</th>
<td>
<label>
<input type="text" name="wp_smtp_fromname" value="<?php echo $this->wsOptions["fromname"]; ?>"
size="43" style="width:272px;height:24px;" required />
</label>
</td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e('SMTP Host', 'wp-smtp'); ?>
</th>
<td>
<label>
<input type="text" name="wp_smtp_host" value="<?php echo $this->wsOptions["host"]; ?>" size="43"
style="width:272px;height:24px;" required />
</label>
</td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e('SMTP Secure', 'wp-smtp'); ?>
</th>
<td>
<label>
<input name="wp_smtp_smtpsecure" type="radio"
value=""<?php if ($this->wsOptions["smtpsecure"] == '') { ?> checked="checked"<?php } ?> />
None
</label>
&nbsp;
<label>
<input name="wp_smtp_smtpsecure" type="radio"
value="ssl"<?php if ($this->wsOptions["smtpsecure"] == 'ssl') { ?> checked="checked"<?php } ?> />
SSL
</label>
&nbsp;
<label>
<input name="wp_smtp_smtpsecure" type="radio"
value="tls"<?php if ($this->wsOptions["smtpsecure"] == 'tls') { ?> checked="checked"<?php } ?> />
TLS
</label>
</td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e('SMTP Port', 'wp-smtp'); ?>
</th>
<td>
<label>
<input type="text" name="wp_smtp_port" value="<?php echo $this->wsOptions["port"]; ?>" size="43"
style="width:272px;height:24px;"/>
</label>
</td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e('SMTP Authentication', 'wp-smtp'); ?>
</th>
<td>
<label>
<input name="wp_smtp_smtpauth" type="radio"
value="no"<?php if ($this->wsOptions["smtpauth"] == 'no') { ?> checked="checked"<?php } ?> />
No
</label>
&nbsp;
<label>
<input name="wp_smtp_smtpauth" type="radio"
value="yes"<?php if ($this->wsOptions["smtpauth"] == 'yes') { ?> checked="checked"<?php } ?> />
Yes
</label>
</td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e('Username', 'wp-smtp'); ?>
</th>
<td>
<label>
<input type="text" name="wp_smtp_username" value="<?php echo $this->wsOptions["username"]; ?>"
size="43" style="width:272px;height:24px;"/>
</label>
</td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e('Password', 'wp-smtp'); ?>
</th>
<td>
<label>
<input type="password" name="wp_smtp_password" value="<?php echo $this->wsOptions["password"]; ?>"
size="43" style="width:272px;height:24px;"/>
</label>
</td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e('Delete Options', 'wp-smtp'); ?>
</th>
<td>
<label>
<input type="checkbox" name="wp_smtp_deactivate"
value="yes" <?php if ($this->wsOptions["deactivate"] == 'yes') echo 'checked="checked"'; ?> />
<?php _e('Delete options while deactivate this plugin.', 'wp-smtp'); ?>
</label>
</td>
</tr>
</table>
<p class="submit">
<input type="hidden" name="wp_smtp_update" value="update"/>
<input type="hidden" name="wp_smtp_nonce_update" value="<?php echo $ws_nonce; ?>"/>
<input type="submit" class="button-primary" name="Submit" value="<?php _e('Save Changes'); ?>"/>
</p>
</form>
<form action="" method="post" enctype="multipart/form-data" name="wp_smtp_testform">
<h2><?php _e( 'Test your settings', 'wp-smtp' ); ?></h2>
<table class="form-table">
<tr valign="top">
<th scope="row">
<?php _e('To:', 'wp-smtp'); ?>
</th>
<td>
<label>
<input type="email" name="wp_smtp_to" value="" size="43" style="width:272px;height:24px;" required />
</label>
</td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e('Subject:', 'wp-smtp'); ?>
</th>
<td>
<label>
<input type="text" name="wp_smtp_subject" value="" size="43" style="width:272px;height:24px;" required />
</label>
</td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e('Message:', 'wp-smtp'); ?>
</th>
<td>
<label>
<textarea type="text" name="wp_smtp_message" value="" cols="45" rows="3"
style="width:284px;height:62px;" required></textarea>
</label>
</td>
</tr>
</table>
<p class="submit">
<input type="hidden" name="wp_smtp_test" value="test"/>
<input type="hidden" name="wp_smtp_nonce_test" value="<?php echo $ws_nonce; ?>"/>
<input type="submit" class="button-primary" value="<?php _e('Send Test', 'wp-smtp'); ?>"/>
</p>
</form>