Version Description
- 2019-05-15
- New: Mailer Type - Added an option to send without overwrite the 'wp_mail' function, better compability to WordPress delivery. hopefully will be the default in the future.
- Updated: Sendgrid API was upgraded and rewritten to the new version.
- Fixed: Message-Id header was missing on SMTP
- Fixed: Email logger optimization - better query for large amount of records.
- Fixed: The localization was fixed to match translate.wordpress.org translation system ( Thanks to Niels de Blaauw from Level-Level ).
- Fixed: Code and optimization ( Thanks to Niels de Blaauw from Level-Level ).
Download this release
Release Info
Developer | yehudah |
Plugin | Post SMTP Mailer/Email Log |
Version | 2.0 |
Comparing to | |
See all releases |
Code changes from version 1.9.8 to 2.0
- Postman/Phpmailer/PostsmtpMailer.php +122 -0
- Postman/Postman-Auth/PostmanAbstractAuthenticationManager.php +2 -2
- Postman/Postman-Configuration/PostmanConfigurationController.php +91 -82
- Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php +93 -72
- Postman/Postman-Configuration/PostmanSmtpDiscovery.php +7 -7
- Postman/Postman-Connectivity-Test/Postman-PortTest.php +2 -2
- Postman/Postman-Connectivity-Test/PostmanConnectivityTestController.php +29 -29
- Postman/Postman-Controller/PostmanAdminPointer.php +2 -2
- Postman/Postman-Controller/PostmanDashboardWidgetController.php +12 -12
- Postman/Postman-Controller/PostmanManageConfigurationAjaxHandler.php +1 -1
- Postman/Postman-Controller/PostmanWelcomeController.php +35 -35
- Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php +14 -15
- Postman/Postman-Email-Log/PostmanEmailLogController.php +38 -36
- Postman/Postman-Email-Log/PostmanEmailLogPostType.php +2 -2
- Postman/Postman-Email-Log/PostmanEmailLogService.php +18 -18
- Postman/Postman-Email-Log/PostmanEmailLogView.php +18 -16
- Postman/Postman-Mail/PostmanDefaultModuleTransport.php +2 -2
- Postman/Postman-Mail/PostmanEmailAddress.php +2 -2
- Postman/Postman-Mail/PostmanGmailApiModuleTransport.php +5 -5
- Postman/Postman-Mail/PostmanGmailApiModuleZendMailTransport.php +2 -2
- Postman/Postman-Mail/PostmanMailgunMailEngine.php +2 -2
- Postman/Postman-Mail/PostmanMailgunTransport.php +21 -21
- Postman/Postman-Mail/PostmanMandrillMailEngine.php +2 -2
- Postman/Postman-Mail/PostmanMandrillTransport.php +12 -12
- Postman/Postman-Mail/PostmanMessage.php +12 -12
- Postman/Postman-Mail/PostmanModuleTransport.php +24 -23
- Postman/Postman-Mail/PostmanMyMailConnector.php +4 -5
- Postman/Postman-Mail/PostmanSendGridMailEngine.php +48 -75
- Postman/Postman-Mail/PostmanSendGridTransport.php +15 -15
- Postman/Postman-Mail/PostmanSmtpModuleTransport.php +42 -42
- Postman/Postman-Mail/PostmanTransportRegistry.php +11 -11
- Postman/Postman-Mail/PostmanWooCommerce.php +21 -21
- Postman/Postman-Mail/PostmanZendMailEngine.php +3 -3
- Postman/Postman-Mail/PostmanZendMailTransportConfigurationFactory.php +9 -9
- Postman/Postman-Mail/Zend-1.12.10/Mail.php +2 -2
- Postman/Postman-Mail/Zend-1.12.10/Validate/EmailAddress.php +1 -1
- Postman/Postman-Mail/sendgrid/composer.json +2 -2
- Postman/Postman-Send-Test-Email/PostmanSendTestEmailController.php +26 -26
- Postman/Postman.php +71 -24
- Postman/PostmanAdminController.php +21 -20
- Postman/PostmanAjaxController.php +5 -5
- Postman/PostmanConfigTextHelper.php +33 -33
- Postman/PostmanEmailLogs.php +111 -0
- Postman/PostmanInputSanitizer.php +6 -5
- Postman/PostmanInstaller.php +3 -4
- Postman/PostmanLogger.php +2 -2
- Postman/PostmanMessageHandler.php +8 -8
- Postman/PostmanOptions.php +17 -4
- Postman/PostmanSession.php +3 -3
- Postman/PostmanUtils.php +30 -37
- Postman/PostmanViewController.php +99 -79
- Postman/PostmanWpMail.php +54 -21
- Postman/PostmanWpMailBinder.php +2 -4
- Postman/extra/donation.php +19 -0
- Postman/notifications/PostmanMailNotify.php +1 -1
- README.md +217 -104
- postman-smtp.php +5 -3
- readme.txt +12 -5
- script/postman.js +12 -0
- style/images/mailer-type.gif +0 -0
- style/jquery-steps/jquery.steps.css +0 -1
- style/postman.css +20 -1
Postman/Phpmailer/PostsmtpMailer.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once ABSPATH . WPINC . '/class-phpmailer.php';
|
3 |
+
require_once ABSPATH . WPINC . '/class-smtp.php';
|
4 |
+
|
5 |
+
add_action('plugins_loaded', function() {
|
6 |
+
global $phpmailer;
|
7 |
+
|
8 |
+
$phpmailer = new PostsmtpMailer(true);
|
9 |
+
});
|
10 |
+
|
11 |
+
class PostsmtpMailer extends PHPMailer {
|
12 |
+
|
13 |
+
private $options;
|
14 |
+
|
15 |
+
private $error;
|
16 |
+
|
17 |
+
public function __construct($exceptions = null)
|
18 |
+
{
|
19 |
+
parent::__construct($exceptions);
|
20 |
+
|
21 |
+
$this->options = PostmanOptions::getInstance();
|
22 |
+
add_filter( 'postman_wp_mail_result', [ $this, 'postman_wp_mail_result' ] );
|
23 |
+
}
|
24 |
+
|
25 |
+
public function send()
|
26 |
+
{
|
27 |
+
require_once dirname(__DIR__) . '/PostmanWpMail.php';
|
28 |
+
|
29 |
+
// create a PostmanWpMail instance
|
30 |
+
$postmanWpMail = new PostmanWpMail();
|
31 |
+
$postmanWpMail->init();
|
32 |
+
|
33 |
+
$senderEmail = $this->options->getMessageSenderEmail();
|
34 |
+
$senderName = $this->options->getMessageSenderName();
|
35 |
+
|
36 |
+
// create a PostmanMessage instance
|
37 |
+
$message = $postmanWpMail->createNewMessage();
|
38 |
+
|
39 |
+
$message->setFrom( $senderEmail, $senderName );
|
40 |
+
$message->addHeaders( $this->getHeaders() );
|
41 |
+
$message->setBodyTextPart( $this->AltBody );
|
42 |
+
$message->setBodyHtmlPart( $this->Body );
|
43 |
+
$message->setBody( $this->Body );
|
44 |
+
$message->setSubject( $this->Subject );
|
45 |
+
$message->addTo( $this->flatArray($this->getToAddresses() ) );
|
46 |
+
$message->setReplyTo( $this->flatArray( $this->getReplyToAddresses() ) );
|
47 |
+
$message->addCc( $this->flatArray($this->getCcAddresses() ) );
|
48 |
+
$message->addBCc( $this->flatArray( $this->getBccAddresses() ) );
|
49 |
+
$message->setReplyTo( $this->flatArray( $this->getReplyToAddresses() ) );
|
50 |
+
$message->setAttachments( $this->getAttachments() );
|
51 |
+
|
52 |
+
// create a PostmanEmailLog instance
|
53 |
+
$log = new PostmanEmailLog();
|
54 |
+
|
55 |
+
$log->originalTo = $this->flatArray($this->getToAddresses() );
|
56 |
+
$log->originalSubject = $this->Subject;
|
57 |
+
$log->originalMessage = $this->Body;
|
58 |
+
$log->originalHeaders = $this->getCustomHeaders();
|
59 |
+
|
60 |
+
try {
|
61 |
+
return $postmanWpMail->sendMessage( $message, $log );
|
62 |
+
} catch (phpmailerException $exc) {
|
63 |
+
|
64 |
+
$this->error = $exc;
|
65 |
+
|
66 |
+
$this->mailHeader = '';
|
67 |
+
$this->setError($exc->getMessage());
|
68 |
+
if ($this->exceptions) {
|
69 |
+
throw $exc;
|
70 |
+
}
|
71 |
+
return false;
|
72 |
+
}
|
73 |
+
|
74 |
+
}
|
75 |
+
|
76 |
+
public function getAttachments() {
|
77 |
+
$attachments = parent::getAttachments();
|
78 |
+
|
79 |
+
$data = array();
|
80 |
+
foreach ( $attachments as $attachment ) {
|
81 |
+
$data[] = $attachment[0];
|
82 |
+
}
|
83 |
+
|
84 |
+
return $data;
|
85 |
+
}
|
86 |
+
|
87 |
+
private function getHeaders() {
|
88 |
+
$headers = array();
|
89 |
+
foreach ( $this->getCustomHeaders() as $header ) {
|
90 |
+
$headers[] = "{$header[0]}: {$header[1]}";
|
91 |
+
}
|
92 |
+
|
93 |
+
return $headers;
|
94 |
+
}
|
95 |
+
|
96 |
+
public function postman_wp_mail_result() {
|
97 |
+
$result = [
|
98 |
+
'time' => '',
|
99 |
+
'exception' => $this->error,
|
100 |
+
'transcript' => '',
|
101 |
+
];
|
102 |
+
return $result;
|
103 |
+
}
|
104 |
+
|
105 |
+
private function flatArray($arr) {
|
106 |
+
$result = [];
|
107 |
+
foreach ( $arr as $key => $value ) {
|
108 |
+
if ( is_array( $value ) ) {
|
109 |
+
foreach ($value as $k => $v ) {
|
110 |
+
if ( empty( $v ) ) {
|
111 |
+
continue;
|
112 |
+
}
|
113 |
+
$value = $v;
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
$result[] = $value;
|
118 |
+
}
|
119 |
+
|
120 |
+
return implode(',', $result );
|
121 |
+
}
|
122 |
+
}
|
Postman/Postman-Auth/PostmanAbstractAuthenticationManager.php
CHANGED
@@ -69,7 +69,7 @@ if (! class_exists ( "PostmanAbstractAuthenticationManager" )) {
|
|
69 |
* Decoded the received token
|
70 |
* This code is identical for Google and Hotmail
|
71 |
*
|
72 |
-
* @param
|
73 |
* @throws Exception
|
74 |
*/
|
75 |
protected function processResponse($response) {
|
@@ -99,7 +99,7 @@ if (! class_exists ( "PostmanAbstractAuthenticationManager" )) {
|
|
99 |
*
|
100 |
* This code is identical for Google and Hotmail
|
101 |
*
|
102 |
-
* @param
|
103 |
*/
|
104 |
protected function decodeReceivedAuthorizationToken($newtoken) {
|
105 |
assert ( ! empty ( $newtoken ) );
|
69 |
* Decoded the received token
|
70 |
* This code is identical for Google and Hotmail
|
71 |
*
|
72 |
+
* @param mixed $response
|
73 |
* @throws Exception
|
74 |
*/
|
75 |
protected function processResponse($response) {
|
99 |
*
|
100 |
* This code is identical for Google and Hotmail
|
101 |
*
|
102 |
+
* @param mixed $client
|
103 |
*/
|
104 |
protected function decodeReceivedAuthorizationToken($newtoken) {
|
105 |
assert ( ! empty ( $newtoken ) );
|
Postman/Postman-Configuration/PostmanConfigurationController.php
CHANGED
@@ -12,10 +12,12 @@ class PostmanConfigurationController {
|
|
12 |
// Holds the values to be used in the fields callbacks
|
13 |
private $rootPluginFilenameAndPath;
|
14 |
|
|
|
|
|
15 |
/**
|
16 |
* Constructor
|
17 |
*
|
18 |
-
* @param
|
19 |
*/
|
20 |
public function __construct( $rootPluginFilenameAndPath ) {
|
21 |
assert( ! empty( $rootPluginFilenameAndPath ) );
|
@@ -94,11 +96,11 @@ class PostmanConfigurationController {
|
|
94 |
/**
|
95 |
*/
|
96 |
private function addLocalizeScriptsToPage() {
|
97 |
-
$warning = __( 'Warning',
|
98 |
/* translators: where %s is the name of the SMTP server */
|
99 |
-
wp_localize_script( 'postman_wizard_script', 'postman_smtp_mitm', sprintf( '%s: %s', $warning, __( 'connected to %1$s instead of %2$s.',
|
100 |
/* translators: where %d is a port number */
|
101 |
-
wp_localize_script( 'postman_wizard_script', 'postman_wizard_bad_redirect_url', __( 'You are about to configure OAuth 2.0 with an IP address instead of a domain name. This is not permitted. Either assign a real domain name to your site or add a fake one in your local host file.',
|
102 |
|
103 |
// user input
|
104 |
wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_input_sender_email', '#input_' . PostmanOptions::MESSAGE_SENDER_EMAIL );
|
@@ -131,7 +133,7 @@ class PostmanConfigurationController {
|
|
131 |
* Register the Configuration screen
|
132 |
*/
|
133 |
public function addConfigurationSubmenu() {
|
134 |
-
$page = add_submenu_page( null, sprintf( __( '%s Setup',
|
135 |
$this,
|
136 |
'outputManualConfigurationContent',
|
137 |
) );
|
@@ -155,7 +157,7 @@ class PostmanConfigurationController {
|
|
155 |
* Register the Setup Wizard screen
|
156 |
*/
|
157 |
public function addSetupWizardSubmenu() {
|
158 |
-
$page = add_submenu_page( null, sprintf( __( '%s Setup',
|
159 |
$this,
|
160 |
'outputWizardContent',
|
161 |
) );
|
@@ -194,14 +196,14 @@ class PostmanConfigurationController {
|
|
194 |
public function outputManualConfigurationContent() {
|
195 |
print '<div class="wrap">';
|
196 |
|
197 |
-
PostmanViewController::outputChildPageHeader( __( 'Settings',
|
198 |
print '<div id="config_tabs"><ul>';
|
199 |
-
print sprintf( '<li><a href="#account_config">%s</a></li>', __( 'Account',
|
200 |
-
print sprintf( '<li><a href="#fallback">%s</a></li>', __( 'Fallback',
|
201 |
-
print sprintf( '<li><a href="#message_config">%s</a></li>', __( 'Message',
|
202 |
-
print sprintf( '<li><a href="#logging_config">%s</a></li>', __( 'Logging',
|
203 |
-
print sprintf( '<li><a href="#advanced_options_config">%s</a></li>', __( 'Advanced',
|
204 |
-
print sprintf( '<li><a href="#notifications">%s</a></li>', __( 'Notifications',
|
205 |
print '</ul>';
|
206 |
|
207 |
print '<form method="post" action="options.php">';
|
@@ -239,29 +241,29 @@ class PostmanConfigurationController {
|
|
239 |
|
240 |
<!-- Fallback Start -->
|
241 |
<section id="fallback">
|
242 |
-
<h2><?php esc_html_e( 'Failed emails fallback',
|
243 |
-
<p><?php esc_html_e( 'By enable this option, if your email is fail to send Post SMTP will try to use the SMTP service you define here.',
|
244 |
<table class="form-table">
|
245 |
<tr valign="">
|
246 |
-
<th scope="row"><?php _e( 'Use Fallback?',
|
247 |
<td>
|
248 |
<label>
|
249 |
<input name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_ENABLED; ?>]" type="radio"
|
250 |
value="no"<?php echo checked( $this->options->getFallbackIsEnabled(), 'no' ); ?>>
|
251 |
-
<?php _e( 'No',
|
252 |
</label>
|
253 |
|
254 |
<label>
|
255 |
<?php $checked = checked( $this->options->getFallbackIsEnabled(), 'yes', false ); ?>
|
256 |
<input name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_ENABLED; ?>]" type="radio"
|
257 |
value="yes"<?php echo checked( $this->options->getFallbackIsEnabled(), 'yes' ); ?>>
|
258 |
-
<?php _e( 'Yes',
|
259 |
</label>
|
260 |
</td>
|
261 |
</tr>
|
262 |
|
263 |
<tr>
|
264 |
-
<th scope="row"><?php _e('Outgoing Mail Server',
|
265 |
<?php $host = $this->options->getFallbackHostname(); ?>
|
266 |
<td>
|
267 |
<input type="text" id="fallback-smtp-host" name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_HOSTNAME; ?>]"
|
@@ -270,7 +272,7 @@ class PostmanConfigurationController {
|
|
270 |
</tr>
|
271 |
|
272 |
<tr>
|
273 |
-
<th scope="row"><?php _e('Mail Server Port',
|
274 |
<?php $port = $this->options->getFallbackPort(); ?>
|
275 |
<td>
|
276 |
<input type="number" id="fallback-smtp-port" name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_PORT; ?>]"
|
@@ -279,12 +281,12 @@ class PostmanConfigurationController {
|
|
279 |
</tr>
|
280 |
|
281 |
<tr>
|
282 |
-
<th scope="row"><?php _e('Security',
|
283 |
<?php
|
284 |
$security_options = array(
|
285 |
-
'none' => __( 'None',
|
286 |
-
'ssl' => __( 'SSL',
|
287 |
-
'tls' => __( 'TLS',
|
288 |
);
|
289 |
?>
|
290 |
<td>
|
@@ -302,36 +304,36 @@ class PostmanConfigurationController {
|
|
302 |
</tr>
|
303 |
|
304 |
<tr>
|
305 |
-
<th scope="row"><?php _e('From Email',
|
306 |
<td>
|
307 |
<input type="email" id="fallback-smtp-from-email"
|
308 |
value="<?php echo $this->options->getFallbackFromEmail(); ?>"
|
309 |
name="postman_options[<?php echo PostmanOptions::FALLBACK_FROM_EMAIL; ?>]"
|
310 |
>
|
311 |
<br>
|
312 |
-
<small><?php _e( "Use allowed email, for example: If you are using Gmail, type your Gmail adress.",
|
313 |
</td>
|
314 |
</tr>
|
315 |
|
316 |
<tr valign="">
|
317 |
-
<th scope="row"><?php _e( 'Use SMTP Authentication?',
|
318 |
<td>
|
319 |
<label>
|
320 |
<input name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_USE_AUTH; ?>]"
|
321 |
type="radio" value="none"<?php checked( $this->options->getFallbackAuth(), 'none' ); ?>>
|
322 |
-
<?php _e( 'No',
|
323 |
</label>
|
324 |
|
325 |
<label>
|
326 |
<input name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_USE_AUTH; ?>]"
|
327 |
type="radio" value="login"<?php checked( $this->options->getFallbackAuth(), 'login' ); ?>>
|
328 |
-
<?php _e( 'Yes',
|
329 |
</label>
|
330 |
</td>
|
331 |
</tr>
|
332 |
|
333 |
<tr>
|
334 |
-
<th scope="row"><?php _e('User name',
|
335 |
<td>
|
336 |
<input type="text" id="fallback-smtp-username"
|
337 |
value="<?php echo $this->options->getFallbackUsername(); ?>"
|
@@ -341,7 +343,7 @@ class PostmanConfigurationController {
|
|
341 |
</tr>
|
342 |
|
343 |
<tr>
|
344 |
-
<th scope="row"><?php _e('Password',
|
345 |
<td>
|
346 |
<input type="password" id="fallback-smtp-password"
|
347 |
value="<?php echo PostmanUtils::obfuscatePassword( $this->options->getFallbackPassword() ); ?>"
|
@@ -408,7 +410,7 @@ class PostmanConfigurationController {
|
|
408 |
// construct Wizard
|
409 |
print '<div class="wrap">';
|
410 |
|
411 |
-
PostmanViewController::outputChildPageHeader( __( 'Setup Wizard',
|
412 |
|
413 |
print '<form id="postman_wizard" method="post" action="options.php">';
|
414 |
|
@@ -440,12 +442,12 @@ class PostmanConfigurationController {
|
|
440 |
settings_fields( PostmanAdminController::SETTINGS_GROUP_NAME );
|
441 |
|
442 |
// Wizard Step 0
|
443 |
-
printf( '<h5>%s</h5>', _x( 'Import Configuration', 'Wizard Step Title',
|
444 |
print '<fieldset>';
|
445 |
-
printf( '<legend>%s</legend>', _x( 'Import configuration from another plugin?', 'Wizard Step Title',
|
446 |
-
printf( '<p>%s</p>', __( 'If you had a working configuration with another Plugin, the Setup Wizard can begin with those settings.',
|
447 |
print '<table class="input_auth_type">';
|
448 |
-
printf( '<tr><td><input type="radio" id="import_none" name="input_plugin" value="%s" checked="checked"></input></td><td><label> %s</label></td></tr>', 'none', __( 'None',
|
449 |
|
450 |
if ( $this->importableConfiguration->isImportAvailable() ) {
|
451 |
foreach ( $this->importableConfiguration->getAvailableOptions() as $options ) {
|
@@ -456,20 +458,20 @@ class PostmanConfigurationController {
|
|
456 |
print '</fieldset>';
|
457 |
|
458 |
// Wizard Step 1
|
459 |
-
printf( '<h5>%s</h5>', _x( 'Sender Details', 'Wizard Step Title',
|
460 |
print '<fieldset>';
|
461 |
-
printf( '<legend>%s</legend>', _x( 'Who is the mail coming from?', 'Wizard Step Title',
|
462 |
-
printf( '<p>%s</p>', __( 'Enter the email address and name you\'d like to send mail as.',
|
463 |
-
printf( '<p>%s</p>', __( 'Please note that to prevent abuse, many email services will <em>not</em> let you send from an email address other than the one you authenticate with.',
|
464 |
-
printf( '<label for="postman_options[sender_email]">%s</label>', __( 'Email Address',
|
465 |
print $this->settingsRegistry->from_email_callback();
|
466 |
print '<br/>';
|
467 |
-
printf( '<label for="postman_options[sender_name]">%s</label>', __( 'Name',
|
468 |
print $this->settingsRegistry->sender_name_callback();
|
469 |
print '</fieldset>';
|
470 |
|
471 |
// Wizard Step 2
|
472 |
-
printf( '<h5>%s</h5>', __( 'Outgoing Mail Server Hostname',
|
473 |
print '<fieldset>';
|
474 |
foreach ( PostmanTransportRegistry::getInstance()->getTransports() as $transport ) {
|
475 |
$transport->printWizardMailServerHostnameStep();
|
@@ -477,11 +479,11 @@ class PostmanConfigurationController {
|
|
477 |
print '</fieldset>';
|
478 |
|
479 |
// Wizard Step 3
|
480 |
-
printf( '<h5>%s</h5>', __( 'Connectivity Test',
|
481 |
print '<fieldset>';
|
482 |
-
printf( '<legend>%s</legend>', __( 'How will the connection to the mail server be established?',
|
483 |
-
printf( '<p>%s</p>', __( 'Your connection settings depend on what your email service provider offers, and what your WordPress host allows.',
|
484 |
-
printf( '<p id="connectivity_test_status">%s: <span id="port_test_status">%s</span></p>', __( 'Connectivity Test',
|
485 |
printf( '<p class="ajax-loader" style="display:none"><img src="%s"/></p>', plugins_url( 'post-smtp/style/ajax-loader.gif' ) );
|
486 |
printf( '<input type="hidden" id="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::TRANSPORT_TYPE );
|
487 |
printf( '<input type="hidden" id="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::PORT );
|
@@ -489,27 +491,27 @@ class PostmanConfigurationController {
|
|
489 |
printf( '<input type="hidden" id="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::AUTHENTICATION_TYPE );
|
490 |
print '<p id="wizard_recommendation"></p>';
|
491 |
/* Translators: Where %1$s is the socket identifier and %2$s is the authentication type */
|
492 |
-
printf( '<p class="user_override" style="display:none"><label><span>%s:</span></label> <table id="user_socket_override" class="user_override"></table></p>', _x( 'Socket', 'A socket is the network term for host and port together',
|
493 |
-
printf( '<p class="user_override" style="display:none"><label><span>%s:</span></label> <table id="user_auth_override" class="user_override"></table></p>', __( 'Authentication',
|
494 |
print ('<p><span id="smtp_mitm" style="display:none; background-color:yellow"></span></p>') ;
|
495 |
-
$warning = __( 'Warning',
|
496 |
-
$clearCredentialsWarning = __( 'This configuration option will send your authorization credentials in the clear.',
|
497 |
printf( '<p id="smtp_not_secure" style="display:none"><span style="background-color:yellow">%s: %s</span></p>', $warning, $clearCredentialsWarning );
|
498 |
print '</fieldset>';
|
499 |
|
500 |
// Wizard Step 4
|
501 |
-
printf( '<h5>%s</h5>', __( 'Authentication',
|
502 |
print '<fieldset>';
|
503 |
-
printf( '<legend>%s</legend>', __( 'How will you prove your identity to the mail server?',
|
504 |
foreach ( PostmanTransportRegistry::getInstance()->getTransports() as $transport ) {
|
505 |
$transport->printWizardAuthenticationStep();
|
506 |
}
|
507 |
print '</fieldset>';
|
508 |
|
509 |
// Wizard Step 5 - Notificiations
|
510 |
-
printf( '<h5>%s</h5>', __( 'Notifications',
|
511 |
print '<fieldset>';
|
512 |
-
printf( '<legend>%s</legend>', __( 'Select a notify service to notify you when an email is failed to delivered.',
|
513 |
|
514 |
?>
|
515 |
<select id="input_notification_service" class="input_notification_service" name="postman_options[notification_service]">
|
@@ -518,17 +520,17 @@ class PostmanConfigurationController {
|
|
518 |
<option value="slack">Slack</option>
|
519 |
</select>
|
520 |
<div id="pushover_cred" style="display: none;">
|
521 |
-
<h2><?php _e( 'Pushover Credentials',
|
522 |
<table class="form-table">
|
523 |
<tbody>
|
524 |
<tr>
|
525 |
-
<th scope="row"><?php _e( 'Pushover User Key',
|
526 |
<td>
|
527 |
<input type="password" id="pushover_user" name="postman_options[pushover_user]" value="">
|
528 |
</td>
|
529 |
</tr>
|
530 |
<tr>
|
531 |
-
<th scope="row"><?php _e( 'Pushover App Token',
|
532 |
<td>
|
533 |
<input type="password" id="pushover_token" name="postman_options[pushover_token]" value="">
|
534 |
</td>
|
@@ -537,15 +539,15 @@ class PostmanConfigurationController {
|
|
537 |
</table>
|
538 |
</div>
|
539 |
<div id="slack_cred" style="display: none;">
|
540 |
-
<h2><?php _e( 'Slack Credentials',
|
541 |
<table class="form-table">
|
542 |
<tbody>
|
543 |
<tr>
|
544 |
-
<th scope="row"><?php _e( 'Slack webhook',
|
545 |
<td>
|
546 |
<input type="password" id="slack_token" name="postman_options[slack_token]" value="">
|
547 |
<a target="_blank" class="" href="https://slack.postmansmtp.com/">
|
548 |
-
<?php _e( 'Get your webhook URL here.',
|
549 |
</a>
|
550 |
</td>
|
551 |
</tr>
|
@@ -554,20 +556,20 @@ class PostmanConfigurationController {
|
|
554 |
</div>
|
555 |
|
556 |
<div id="use-chrome-extension">
|
557 |
-
<h2><?php _e( 'Push To Chrome Extension',
|
558 |
<table class="form-table">
|
559 |
<tbody>
|
560 |
<tr>
|
561 |
-
<th scope="row"><?php _e( 'This is an extra notification to the selection above',
|
562 |
<td>
|
563 |
<input type="checkbox" id="notification_use_chrome" name="postman_options[notification_use_chrome]">
|
564 |
<a target="_blank" class="" href="https://chrome.google.com/webstore/detail/npklmbkpbknkmbohdbpikeidiaekjoch">
|
565 |
-
<?php _e( 'You can download the chrome
|
566 |
</a>
|
567 |
</td>
|
568 |
</tr>
|
569 |
<tr>
|
570 |
-
<th scope="row"><?php _e( 'Your UID as you see in the extension.',
|
571 |
<td>
|
572 |
<input type="password" id="notification_chrome_uid" name="postman_options[notification_chrome_uid]" value="">
|
573 |
</td>
|
@@ -580,15 +582,22 @@ class PostmanConfigurationController {
|
|
580 |
print '</fieldset>';
|
581 |
|
582 |
// Wizard Step 6
|
583 |
-
printf( '<h5>%s</h5>', _x( 'Finish', 'The final step of the Wizard',
|
584 |
print '<fieldset>';
|
585 |
-
printf( '<legend>%s</legend>', _x( 'You\'re Done!', 'Wizard Step Title',
|
586 |
print '<section>';
|
587 |
-
printf( '<p>%s</p>', __( 'Click Finish to save these settings, then:',
|
588 |
print '<ul style="margin-left: 20px">';
|
589 |
-
printf( '<li class="wizard-auth-oauth2">%s</li>', __( 'Grant permission with the Email Provider for Postman to send email and',
|
590 |
-
printf( '<li>%s</li>', __( 'Send yourself a Test Email to make sure everything is working!',
|
591 |
print '</ul>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
592 |
print '</section>';
|
593 |
print '</fieldset>';
|
594 |
print '</form>';
|
@@ -730,7 +739,7 @@ class PostmanManageConfigurationAjaxHandler extends PostmanAbstractAjaxHandler {
|
|
730 |
wp_send_json_success( $response );
|
731 |
} else {
|
732 |
/* translators: where %s is the URL to the Connectivity Test page */
|
733 |
-
$configuration ['message'] = sprintf( __( 'Postman can\'t find any way to send mail on your system. Run a <a href="%s">connectivity test</a>.',
|
734 |
$response ['configuration'] = $configuration;
|
735 |
if ( $this->logger->isTrace() ) {
|
736 |
$this->logger->trace( 'configuration:' );
|
@@ -745,8 +754,8 @@ class PostmanManageConfigurationAjaxHandler extends PostmanAbstractAjaxHandler {
|
|
745 |
* // ask a transport if they support it, and if they do at what priority is it
|
746 |
* // configure for the highest priority you find
|
747 |
*
|
748 |
-
* @param
|
749 |
-
* @return
|
750 |
*/
|
751 |
private function getWinningRecommendation( $sockets, $userSocketOverride, $userAuthOverride, $originalSmtpServer ) {
|
752 |
foreach ( $sockets as $socket ) {
|
@@ -758,11 +767,11 @@ class PostmanManageConfigurationAjaxHandler extends PostmanAbstractAjaxHandler {
|
|
758 |
|
759 |
/**
|
760 |
*
|
761 |
-
* @param
|
762 |
-
* @param
|
763 |
-
* @param
|
764 |
-
* @param
|
765 |
-
* @return
|
766 |
*/
|
767 |
private function getWin( PostmanWizardSocket $socket, $userSocketOverride, $userAuthOverride, $originalSmtpServer ) {
|
768 |
static $recommendationPriority = - 1;
|
@@ -790,7 +799,7 @@ class PostmanManageConfigurationAjaxHandler extends PostmanAbstractAjaxHandler {
|
|
790 |
|
791 |
/**
|
792 |
*
|
793 |
-
* @param
|
794 |
* @return multitype:
|
795 |
*/
|
796 |
private function createOverrideMenus( $sockets, $winningRecommendation, $userSocketOverride, $userAuthOverride ) {
|
@@ -815,9 +824,9 @@ class PostmanManageConfigurationAjaxHandler extends PostmanAbstractAjaxHandler {
|
|
815 |
/**
|
816 |
*
|
817 |
* @param PostmanWizardSocket $socket
|
818 |
-
* @param
|
819 |
-
* @param
|
820 |
-
* @param
|
821 |
*/
|
822 |
private function createOverrideMenu( PostmanWizardSocket $socket, $winningRecommendation, $userSocketOverride, $userAuthOverride ) {
|
823 |
if ( $socket->success ) {
|
12 |
// Holds the values to be used in the fields callbacks
|
13 |
private $rootPluginFilenameAndPath;
|
14 |
|
15 |
+
private $importableConfiguration;
|
16 |
+
|
17 |
/**
|
18 |
* Constructor
|
19 |
*
|
20 |
+
* @param mixed $rootPluginFilenameAndPath
|
21 |
*/
|
22 |
public function __construct( $rootPluginFilenameAndPath ) {
|
23 |
assert( ! empty( $rootPluginFilenameAndPath ) );
|
96 |
/**
|
97 |
*/
|
98 |
private function addLocalizeScriptsToPage() {
|
99 |
+
$warning = __( 'Warning', 'post-smtp' );
|
100 |
/* translators: where %s is the name of the SMTP server */
|
101 |
+
wp_localize_script( 'postman_wizard_script', 'postman_smtp_mitm', sprintf( '%s: %s', $warning, __( 'connected to %1$s instead of %2$s.', 'post-smtp' ) ) );
|
102 |
/* translators: where %d is a port number */
|
103 |
+
wp_localize_script( 'postman_wizard_script', 'postman_wizard_bad_redirect_url', __( 'You are about to configure OAuth 2.0 with an IP address instead of a domain name. This is not permitted. Either assign a real domain name to your site or add a fake one in your local host file.', 'post-smtp' ) );
|
104 |
|
105 |
// user input
|
106 |
wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_input_sender_email', '#input_' . PostmanOptions::MESSAGE_SENDER_EMAIL );
|
133 |
* Register the Configuration screen
|
134 |
*/
|
135 |
public function addConfigurationSubmenu() {
|
136 |
+
$page = add_submenu_page( null, sprintf( __( '%s Setup', 'post-smtp' ), __( 'Postman SMTP', 'post-smtp' ) ), __( 'Postman SMTP', 'post-smtp' ), Postman::MANAGE_POSTMAN_CAPABILITY_NAME, PostmanConfigurationController::CONFIGURATION_SLUG, array(
|
137 |
$this,
|
138 |
'outputManualConfigurationContent',
|
139 |
) );
|
157 |
* Register the Setup Wizard screen
|
158 |
*/
|
159 |
public function addSetupWizardSubmenu() {
|
160 |
+
$page = add_submenu_page( null, sprintf( __( '%s Setup', 'post-smtp' ), __( 'Postman SMTP', 'post-smtp' ) ), __( 'Postman SMTP', 'post-smtp' ), Postman::MANAGE_POSTMAN_CAPABILITY_NAME, PostmanConfigurationController::CONFIGURATION_WIZARD_SLUG, array(
|
161 |
$this,
|
162 |
'outputWizardContent',
|
163 |
) );
|
196 |
public function outputManualConfigurationContent() {
|
197 |
print '<div class="wrap">';
|
198 |
|
199 |
+
PostmanViewController::outputChildPageHeader( __( 'Settings', 'post-smtp' ), 'advanced_config' );
|
200 |
print '<div id="config_tabs"><ul>';
|
201 |
+
print sprintf( '<li><a href="#account_config">%s</a></li>', __( 'Account', 'post-smtp' ) );
|
202 |
+
print sprintf( '<li><a href="#fallback">%s</a></li>', __( 'Fallback', 'post-smtp' ) );
|
203 |
+
print sprintf( '<li><a href="#message_config">%s</a></li>', __( 'Message', 'post-smtp' ) );
|
204 |
+
print sprintf( '<li><a href="#logging_config">%s</a></li>', __( 'Logging', 'post-smtp' ) );
|
205 |
+
print sprintf( '<li><a href="#advanced_options_config">%s</a></li>', __( 'Advanced', 'post-smtp' ) );
|
206 |
+
print sprintf( '<li><a href="#notifications">%s</a></li>', __( 'Notifications', 'post-smtp' ) );
|
207 |
print '</ul>';
|
208 |
|
209 |
print '<form method="post" action="options.php">';
|
241 |
|
242 |
<!-- Fallback Start -->
|
243 |
<section id="fallback">
|
244 |
+
<h2><?php esc_html_e( 'Failed emails fallback', 'post-smtp' ); ?></h2>
|
245 |
+
<p><?php esc_html_e( 'By enable this option, if your email is fail to send Post SMTP will try to use the SMTP service you define here.', 'post-smtp' ); ?></p>
|
246 |
<table class="form-table">
|
247 |
<tr valign="">
|
248 |
+
<th scope="row"><?php _e( 'Use Fallback?', 'post-smtp' ); ?></th>
|
249 |
<td>
|
250 |
<label>
|
251 |
<input name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_ENABLED; ?>]" type="radio"
|
252 |
value="no"<?php echo checked( $this->options->getFallbackIsEnabled(), 'no' ); ?>>
|
253 |
+
<?php _e( 'No', 'post-smtp' ); ?>
|
254 |
</label>
|
255 |
|
256 |
<label>
|
257 |
<?php $checked = checked( $this->options->getFallbackIsEnabled(), 'yes', false ); ?>
|
258 |
<input name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_ENABLED; ?>]" type="radio"
|
259 |
value="yes"<?php echo checked( $this->options->getFallbackIsEnabled(), 'yes' ); ?>>
|
260 |
+
<?php _e( 'Yes', 'post-smtp' ); ?>
|
261 |
</label>
|
262 |
</td>
|
263 |
</tr>
|
264 |
|
265 |
<tr>
|
266 |
+
<th scope="row"><?php _e('Outgoing Mail Server', 'post-smtp' ); ?></th>
|
267 |
<?php $host = $this->options->getFallbackHostname(); ?>
|
268 |
<td>
|
269 |
<input type="text" id="fallback-smtp-host" name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_HOSTNAME; ?>]"
|
272 |
</tr>
|
273 |
|
274 |
<tr>
|
275 |
+
<th scope="row"><?php _e('Mail Server Port', 'post-smtp' ); ?></th>
|
276 |
<?php $port = $this->options->getFallbackPort(); ?>
|
277 |
<td>
|
278 |
<input type="number" id="fallback-smtp-port" name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_PORT; ?>]"
|
281 |
</tr>
|
282 |
|
283 |
<tr>
|
284 |
+
<th scope="row"><?php _e('Security', 'post-smtp' ); ?></th>
|
285 |
<?php
|
286 |
$security_options = array(
|
287 |
+
'none' => __( 'None', 'post-smtp' ),
|
288 |
+
'ssl' => __( 'SSL', 'post-smtp' ),
|
289 |
+
'tls' => __( 'TLS', 'post-smtp' ),
|
290 |
);
|
291 |
?>
|
292 |
<td>
|
304 |
</tr>
|
305 |
|
306 |
<tr>
|
307 |
+
<th scope="row"><?php _e('From Email', 'post-smtp' ); ?></th>
|
308 |
<td>
|
309 |
<input type="email" id="fallback-smtp-from-email"
|
310 |
value="<?php echo $this->options->getFallbackFromEmail(); ?>"
|
311 |
name="postman_options[<?php echo PostmanOptions::FALLBACK_FROM_EMAIL; ?>]"
|
312 |
>
|
313 |
<br>
|
314 |
+
<small><?php _e( "Use allowed email, for example: If you are using Gmail, type your Gmail adress.", 'post-smtp' ); ?></small>
|
315 |
</td>
|
316 |
</tr>
|
317 |
|
318 |
<tr valign="">
|
319 |
+
<th scope="row"><?php _e( 'Use SMTP Authentication?', 'post-smtp' ); ?></th>
|
320 |
<td>
|
321 |
<label>
|
322 |
<input name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_USE_AUTH; ?>]"
|
323 |
type="radio" value="none"<?php checked( $this->options->getFallbackAuth(), 'none' ); ?>>
|
324 |
+
<?php _e( 'No', 'post-smtp' ); ?>
|
325 |
</label>
|
326 |
|
327 |
<label>
|
328 |
<input name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_USE_AUTH; ?>]"
|
329 |
type="radio" value="login"<?php checked( $this->options->getFallbackAuth(), 'login' ); ?>>
|
330 |
+
<?php _e( 'Yes', 'post-smtp' ); ?>
|
331 |
</label>
|
332 |
</td>
|
333 |
</tr>
|
334 |
|
335 |
<tr>
|
336 |
+
<th scope="row"><?php _e('User name', 'post-smtp' ); ?></th>
|
337 |
<td>
|
338 |
<input type="text" id="fallback-smtp-username"
|
339 |
value="<?php echo $this->options->getFallbackUsername(); ?>"
|
343 |
</tr>
|
344 |
|
345 |
<tr>
|
346 |
+
<th scope="row"><?php _e('Password', 'post-smtp' ); ?></th>
|
347 |
<td>
|
348 |
<input type="password" id="fallback-smtp-password"
|
349 |
value="<?php echo PostmanUtils::obfuscatePassword( $this->options->getFallbackPassword() ); ?>"
|
410 |
// construct Wizard
|
411 |
print '<div class="wrap">';
|
412 |
|
413 |
+
PostmanViewController::outputChildPageHeader( __( 'Setup Wizard', 'post-smtp' ) );
|
414 |
|
415 |
print '<form id="postman_wizard" method="post" action="options.php">';
|
416 |
|
442 |
settings_fields( PostmanAdminController::SETTINGS_GROUP_NAME );
|
443 |
|
444 |
// Wizard Step 0
|
445 |
+
printf( '<h5>%s</h5>', _x( 'Import Configuration', 'Wizard Step Title', 'post-smtp' ) );
|
446 |
print '<fieldset>';
|
447 |
+
printf( '<legend>%s</legend>', _x( 'Import configuration from another plugin?', 'Wizard Step Title', 'post-smtp' ) );
|
448 |
+
printf( '<p>%s</p>', __( 'If you had a working configuration with another Plugin, the Setup Wizard can begin with those settings.', 'post-smtp' ) );
|
449 |
print '<table class="input_auth_type">';
|
450 |
+
printf( '<tr><td><input type="radio" id="import_none" name="input_plugin" value="%s" checked="checked"></input></td><td><label> %s</label></td></tr>', 'none', __( 'None', 'post-smtp' ) );
|
451 |
|
452 |
if ( $this->importableConfiguration->isImportAvailable() ) {
|
453 |
foreach ( $this->importableConfiguration->getAvailableOptions() as $options ) {
|
458 |
print '</fieldset>';
|
459 |
|
460 |
// Wizard Step 1
|
461 |
+
printf( '<h5>%s</h5>', _x( 'Sender Details', 'Wizard Step Title', 'post-smtp' ) );
|
462 |
print '<fieldset>';
|
463 |
+
printf( '<legend>%s</legend>', _x( 'Who is the mail coming from?', 'Wizard Step Title', 'post-smtp' ) );
|
464 |
+
printf( '<p>%s</p>', __( 'Enter the email address and name you\'d like to send mail as.', 'post-smtp' ) );
|
465 |
+
printf( '<p>%s</p>', __( 'Please note that to prevent abuse, many email services will <em>not</em> let you send from an email address other than the one you authenticate with.', 'post-smtp' ) );
|
466 |
+
printf( '<label for="postman_options[sender_email]">%s</label>', __( 'Email Address', 'post-smtp' ) );
|
467 |
print $this->settingsRegistry->from_email_callback();
|
468 |
print '<br/>';
|
469 |
+
printf( '<label for="postman_options[sender_name]">%s</label>', __( 'Name', 'post-smtp' ) );
|
470 |
print $this->settingsRegistry->sender_name_callback();
|
471 |
print '</fieldset>';
|
472 |
|
473 |
// Wizard Step 2
|
474 |
+
printf( '<h5>%s</h5>', __( 'Outgoing Mail Server Hostname', 'post-smtp' ) );
|
475 |
print '<fieldset>';
|
476 |
foreach ( PostmanTransportRegistry::getInstance()->getTransports() as $transport ) {
|
477 |
$transport->printWizardMailServerHostnameStep();
|
479 |
print '</fieldset>';
|
480 |
|
481 |
// Wizard Step 3
|
482 |
+
printf( '<h5>%s</h5>', __( 'Connectivity Test', 'post-smtp' ) );
|
483 |
print '<fieldset>';
|
484 |
+
printf( '<legend>%s</legend>', __( 'How will the connection to the mail server be established?', 'post-smtp' ) );
|
485 |
+
printf( '<p>%s</p>', __( 'Your connection settings depend on what your email service provider offers, and what your WordPress host allows.', 'post-smtp' ) );
|
486 |
+
printf( '<p id="connectivity_test_status">%s: <span id="port_test_status">%s</span></p>', __( 'Connectivity Test', 'post-smtp' ), _x( 'Ready', 'TCP Port Test Status', 'post-smtp' ) );
|
487 |
printf( '<p class="ajax-loader" style="display:none"><img src="%s"/></p>', plugins_url( 'post-smtp/style/ajax-loader.gif' ) );
|
488 |
printf( '<input type="hidden" id="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::TRANSPORT_TYPE );
|
489 |
printf( '<input type="hidden" id="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::PORT );
|
491 |
printf( '<input type="hidden" id="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::AUTHENTICATION_TYPE );
|
492 |
print '<p id="wizard_recommendation"></p>';
|
493 |
/* Translators: Where %1$s is the socket identifier and %2$s is the authentication type */
|
494 |
+
printf( '<p class="user_override" style="display:none"><label><span>%s:</span></label> <table id="user_socket_override" class="user_override"></table></p>', _x( 'Socket', 'A socket is the network term for host and port together', 'post-smtp' ) );
|
495 |
+
printf( '<p class="user_override" style="display:none"><label><span>%s:</span></label> <table id="user_auth_override" class="user_override"></table></p>', __( 'Authentication', 'post-smtp' ) );
|
496 |
print ('<p><span id="smtp_mitm" style="display:none; background-color:yellow"></span></p>') ;
|
497 |
+
$warning = __( 'Warning', 'post-smtp' );
|
498 |
+
$clearCredentialsWarning = __( 'This configuration option will send your authorization credentials in the clear.', 'post-smtp' );
|
499 |
printf( '<p id="smtp_not_secure" style="display:none"><span style="background-color:yellow">%s: %s</span></p>', $warning, $clearCredentialsWarning );
|
500 |
print '</fieldset>';
|
501 |
|
502 |
// Wizard Step 4
|
503 |
+
printf( '<h5>%s</h5>', __( 'Authentication', 'post-smtp' ) );
|
504 |
print '<fieldset>';
|
505 |
+
printf( '<legend>%s</legend>', __( 'How will you prove your identity to the mail server?', 'post-smtp' ) );
|
506 |
foreach ( PostmanTransportRegistry::getInstance()->getTransports() as $transport ) {
|
507 |
$transport->printWizardAuthenticationStep();
|
508 |
}
|
509 |
print '</fieldset>';
|
510 |
|
511 |
// Wizard Step 5 - Notificiations
|
512 |
+
printf( '<h5>%s</h5>', __( 'Notifications', 'post-smtp' ) );
|
513 |
print '<fieldset>';
|
514 |
+
printf( '<legend>%s</legend>', __( 'Select a notify service to notify you when an email is failed to delivered.', 'post-smtp' ) );
|
515 |
|
516 |
?>
|
517 |
<select id="input_notification_service" class="input_notification_service" name="postman_options[notification_service]">
|
520 |
<option value="slack">Slack</option>
|
521 |
</select>
|
522 |
<div id="pushover_cred" style="display: none;">
|
523 |
+
<h2><?php _e( 'Pushover Credentials', 'post-smtp' ); ?></h2>
|
524 |
<table class="form-table">
|
525 |
<tbody>
|
526 |
<tr>
|
527 |
+
<th scope="row"><?php _e( 'Pushover User Key', 'post-smtp' ); ?></th>
|
528 |
<td>
|
529 |
<input type="password" id="pushover_user" name="postman_options[pushover_user]" value="">
|
530 |
</td>
|
531 |
</tr>
|
532 |
<tr>
|
533 |
+
<th scope="row"><?php _e( 'Pushover App Token', 'post-smtp' ); ?></th>
|
534 |
<td>
|
535 |
<input type="password" id="pushover_token" name="postman_options[pushover_token]" value="">
|
536 |
</td>
|
539 |
</table>
|
540 |
</div>
|
541 |
<div id="slack_cred" style="display: none;">
|
542 |
+
<h2><?php _e( 'Slack Credentials', 'post-smtp' ); ?></h2>
|
543 |
<table class="form-table">
|
544 |
<tbody>
|
545 |
<tr>
|
546 |
+
<th scope="row"><?php _e( 'Slack webhook', 'post-smtp' ); ?></th>
|
547 |
<td>
|
548 |
<input type="password" id="slack_token" name="postman_options[slack_token]" value="">
|
549 |
<a target="_blank" class="" href="https://slack.postmansmtp.com/">
|
550 |
+
<?php _e( 'Get your webhook URL here.', 'post-smtp' ); ?>
|
551 |
</a>
|
552 |
</td>
|
553 |
</tr>
|
556 |
</div>
|
557 |
|
558 |
<div id="use-chrome-extension">
|
559 |
+
<h2><?php _e( 'Push To Chrome Extension', 'post-smtp' ); ?></h2>
|
560 |
<table class="form-table">
|
561 |
<tbody>
|
562 |
<tr>
|
563 |
+
<th scope="row"><?php _e( 'This is an extra notification to the selection above', 'post-smtp' ); ?></th>
|
564 |
<td>
|
565 |
<input type="checkbox" id="notification_use_chrome" name="postman_options[notification_use_chrome]">
|
566 |
<a target="_blank" class="" href="https://chrome.google.com/webstore/detail/npklmbkpbknkmbohdbpikeidiaekjoch">
|
567 |
+
<?php _e( 'You can download the chrome extension here.', 'post-smtp' ); ?>
|
568 |
</a>
|
569 |
</td>
|
570 |
</tr>
|
571 |
<tr>
|
572 |
+
<th scope="row"><?php _e( 'Your UID as you see in the extension.', 'post-smtp' ); ?></th>
|
573 |
<td>
|
574 |
<input type="password" id="notification_chrome_uid" name="postman_options[notification_chrome_uid]" value="">
|
575 |
</td>
|
582 |
print '</fieldset>';
|
583 |
|
584 |
// Wizard Step 6
|
585 |
+
printf( '<h5>%s</h5>', _x( 'Finish', 'The final step of the Wizard', 'post-smtp' ) );
|
586 |
print '<fieldset>';
|
587 |
+
printf( '<legend>%s</legend>', _x( 'You\'re Done!', 'Wizard Step Title', 'post-smtp' ) );
|
588 |
print '<section>';
|
589 |
+
printf( '<p>%s</p>', __( 'Click Finish to save these settings, then:', 'post-smtp' ) );
|
590 |
print '<ul style="margin-left: 20px">';
|
591 |
+
printf( '<li class="wizard-auth-oauth2">%s</li>', __( 'Grant permission with the Email Provider for Postman to send email and', 'post-smtp' ) );
|
592 |
+
printf( '<li>%s</li>', __( 'Send yourself a Test Email to make sure everything is working!', 'post-smtp' ) );
|
593 |
print '</ul>';
|
594 |
+
|
595 |
+
// Get PHPmailer recommendation
|
596 |
+
Postman::getMailerTypeRecommend();
|
597 |
+
|
598 |
+
$in_wizard = true;
|
599 |
+
include_once POST_PATH . '/Postman/extra/donation.php';
|
600 |
+
|
601 |
print '</section>';
|
602 |
print '</fieldset>';
|
603 |
print '</form>';
|
739 |
wp_send_json_success( $response );
|
740 |
} else {
|
741 |
/* translators: where %s is the URL to the Connectivity Test page */
|
742 |
+
$configuration ['message'] = sprintf( __( 'Postman can\'t find any way to send mail on your system. Run a <a href="%s">connectivity test</a>.', 'post-smtp' ), PostmanViewController::getPageUrl( PostmanViewController::PORT_TEST_SLUG ) );
|
743 |
$response ['configuration'] = $configuration;
|
744 |
if ( $this->logger->isTrace() ) {
|
745 |
$this->logger->trace( 'configuration:' );
|
754 |
* // ask a transport if they support it, and if they do at what priority is it
|
755 |
* // configure for the highest priority you find
|
756 |
*
|
757 |
+
* @param mixed $queryHostData
|
758 |
+
* @return mixed
|
759 |
*/
|
760 |
private function getWinningRecommendation( $sockets, $userSocketOverride, $userAuthOverride, $originalSmtpServer ) {
|
761 |
foreach ( $sockets as $socket ) {
|
767 |
|
768 |
/**
|
769 |
*
|
770 |
+
* @param PostmanWizardSocket $socket
|
771 |
+
* @param mixed $userSocketOverride
|
772 |
+
* @param mixed $userAuthOverride
|
773 |
+
* @param mixed $originalSmtpServer
|
774 |
+
* @return mixed
|
775 |
*/
|
776 |
private function getWin( PostmanWizardSocket $socket, $userSocketOverride, $userAuthOverride, $originalSmtpServer ) {
|
777 |
static $recommendationPriority = - 1;
|
799 |
|
800 |
/**
|
801 |
*
|
802 |
+
* @param mixed $queryHostData
|
803 |
* @return multitype:
|
804 |
*/
|
805 |
private function createOverrideMenus( $sockets, $winningRecommendation, $userSocketOverride, $userAuthOverride ) {
|
824 |
/**
|
825 |
*
|
826 |
* @param PostmanWizardSocket $socket
|
827 |
+
* @param mixed $winningRecommendation
|
828 |
+
* @param mixed $userSocketOverride
|
829 |
+
* @param mixed $userAuthOverride
|
830 |
*/
|
831 |
private function createOverrideMenu( PostmanWizardSocket $socket, $winningRecommendation, $userSocketOverride, $userAuthOverride ) {
|
832 |
if ( $socket->success ) {
|
Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php
CHANGED
@@ -28,23 +28,28 @@ class PostmanSettingsRegistry {
|
|
28 |
) );
|
29 |
|
30 |
// Sanitize
|
31 |
-
add_settings_section( 'transport_section', __( 'Transport',
|
32 |
$this,
|
33 |
'printTransportSectionInfo',
|
34 |
), 'transport_options' );
|
35 |
|
36 |
-
add_settings_field( PostmanOptions::TRANSPORT_TYPE, _x( 'Type', '(i.e.) What kind is it?',
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
// the Message From section
|
42 |
-
add_settings_section( PostmanAdminController::MESSAGE_FROM_SECTION, _x( 'From Address', 'The Message Sender Email Address',
|
43 |
$this,
|
44 |
'printMessageFromSectionInfo',
|
45 |
), PostmanAdminController::MESSAGE_FROM_OPTIONS );
|
46 |
|
47 |
-
add_settings_field( PostmanOptions::MESSAGE_SENDER_EMAIL, __( 'Email Address',
|
48 |
$this,
|
49 |
'from_email_callback',
|
50 |
), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION );
|
@@ -54,7 +59,7 @@ class PostmanSettingsRegistry {
|
|
54 |
'prevent_from_email_override_callback',
|
55 |
), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION );
|
56 |
|
57 |
-
add_settings_field( PostmanOptions::MESSAGE_SENDER_NAME, __( 'Name',
|
58 |
$this,
|
59 |
'sender_name_callback',
|
60 |
), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION );
|
@@ -65,38 +70,38 @@ class PostmanSettingsRegistry {
|
|
65 |
), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION );
|
66 |
|
67 |
// the Additional Addresses section
|
68 |
-
add_settings_section( PostmanAdminController::MESSAGE_SECTION, __( 'Additional Email Addresses',
|
69 |
$this,
|
70 |
'printMessageSectionInfo',
|
71 |
), PostmanAdminController::MESSAGE_OPTIONS );
|
72 |
|
73 |
-
add_settings_field( PostmanOptions::REPLY_TO, __( 'Reply-To',
|
74 |
$this,
|
75 |
'reply_to_callback',
|
76 |
), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION );
|
77 |
|
78 |
-
add_settings_field( PostmanOptions::FORCED_TO_RECIPIENTS, __( 'To Recipient(s)',
|
79 |
$this,
|
80 |
'to_callback',
|
81 |
), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION );
|
82 |
|
83 |
-
add_settings_field( PostmanOptions::FORCED_CC_RECIPIENTS, __( 'Carbon Copy Recipient(s)',
|
84 |
$this,
|
85 |
'cc_callback',
|
86 |
), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION );
|
87 |
|
88 |
-
add_settings_field( PostmanOptions::FORCED_BCC_RECIPIENTS, __( 'Blind Carbon Copy Recipient(s)',
|
89 |
$this,
|
90 |
'bcc_callback',
|
91 |
), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION );
|
92 |
|
93 |
// the Additional Headers section
|
94 |
-
add_settings_section( PostmanAdminController::MESSAGE_HEADERS_SECTION, __( 'Additional Headers',
|
95 |
$this,
|
96 |
'printAdditionalHeadersSectionInfo',
|
97 |
), PostmanAdminController::MESSAGE_HEADERS_OPTIONS );
|
98 |
|
99 |
-
add_settings_field( PostmanOptions::ADDITIONAL_HEADERS, __( 'Custom Headers',
|
100 |
$this,
|
101 |
'headers_callback',
|
102 |
), PostmanAdminController::MESSAGE_HEADERS_OPTIONS, PostmanAdminController::MESSAGE_HEADERS_SECTION );
|
@@ -104,123 +109,123 @@ class PostmanSettingsRegistry {
|
|
104 |
// Fallback
|
105 |
|
106 |
// the Email Validation section
|
107 |
-
add_settings_section( PostmanAdminController::EMAIL_VALIDATION_SECTION, __( 'Validation',
|
108 |
$this,
|
109 |
'printEmailValidationSectionInfo',
|
110 |
), PostmanAdminController::EMAIL_VALIDATION_OPTIONS );
|
111 |
|
112 |
-
add_settings_field( PostmanOptions::ENVELOPE_SENDER, __( 'Email Address',
|
113 |
$this,
|
114 |
'disable_email_validation_callback',
|
115 |
), PostmanAdminController::EMAIL_VALIDATION_OPTIONS, PostmanAdminController::EMAIL_VALIDATION_SECTION );
|
116 |
|
117 |
// the Logging section
|
118 |
-
add_settings_section( PostmanAdminController::LOGGING_SECTION, __( 'Email Log Settings',
|
119 |
$this,
|
120 |
'printLoggingSectionInfo',
|
121 |
), PostmanAdminController::LOGGING_OPTIONS );
|
122 |
|
123 |
-
add_settings_field( 'logging_status', __( 'Enable Logging',
|
124 |
$this,
|
125 |
'loggingStatusInputField',
|
126 |
), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION );
|
127 |
|
128 |
-
add_settings_field( 'logging_max_entries', __( 'Maximum Log Entries',
|
129 |
$this,
|
130 |
'loggingMaxEntriesInputField',
|
131 |
), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION );
|
132 |
|
133 |
-
add_settings_field( PostmanOptions::TRANSCRIPT_SIZE, __( 'Maximum Transcript Size',
|
134 |
$this,
|
135 |
'transcriptSizeInputField',
|
136 |
), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION );
|
137 |
|
138 |
// the Network section
|
139 |
-
add_settings_section( PostmanAdminController::NETWORK_SECTION, __( 'Network Settings',
|
140 |
$this,
|
141 |
'printNetworkSectionInfo',
|
142 |
), PostmanAdminController::NETWORK_OPTIONS );
|
143 |
|
144 |
-
add_settings_field( 'connection_timeout', _x( 'TCP Connection Timeout (sec)', 'Configuration Input Field',
|
145 |
$this,
|
146 |
'connection_timeout_callback',
|
147 |
), PostmanAdminController::NETWORK_OPTIONS, PostmanAdminController::NETWORK_SECTION );
|
148 |
|
149 |
-
add_settings_field( 'read_timeout', _x( 'TCP Read Timeout (sec)', 'Configuration Input Field',
|
150 |
$this,
|
151 |
'read_timeout_callback',
|
152 |
), PostmanAdminController::NETWORK_OPTIONS, PostmanAdminController::NETWORK_SECTION );
|
153 |
|
154 |
// the Advanced section
|
155 |
-
add_settings_section( PostmanAdminController::ADVANCED_SECTION, _x( 'Miscellaneous Settings', 'Configuration Section Title',
|
156 |
$this,
|
157 |
'printAdvancedSectionInfo',
|
158 |
), PostmanAdminController::ADVANCED_OPTIONS );
|
159 |
|
160 |
-
add_settings_field( PostmanOptions::LOG_LEVEL, _x( 'PHP Log Level', 'Configuration Input Field',
|
161 |
$this,
|
162 |
'log_level_callback',
|
163 |
), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION );
|
164 |
|
165 |
-
add_settings_field( PostmanOptions::RUN_MODE, _x( 'Delivery Mode', 'Configuration Input Field',
|
166 |
$this,
|
167 |
'runModeCallback',
|
168 |
), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION );
|
169 |
|
170 |
-
add_settings_field( PostmanOptions::STEALTH_MODE, _x( 'Stealth Mode', 'This mode removes the Postman X-Mailer signature from emails',
|
171 |
$this,
|
172 |
'stealthModeCallback',
|
173 |
), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION );
|
174 |
|
175 |
-
add_settings_field( PostmanOptions::TEMPORARY_DIRECTORY, __( 'Temporary Directory',
|
176 |
$this,
|
177 |
'temporaryDirectoryCallback',
|
178 |
), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION );
|
179 |
|
180 |
// Notifications
|
181 |
-
add_settings_section( PostmanAdminController::NOTIFICATIONS_SECTION, _x( 'Notifications Settings', 'Configuration Section Title',
|
182 |
$this,
|
183 |
'printNotificationsSectionInfo',
|
184 |
), PostmanAdminController::NOTIFICATIONS_OPTIONS );
|
185 |
|
186 |
-
add_settings_field( PostmanOptions::NOTIFICATION_SERVICE, _x( 'Notification Service', 'Configuration Input Field',
|
187 |
$this,
|
188 |
'notification_service_callback',
|
189 |
), PostmanAdminController::NOTIFICATIONS_OPTIONS, PostmanAdminController::NOTIFICATIONS_SECTION );
|
190 |
|
191 |
// Pushover
|
192 |
-
add_settings_section( 'pushover_credentials', _x( 'Pushover Credentials', 'Configuration Section Title',
|
193 |
$this,
|
194 |
'printNotificationsSectionInfo',
|
195 |
), PostmanAdminController::NOTIFICATIONS_PUSHOVER_CRED );
|
196 |
|
197 |
-
add_settings_field( PostmanOptions::PUSHOVER_USER, _x( 'Pushover User Key', 'Configuration Input Field',
|
198 |
$this,
|
199 |
'pushover_user_callback',
|
200 |
), PostmanAdminController::NOTIFICATIONS_PUSHOVER_CRED, 'pushover_credentials' );
|
201 |
|
202 |
-
add_settings_field( PostmanOptions::PUSHOVER_TOKEN, _x( 'Pushover App Token', 'Configuration Input Field',
|
203 |
$this,
|
204 |
'pushover_token_callback',
|
205 |
), PostmanAdminController::NOTIFICATIONS_PUSHOVER_CRED, 'pushover_credentials' );
|
206 |
|
207 |
// Slack
|
208 |
-
add_settings_section( 'slack_credentials', _x( 'Slack Credentials', 'Configuration Section Title',
|
209 |
$this,
|
210 |
'printNotificationsSectionInfo',
|
211 |
), PostmanAdminController::NOTIFICATIONS_SLACK_CRED );
|
212 |
|
213 |
-
add_settings_field( PostmanOptions::SLACK_TOKEN, _x( 'Slack Webhook', 'Configuration Input Field',
|
214 |
$this,
|
215 |
'slack_token_callback',
|
216 |
), PostmanAdminController::NOTIFICATIONS_SLACK_CRED, 'slack_credentials' );
|
217 |
|
218 |
-
add_settings_field( PostmanOptions::NOTIFICATION_USE_CHROME, _x( 'Push to chrome extension', 'Configuration Input Field',
|
219 |
$this,
|
220 |
'notification_use_chrome_callback',
|
221 |
), PostmanAdminController::NOTIFICATIONS_OPTIONS, PostmanAdminController::NOTIFICATIONS_SECTION );
|
222 |
|
223 |
-
add_settings_field( PostmanOptions::NOTIFICATION_CHROME_UID, _x( 'Chrome Extension UID', 'Configuration Input Field',
|
224 |
$this,
|
225 |
'notification_chrome_uid_callback',
|
226 |
), PostmanAdminController::NOTIFICATIONS_OPTIONS, PostmanAdminController::NOTIFICATIONS_SECTION );
|
@@ -232,31 +237,31 @@ class PostmanSettingsRegistry {
|
|
232 |
* Print the Transport section info
|
233 |
*/
|
234 |
public function printTransportSectionInfo() {
|
235 |
-
print __( 'Choose SMTP or a vendor-specific API:',
|
236 |
}
|
237 |
public function printLoggingSectionInfo() {
|
238 |
-
print __( 'Configure the delivery audit log:',
|
239 |
}
|
240 |
|
241 |
/**
|
242 |
* Print the Section text
|
243 |
*/
|
244 |
public function printMessageFromSectionInfo() {
|
245 |
-
print sprintf( __( 'This address, like the <b>letterhead</b> printed on a letter, identifies the sender to the recipient. Change this when you are sending on behalf of someone else, for example to use Google\'s <a href="%s">Send Mail As</a> feature. Other plugins, especially Contact Forms, may override this field to be your visitor\'s address.',
|
246 |
}
|
247 |
|
248 |
/**
|
249 |
* Print the Section text
|
250 |
*/
|
251 |
public function printMessageSectionInfo() {
|
252 |
-
print __( 'Separate multiple <b>to</b>/<b>cc</b>/<b>bcc</b> recipients with commas.',
|
253 |
}
|
254 |
|
255 |
/**
|
256 |
* Print the Section text
|
257 |
*/
|
258 |
public function printNetworkSectionInfo() {
|
259 |
-
print __( 'Increase the timeouts if your host is intermittenly failing to send mail. Be careful, this also correlates to how long your user must wait if the mail server is unreachable.',
|
260 |
}
|
261 |
|
262 |
/**
|
@@ -275,14 +280,14 @@ class PostmanSettingsRegistry {
|
|
275 |
* Print the Section text
|
276 |
*/
|
277 |
public function printAdditionalHeadersSectionInfo() {
|
278 |
-
print __( 'Specify custom headers (e.g. <code>X-MC-Tags: wordpress-site-A</code>), one per line. Use custom headers with caution as they can negatively affect your Spam score.',
|
279 |
}
|
280 |
|
281 |
/**
|
282 |
* Print the Email Validation Description
|
283 |
*/
|
284 |
public function printEmailValidationSectionInfo() {
|
285 |
-
print __( 'E-mail addresses can be validated before sending e-mail, however this may fail with some newer domains.',
|
286 |
}
|
287 |
|
288 |
/**
|
@@ -297,6 +302,22 @@ class PostmanSettingsRegistry {
|
|
297 |
print '</select>';
|
298 |
}
|
299 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
/**
|
301 |
* Get the settings option array and print one of its values
|
302 |
*/
|
@@ -308,21 +329,21 @@ class PostmanSettingsRegistry {
|
|
308 |
*/
|
309 |
public function prevent_from_name_override_callback() {
|
310 |
$enforced = $this->options->isPluginSenderNameEnforced();
|
311 |
-
printf( '<input type="checkbox" id="input_prevent_sender_name_override" name="postman_options[prevent_sender_name_override]" %s /> %s', $enforced ? 'checked="checked"' : '', __( 'Prevent <b>plugins</b> and <b>themes</b> from changing this',
|
312 |
}
|
313 |
|
314 |
/**
|
315 |
* Get the settings option array and print one of its values
|
316 |
*/
|
317 |
public function from_email_callback() {
|
318 |
-
printf( '<input type="email" id="input_sender_email" name="postman_options[sender_email]" value="%s" size="40" class="required" placeholder="%s"/>', null !== $this->options->getMessageSenderEmail() ? esc_attr( $this->options->getMessageSenderEmail() ) : '', __( 'Required',
|
319 |
}
|
320 |
|
321 |
/**
|
322 |
* Print the Section text
|
323 |
*/
|
324 |
public function printMessageSenderSectionInfo() {
|
325 |
-
print sprintf( __( 'This address, like the <b>return address</b> printed on an envelope, identifies the account owner to the SMTP server.',
|
326 |
}
|
327 |
|
328 |
/**
|
@@ -330,7 +351,7 @@ class PostmanSettingsRegistry {
|
|
330 |
*/
|
331 |
public function prevent_from_email_override_callback() {
|
332 |
$enforced = $this->options->isPluginSenderEmailEnforced();
|
333 |
-
printf( '<input type="checkbox" id="input_prevent_sender_email_override" name="postman_options[prevent_sender_email_override]" %s /> %s', $enforced ? 'checked="checked"' : '', __( 'Prevent <b>plugins</b> and <b>themes</b> from changing this',
|
334 |
}
|
335 |
|
336 |
/**
|
@@ -343,8 +364,8 @@ class PostmanSettingsRegistry {
|
|
343 |
$disabled = 'disabled="disabled" ';
|
344 |
}
|
345 |
printf( '<select ' . $disabled . 'id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::MAIL_LOG_ENABLED_OPTION );
|
346 |
-
printf( '<option value="%s" %s>%s</option>', PostmanOptions::MAIL_LOG_ENABLED_OPTION_YES, $this->options->isMailLoggingEnabled() ? 'selected="selected"' : '', __( 'Yes',
|
347 |
-
printf( '<option value="%s" %s>%s</option>', PostmanOptions::MAIL_LOG_ENABLED_OPTION_NO, ! $this->options->isMailLoggingEnabled() ? 'selected="selected"' : '', __( 'No',
|
348 |
printf( '</select>' );
|
349 |
}
|
350 |
public function loggingMaxEntriesInputField() {
|
@@ -354,7 +375,7 @@ class PostmanSettingsRegistry {
|
|
354 |
$inputOptionsSlug = PostmanOptions::POSTMAN_OPTIONS;
|
355 |
$inputTranscriptSlug = PostmanOptions::TRANSCRIPT_SIZE;
|
356 |
$inputValue = $this->options->getTranscriptSize();
|
357 |
-
$inputDescription = __( 'Change this value if you can\'t see the beginning of the transcript because your messages are too big.',
|
358 |
printf( '<input type="text" id="input%2$s" name="%1$s[%2$s]" value="%3$s"/><br/><span class="postman_input_description">%4$s</span>', $inputOptionsSlug, $inputTranscriptSlug, $inputValue, $inputDescription );
|
359 |
}
|
360 |
|
@@ -397,22 +418,22 @@ class PostmanSettingsRegistry {
|
|
397 |
*/
|
398 |
public function disable_email_validation_callback() {
|
399 |
$disabled = $this->options->isEmailValidationDisabled();
|
400 |
-
printf( '<input type="checkbox" id="%2$s" name="%1$s[%2$s]" %3$s /> %4$s', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::DISABLE_EMAIL_VALIDAITON, $disabled ? 'checked="checked"' : '', __( 'Disable e-mail validation',
|
401 |
}
|
402 |
|
403 |
/**
|
404 |
* Get the settings option array and print one of its values
|
405 |
*/
|
406 |
public function log_level_callback() {
|
407 |
-
$inputDescription = sprintf( __( 'Log Level specifies the level of detail written to the <a target="_blank" href="%s">WordPress Debug log</a> - view the log with <a target-"_new" href="%s">Debug</a>.',
|
408 |
printf( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::LOG_LEVEL );
|
409 |
$currentKey = $this->options->getLogLevel();
|
410 |
-
$this->printSelectOption( __( 'Off',
|
411 |
-
$this->printSelectOption( __( 'Trace',
|
412 |
-
$this->printSelectOption( __( 'Debug',
|
413 |
-
$this->printSelectOption( __( 'Info',
|
414 |
-
$this->printSelectOption( __( 'Warning',
|
415 |
-
$this->printSelectOption( __( 'Error',
|
416 |
printf( '</select><br/><span class="postman_input_description">%s</span>', $inputDescription );
|
417 |
}
|
418 |
|
@@ -421,9 +442,9 @@ class PostmanSettingsRegistry {
|
|
421 |
printf( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::NOTIFICATION_SERVICE );
|
422 |
$currentKey = $this->options->getNotificationService();
|
423 |
|
424 |
-
$this->printSelectOption( __( 'Email',
|
425 |
-
$this->printSelectOption( __( 'Pushover',
|
426 |
-
$this->printSelectOption( __( 'Slack',
|
427 |
printf( '</select><br/><span class="postman_input_description">%s</span>', $inputDescription );
|
428 |
}
|
429 |
|
@@ -446,7 +467,7 @@ class PostmanSettingsRegistry {
|
|
446 |
|
447 |
public function slack_token_callback() {
|
448 |
printf( '<input type="password" id="slack_token" name="%s[%s]" value="%s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::SLACK_TOKEN, $this->options->getSlackToken() );
|
449 |
-
echo '<a target="_blank" href="https://slack.postmansmtp.com/">' . __( 'Get your webhook URL here',
|
450 |
|
451 |
}
|
452 |
|
@@ -455,26 +476,26 @@ class PostmanSettingsRegistry {
|
|
455 |
printf( $optionPattern, $optionKey, $optionKey == $currentKey ? 'selected="selected"' : '', $label );
|
456 |
}
|
457 |
public function runModeCallback() {
|
458 |
-
$inputDescription = __( 'Delivery mode offers options useful for developing or testing.',
|
459 |
printf( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::RUN_MODE );
|
460 |
$currentKey = $this->options->getRunMode();
|
461 |
-
$this->printSelectOption( _x( 'Log Email and Send', 'When the server is online to the public, this is "Production" mode',
|
462 |
-
$this->printSelectOption( __( 'Log Email and Delete',
|
463 |
-
$this->printSelectOption( __( 'Delete All Emails',
|
464 |
printf( '</select><br/><span class="postman_input_description">%s</span>', $inputDescription );
|
465 |
}
|
466 |
|
467 |
public function stealthModeCallback() {
|
468 |
-
printf( '<input type="checkbox" id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]" %3$s /> %4$s', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::STEALTH_MODE, $this->options->isStealthModeEnabled() ? 'checked="checked"' : '', __( 'Remove the Postman X-Header signature from messages',
|
469 |
}
|
470 |
|
471 |
public function temporaryDirectoryCallback() {
|
472 |
$inputDescription = __( 'Lockfiles are written here to prevent users from triggering an OAuth 2.0 token refresh at the same time.' );
|
473 |
printf( '<input type="text" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::TEMPORARY_DIRECTORY, $this->options->getTempDirectory() );
|
474 |
if ( PostmanState::getInstance()->isFileLockingEnabled() ) {
|
475 |
-
printf( ' <span style="color:green">%s</span></br><span class="postman_input_description">%s</span>', __( 'Valid',
|
476 |
} else {
|
477 |
-
printf( ' <span style="color:red">%s</span></br><span class="postman_input_description">%s</span>', __( 'Invalid',
|
478 |
}
|
479 |
}
|
480 |
|
@@ -496,6 +517,6 @@ class PostmanSettingsRegistry {
|
|
496 |
* Get the settings option array and print one of its values
|
497 |
*/
|
498 |
public function port_callback( $args ) {
|
499 |
-
printf( '<input type="text" id="input_port" name="postman_options[port]" value="%s" %s placeholder="%s"/>', null !== $this->options->getPort() ? esc_attr( $this->options->getPort() ) : '', isset( $args ['style'] ) ? $args ['style'] : '', __( 'Required',
|
500 |
}
|
501 |
}
|
28 |
) );
|
29 |
|
30 |
// Sanitize
|
31 |
+
add_settings_section( 'transport_section', __( 'Transport', 'post-smtp' ), array(
|
32 |
$this,
|
33 |
'printTransportSectionInfo',
|
34 |
), 'transport_options' );
|
35 |
|
36 |
+
add_settings_field( PostmanOptions::TRANSPORT_TYPE, _x( 'Type', '(i.e.) What kind is it?', 'post-smtp' ), array(
|
37 |
+
$this,
|
38 |
+
'transport_type_callback',
|
39 |
+
), 'transport_options', 'transport_section' );
|
40 |
+
|
41 |
+
add_settings_field( 'smtp_mailers', __( 'Mailer Type', 'post-smtp' ), array(
|
42 |
+
$this,
|
43 |
+
'smtp_mailer_callback',
|
44 |
+
), 'transport_options', 'transport_section' );
|
45 |
|
46 |
// the Message From section
|
47 |
+
add_settings_section( PostmanAdminController::MESSAGE_FROM_SECTION, _x( 'From Address', 'The Message Sender Email Address', 'post-smtp' ), array(
|
48 |
$this,
|
49 |
'printMessageFromSectionInfo',
|
50 |
), PostmanAdminController::MESSAGE_FROM_OPTIONS );
|
51 |
|
52 |
+
add_settings_field( PostmanOptions::MESSAGE_SENDER_EMAIL, __( 'Email Address', 'post-smtp' ), array(
|
53 |
$this,
|
54 |
'from_email_callback',
|
55 |
), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION );
|
59 |
'prevent_from_email_override_callback',
|
60 |
), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION );
|
61 |
|
62 |
+
add_settings_field( PostmanOptions::MESSAGE_SENDER_NAME, __( 'Name', 'post-smtp' ), array(
|
63 |
$this,
|
64 |
'sender_name_callback',
|
65 |
), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION );
|
70 |
), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION );
|
71 |
|
72 |
// the Additional Addresses section
|
73 |
+
add_settings_section( PostmanAdminController::MESSAGE_SECTION, __( 'Additional Email Addresses', 'post-smtp' ), array(
|
74 |
$this,
|
75 |
'printMessageSectionInfo',
|
76 |
), PostmanAdminController::MESSAGE_OPTIONS );
|
77 |
|
78 |
+
add_settings_field( PostmanOptions::REPLY_TO, __( 'Reply-To', 'post-smtp' ), array(
|
79 |
$this,
|
80 |
'reply_to_callback',
|
81 |
), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION );
|
82 |
|
83 |
+
add_settings_field( PostmanOptions::FORCED_TO_RECIPIENTS, __( 'To Recipient(s)', 'post-smtp' ), array(
|
84 |
$this,
|
85 |
'to_callback',
|
86 |
), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION );
|
87 |
|
88 |
+
add_settings_field( PostmanOptions::FORCED_CC_RECIPIENTS, __( 'Carbon Copy Recipient(s)', 'post-smtp' ), array(
|
89 |
$this,
|
90 |
'cc_callback',
|
91 |
), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION );
|
92 |
|
93 |
+
add_settings_field( PostmanOptions::FORCED_BCC_RECIPIENTS, __( 'Blind Carbon Copy Recipient(s)', 'post-smtp' ), array(
|
94 |
$this,
|
95 |
'bcc_callback',
|
96 |
), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION );
|
97 |
|
98 |
// the Additional Headers section
|
99 |
+
add_settings_section( PostmanAdminController::MESSAGE_HEADERS_SECTION, __( 'Additional Headers', 'post-smtp' ), array(
|
100 |
$this,
|
101 |
'printAdditionalHeadersSectionInfo',
|
102 |
), PostmanAdminController::MESSAGE_HEADERS_OPTIONS );
|
103 |
|
104 |
+
add_settings_field( PostmanOptions::ADDITIONAL_HEADERS, __( 'Custom Headers', 'post-smtp' ), array(
|
105 |
$this,
|
106 |
'headers_callback',
|
107 |
), PostmanAdminController::MESSAGE_HEADERS_OPTIONS, PostmanAdminController::MESSAGE_HEADERS_SECTION );
|
109 |
// Fallback
|
110 |
|
111 |
// the Email Validation section
|
112 |
+
add_settings_section( PostmanAdminController::EMAIL_VALIDATION_SECTION, __( 'Validation', 'post-smtp' ), array(
|
113 |
$this,
|
114 |
'printEmailValidationSectionInfo',
|
115 |
), PostmanAdminController::EMAIL_VALIDATION_OPTIONS );
|
116 |
|
117 |
+
add_settings_field( PostmanOptions::ENVELOPE_SENDER, __( 'Email Address', 'post-smtp' ), array(
|
118 |
$this,
|
119 |
'disable_email_validation_callback',
|
120 |
), PostmanAdminController::EMAIL_VALIDATION_OPTIONS, PostmanAdminController::EMAIL_VALIDATION_SECTION );
|
121 |
|
122 |
// the Logging section
|
123 |
+
add_settings_section( PostmanAdminController::LOGGING_SECTION, __( 'Email Log Settings', 'post-smtp' ), array(
|
124 |
$this,
|
125 |
'printLoggingSectionInfo',
|
126 |
), PostmanAdminController::LOGGING_OPTIONS );
|
127 |
|
128 |
+
add_settings_field( 'logging_status', __( 'Enable Logging', 'post-smtp' ), array(
|
129 |
$this,
|
130 |
'loggingStatusInputField',
|
131 |
), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION );
|
132 |
|
133 |
+
add_settings_field( 'logging_max_entries', __( 'Maximum Log Entries', 'post-smtp' ), array(
|
134 |
$this,
|
135 |
'loggingMaxEntriesInputField',
|
136 |
), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION );
|
137 |
|
138 |
+
add_settings_field( PostmanOptions::TRANSCRIPT_SIZE, __( 'Maximum Transcript Size', 'post-smtp' ), array(
|
139 |
$this,
|
140 |
'transcriptSizeInputField',
|
141 |
), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION );
|
142 |
|
143 |
// the Network section
|
144 |
+
add_settings_section( PostmanAdminController::NETWORK_SECTION, __( 'Network Settings', 'post-smtp' ), array(
|
145 |
$this,
|
146 |
'printNetworkSectionInfo',
|
147 |
), PostmanAdminController::NETWORK_OPTIONS );
|
148 |
|
149 |
+
add_settings_field( 'connection_timeout', _x( 'TCP Connection Timeout (sec)', 'Configuration Input Field', 'post-smtp' ), array(
|
150 |
$this,
|
151 |
'connection_timeout_callback',
|
152 |
), PostmanAdminController::NETWORK_OPTIONS, PostmanAdminController::NETWORK_SECTION );
|
153 |
|
154 |
+
add_settings_field( 'read_timeout', _x( 'TCP Read Timeout (sec)', 'Configuration Input Field', 'post-smtp' ), array(
|
155 |
$this,
|
156 |
'read_timeout_callback',
|
157 |
), PostmanAdminController::NETWORK_OPTIONS, PostmanAdminController::NETWORK_SECTION );
|
158 |
|
159 |
// the Advanced section
|
160 |
+
add_settings_section( PostmanAdminController::ADVANCED_SECTION, _x( 'Miscellaneous Settings', 'Configuration Section Title', 'post-smtp' ), array(
|
161 |
$this,
|
162 |
'printAdvancedSectionInfo',
|
163 |
), PostmanAdminController::ADVANCED_OPTIONS );
|
164 |
|
165 |
+
add_settings_field( PostmanOptions::LOG_LEVEL, _x( 'PHP Log Level', 'Configuration Input Field', 'post-smtp' ), array(
|
166 |
$this,
|
167 |
'log_level_callback',
|
168 |
), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION );
|
169 |
|
170 |
+
add_settings_field( PostmanOptions::RUN_MODE, _x( 'Delivery Mode', 'Configuration Input Field', 'post-smtp' ), array(
|
171 |
$this,
|
172 |
'runModeCallback',
|
173 |
), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION );
|
174 |
|
175 |
+
add_settings_field( PostmanOptions::STEALTH_MODE, _x( 'Stealth Mode', 'This mode removes the Postman X-Mailer signature from emails', 'post-smtp' ), array(
|
176 |
$this,
|
177 |
'stealthModeCallback',
|
178 |
), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION );
|
179 |
|
180 |
+
add_settings_field( PostmanOptions::TEMPORARY_DIRECTORY, __( 'Temporary Directory', 'post-smtp' ), array(
|
181 |
$this,
|
182 |
'temporaryDirectoryCallback',
|
183 |
), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION );
|
184 |
|
185 |
// Notifications
|
186 |
+
add_settings_section( PostmanAdminController::NOTIFICATIONS_SECTION, _x( 'Notifications Settings', 'Configuration Section Title', 'post-smtp' ), array(
|
187 |
$this,
|
188 |
'printNotificationsSectionInfo',
|
189 |
), PostmanAdminController::NOTIFICATIONS_OPTIONS );
|
190 |
|
191 |
+
add_settings_field( PostmanOptions::NOTIFICATION_SERVICE, _x( 'Notification Service', 'Configuration Input Field', 'post-smtp' ), array(
|
192 |
$this,
|
193 |
'notification_service_callback',
|
194 |
), PostmanAdminController::NOTIFICATIONS_OPTIONS, PostmanAdminController::NOTIFICATIONS_SECTION );
|
195 |
|
196 |
// Pushover
|
197 |
+
add_settings_section( 'pushover_credentials', _x( 'Pushover Credentials', 'Configuration Section Title', 'post-smtp' ), array(
|
198 |
$this,
|
199 |
'printNotificationsSectionInfo',
|
200 |
), PostmanAdminController::NOTIFICATIONS_PUSHOVER_CRED );
|
201 |
|
202 |
+
add_settings_field( PostmanOptions::PUSHOVER_USER, _x( 'Pushover User Key', 'Configuration Input Field', 'post-smtp' ), array(
|
203 |
$this,
|
204 |
'pushover_user_callback',
|
205 |
), PostmanAdminController::NOTIFICATIONS_PUSHOVER_CRED, 'pushover_credentials' );
|
206 |
|
207 |
+
add_settings_field( PostmanOptions::PUSHOVER_TOKEN, _x( 'Pushover App Token', 'Configuration Input Field', 'post-smtp' ), array(
|
208 |
$this,
|
209 |
'pushover_token_callback',
|
210 |
), PostmanAdminController::NOTIFICATIONS_PUSHOVER_CRED, 'pushover_credentials' );
|
211 |
|
212 |
// Slack
|
213 |
+
add_settings_section( 'slack_credentials', _x( 'Slack Credentials', 'Configuration Section Title', 'post-smtp' ), array(
|
214 |
$this,
|
215 |
'printNotificationsSectionInfo',
|
216 |
), PostmanAdminController::NOTIFICATIONS_SLACK_CRED );
|
217 |
|
218 |
+
add_settings_field( PostmanOptions::SLACK_TOKEN, _x( 'Slack Webhook', 'Configuration Input Field', 'post-smtp' ), array(
|
219 |
$this,
|
220 |
'slack_token_callback',
|
221 |
), PostmanAdminController::NOTIFICATIONS_SLACK_CRED, 'slack_credentials' );
|
222 |
|
223 |
+
add_settings_field( PostmanOptions::NOTIFICATION_USE_CHROME, _x( 'Push to chrome extension', 'Configuration Input Field', 'post-smtp' ), array(
|
224 |
$this,
|
225 |
'notification_use_chrome_callback',
|
226 |
), PostmanAdminController::NOTIFICATIONS_OPTIONS, PostmanAdminController::NOTIFICATIONS_SECTION );
|
227 |
|
228 |
+
add_settings_field( PostmanOptions::NOTIFICATION_CHROME_UID, _x( 'Chrome Extension UID', 'Configuration Input Field', 'post-smtp' ), array(
|
229 |
$this,
|
230 |
'notification_chrome_uid_callback',
|
231 |
), PostmanAdminController::NOTIFICATIONS_OPTIONS, PostmanAdminController::NOTIFICATIONS_SECTION );
|
237 |
* Print the Transport section info
|
238 |
*/
|
239 |
public function printTransportSectionInfo() {
|
240 |
+
print __( 'Choose SMTP or a vendor-specific API:', 'post-smtp' );
|
241 |
}
|
242 |
public function printLoggingSectionInfo() {
|
243 |
+
print __( 'Configure the delivery audit log:', 'post-smtp' );
|
244 |
}
|
245 |
|
246 |
/**
|
247 |
* Print the Section text
|
248 |
*/
|
249 |
public function printMessageFromSectionInfo() {
|
250 |
+
print sprintf( __( 'This address, like the <b>letterhead</b> printed on a letter, identifies the sender to the recipient. Change this when you are sending on behalf of someone else, for example to use Google\'s <a href="%s">Send Mail As</a> feature. Other plugins, especially Contact Forms, may override this field to be your visitor\'s address.', 'post-smtp' ), 'https://support.google.com/mail/answer/22370?hl=en' );
|
251 |
}
|
252 |
|
253 |
/**
|
254 |
* Print the Section text
|
255 |
*/
|
256 |
public function printMessageSectionInfo() {
|
257 |
+
print __( 'Separate multiple <b>to</b>/<b>cc</b>/<b>bcc</b> recipients with commas.', 'post-smtp' );
|
258 |
}
|
259 |
|
260 |
/**
|
261 |
* Print the Section text
|
262 |
*/
|
263 |
public function printNetworkSectionInfo() {
|
264 |
+
print __( 'Increase the timeouts if your host is intermittenly failing to send mail. Be careful, this also correlates to how long your user must wait if the mail server is unreachable.', 'post-smtp' );
|
265 |
}
|
266 |
|
267 |
/**
|
280 |
* Print the Section text
|
281 |
*/
|
282 |
public function printAdditionalHeadersSectionInfo() {
|
283 |
+
print __( 'Specify custom headers (e.g. <code>X-MC-Tags: wordpress-site-A</code>), one per line. Use custom headers with caution as they can negatively affect your Spam score.', 'post-smtp' );
|
284 |
}
|
285 |
|
286 |
/**
|
287 |
* Print the Email Validation Description
|
288 |
*/
|
289 |
public function printEmailValidationSectionInfo() {
|
290 |
+
print __( 'E-mail addresses can be validated before sending e-mail, however this may fail with some newer domains.', 'post-smtp' );
|
291 |
}
|
292 |
|
293 |
/**
|
302 |
print '</select>';
|
303 |
}
|
304 |
|
305 |
+
/**
|
306 |
+
* Get the settings option array and print one of its values
|
307 |
+
*/
|
308 |
+
public function smtp_mailer_callback() {
|
309 |
+
$smtp_mailers = PostmanOptions::SMTP_MAILERS;
|
310 |
+
$current_smtp_mailer = $this->options->getSmtpMailer();
|
311 |
+
printf( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, 'smtp_mailers' );
|
312 |
+
foreach ( $smtp_mailers as $key => $smtp_mailer ) {
|
313 |
+
printf( '<option class="input_tx_type_%1$s" value="%1$s" %3$s>%2$s</option>', $key, $smtp_mailer, $current_smtp_mailer == $key ? 'selected="selected"' : '' );
|
314 |
+
}
|
315 |
+
print '</select>';
|
316 |
+
?>
|
317 |
+
<p class="description" id="mailer-type-description"><?php _e( 'Beta Feature: Change this to <strong>PHPMailer</strong> only if you see <code>wp_mail</code> conflict message, conflicts when another plugin is activated, and <strong><u>sometimes</u></strong> spam issues.', 'post-smtp' ); ?></p>
|
318 |
+
<?php
|
319 |
+
}
|
320 |
+
|
321 |
/**
|
322 |
* Get the settings option array and print one of its values
|
323 |
*/
|
329 |
*/
|
330 |
public function prevent_from_name_override_callback() {
|
331 |
$enforced = $this->options->isPluginSenderNameEnforced();
|
332 |
+
printf( '<input type="checkbox" id="input_prevent_sender_name_override" name="postman_options[prevent_sender_name_override]" %s /> %s', $enforced ? 'checked="checked"' : '', __( 'Prevent <b>plugins</b> and <b>themes</b> from changing this', 'post-smtp' ) );
|
333 |
}
|
334 |
|
335 |
/**
|
336 |
* Get the settings option array and print one of its values
|
337 |
*/
|
338 |
public function from_email_callback() {
|
339 |
+
printf( '<input type="email" id="input_sender_email" name="postman_options[sender_email]" value="%s" size="40" class="required" placeholder="%s"/>', null !== $this->options->getMessageSenderEmail() ? esc_attr( $this->options->getMessageSenderEmail() ) : '', __( 'Required', 'post-smtp' ) );
|
340 |
}
|
341 |
|
342 |
/**
|
343 |
* Print the Section text
|
344 |
*/
|
345 |
public function printMessageSenderSectionInfo() {
|
346 |
+
print sprintf( __( 'This address, like the <b>return address</b> printed on an envelope, identifies the account owner to the SMTP server.', 'post-smtp' ), 'https://support.google.com/mail/answer/22370?hl=en' );
|
347 |
}
|
348 |
|
349 |
/**
|
351 |
*/
|
352 |
public function prevent_from_email_override_callback() {
|
353 |
$enforced = $this->options->isPluginSenderEmailEnforced();
|
354 |
+
printf( '<input type="checkbox" id="input_prevent_sender_email_override" name="postman_options[prevent_sender_email_override]" %s /> %s', $enforced ? 'checked="checked"' : '', __( 'Prevent <b>plugins</b> and <b>themes</b> from changing this', 'post-smtp' ) );
|
355 |
}
|
356 |
|
357 |
/**
|
364 |
$disabled = 'disabled="disabled" ';
|
365 |
}
|
366 |
printf( '<select ' . $disabled . 'id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::MAIL_LOG_ENABLED_OPTION );
|
367 |
+
printf( '<option value="%s" %s>%s</option>', PostmanOptions::MAIL_LOG_ENABLED_OPTION_YES, $this->options->isMailLoggingEnabled() ? 'selected="selected"' : '', __( 'Yes', 'post-smtp' ) );
|
368 |
+
printf( '<option value="%s" %s>%s</option>', PostmanOptions::MAIL_LOG_ENABLED_OPTION_NO, ! $this->options->isMailLoggingEnabled() ? 'selected="selected"' : '', __( 'No', 'post-smtp' ) );
|
369 |
printf( '</select>' );
|
370 |
}
|
371 |
public function loggingMaxEntriesInputField() {
|
375 |
$inputOptionsSlug = PostmanOptions::POSTMAN_OPTIONS;
|
376 |
$inputTranscriptSlug = PostmanOptions::TRANSCRIPT_SIZE;
|
377 |
$inputValue = $this->options->getTranscriptSize();
|
378 |
+
$inputDescription = __( 'Change this value if you can\'t see the beginning of the transcript because your messages are too big.', 'post-smtp' );
|
379 |
printf( '<input type="text" id="input%2$s" name="%1$s[%2$s]" value="%3$s"/><br/><span class="postman_input_description">%4$s</span>', $inputOptionsSlug, $inputTranscriptSlug, $inputValue, $inputDescription );
|
380 |
}
|
381 |
|
418 |
*/
|
419 |
public function disable_email_validation_callback() {
|
420 |
$disabled = $this->options->isEmailValidationDisabled();
|
421 |
+
printf( '<input type="checkbox" id="%2$s" name="%1$s[%2$s]" %3$s /> %4$s', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::DISABLE_EMAIL_VALIDAITON, $disabled ? 'checked="checked"' : '', __( 'Disable e-mail validation', 'post-smtp' ) );
|
422 |
}
|
423 |
|
424 |
/**
|
425 |
* Get the settings option array and print one of its values
|
426 |
*/
|
427 |
public function log_level_callback() {
|
428 |
+
$inputDescription = sprintf( __( 'Log Level specifies the level of detail written to the <a target="_blank" href="%s">WordPress Debug log</a> - view the log with <a target-"_new" href="%s">Debug</a>.', 'post-smtp' ), 'https://codex.wordpress.org/Debugging_in_WordPress', 'https://wordpress.org/plugins/debug/' );
|
429 |
printf( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::LOG_LEVEL );
|
430 |
$currentKey = $this->options->getLogLevel();
|
431 |
+
$this->printSelectOption( __( 'Off', 'post-smtp' ), PostmanLogger::OFF_INT, $currentKey );
|
432 |
+
$this->printSelectOption( __( 'Trace', 'post-smtp' ), PostmanLogger::TRACE_INT, $currentKey );
|
433 |
+
$this->printSelectOption( __( 'Debug', 'post-smtp' ), PostmanLogger::DEBUG_INT, $currentKey );
|
434 |
+
$this->printSelectOption( __( 'Info', 'post-smtp' ), PostmanLogger::INFO_INT, $currentKey );
|
435 |
+
$this->printSelectOption( __( 'Warning', 'post-smtp' ), PostmanLogger::WARN_INT, $currentKey );
|
436 |
+
$this->printSelectOption( __( 'Error', 'post-smtp' ), PostmanLogger::ERROR_INT, $currentKey );
|
437 |
printf( '</select><br/><span class="postman_input_description">%s</span>', $inputDescription );
|
438 |
}
|
439 |
|
442 |
printf( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::NOTIFICATION_SERVICE );
|
443 |
$currentKey = $this->options->getNotificationService();
|
444 |
|
445 |
+
$this->printSelectOption( __( 'Email', 'post-smtp' ), 'default', $currentKey );
|
446 |
+
$this->printSelectOption( __( 'Pushover', 'post-smtp' ), 'pushover', $currentKey );
|
447 |
+
$this->printSelectOption( __( 'Slack', 'post-smtp' ), 'slack', $currentKey );
|
448 |
printf( '</select><br/><span class="postman_input_description">%s</span>', $inputDescription );
|
449 |
}
|
450 |
|
467 |
|
468 |
public function slack_token_callback() {
|
469 |
printf( '<input type="password" id="slack_token" name="%s[%s]" value="%s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::SLACK_TOKEN, $this->options->getSlackToken() );
|
470 |
+
echo '<a target="_blank" href="https://slack.postmansmtp.com/">' . __( 'Get your webhook URL here', 'post-smtp' ) . '</a>';
|
471 |
|
472 |
}
|
473 |
|
476 |
printf( $optionPattern, $optionKey, $optionKey == $currentKey ? 'selected="selected"' : '', $label );
|
477 |
}
|
478 |
public function runModeCallback() {
|
479 |
+
$inputDescription = __( 'Delivery mode offers options useful for developing or testing.', 'post-smtp' );
|
480 |
printf( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::RUN_MODE );
|
481 |
$currentKey = $this->options->getRunMode();
|
482 |
+
$this->printSelectOption( _x( 'Log Email and Send', 'When the server is online to the public, this is "Production" mode', 'post-smtp' ), PostmanOptions::RUN_MODE_PRODUCTION, $currentKey );
|
483 |
+
$this->printSelectOption( __( 'Log Email and Delete', 'post-smtp' ), PostmanOptions::RUN_MODE_LOG_ONLY, $currentKey );
|
484 |
+
$this->printSelectOption( __( 'Delete All Emails', 'post-smtp' ), PostmanOptions::RUN_MODE_IGNORE, $currentKey );
|
485 |
printf( '</select><br/><span class="postman_input_description">%s</span>', $inputDescription );
|
486 |
}
|
487 |
|
488 |
public function stealthModeCallback() {
|
489 |
+
printf( '<input type="checkbox" id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]" %3$s /> %4$s', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::STEALTH_MODE, $this->options->isStealthModeEnabled() ? 'checked="checked"' : '', __( 'Remove the Postman X-Header signature from messages', 'post-smtp' ) );
|
490 |
}
|
491 |
|
492 |
public function temporaryDirectoryCallback() {
|
493 |
$inputDescription = __( 'Lockfiles are written here to prevent users from triggering an OAuth 2.0 token refresh at the same time.' );
|
494 |
printf( '<input type="text" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::TEMPORARY_DIRECTORY, $this->options->getTempDirectory() );
|
495 |
if ( PostmanState::getInstance()->isFileLockingEnabled() ) {
|
496 |
+
printf( ' <span style="color:green">%s</span></br><span class="postman_input_description">%s</span>', __( 'Valid', 'post-smtp' ), $inputDescription );
|
497 |
} else {
|
498 |
+
printf( ' <span style="color:red">%s</span></br><span class="postman_input_description">%s</span>', __( 'Invalid', 'post-smtp' ), $inputDescription );
|
499 |
}
|
500 |
}
|
501 |
|
517 |
* Get the settings option array and print one of its values
|
518 |
*/
|
519 |
public function port_callback( $args ) {
|
520 |
+
printf( '<input type="text" id="input_port" name="postman_options[port]" value="%s" %s placeholder="%s"/>', null !== $this->options->getPort() ? esc_attr( $this->options->getPort() ) : '', isset( $args ['style'] ) ? $args ['style'] : '', __( 'Required', 'post-smtp' ) );
|
521 |
}
|
522 |
}
|
Postman/Postman-Configuration/PostmanSmtpDiscovery.php
CHANGED
@@ -117,7 +117,7 @@ if (! class_exists ( 'PostmanSmtpDiscovery' )) {
|
|
117 |
/**
|
118 |
* Constructor
|
119 |
*
|
120 |
-
* @param
|
121 |
*/
|
122 |
public function __construct($email) {
|
123 |
$this->email = $email;
|
@@ -137,8 +137,8 @@ if (! class_exists ( 'PostmanSmtpDiscovery' )) {
|
|
137 |
}
|
138 |
/**
|
139 |
*
|
140 |
-
* @param
|
141 |
-
* @return
|
142 |
*/
|
143 |
private function validateEmail($email) {
|
144 |
return PostmanUtils::validateEmail ( $email );
|
@@ -171,7 +171,7 @@ if (! class_exists ( 'PostmanSmtpDiscovery' )) {
|
|
171 |
/**
|
172 |
* Uses getmxrr to retrieve the MX records of a hostname
|
173 |
*
|
174 |
-
* @param
|
175 |
* @return mixed|boolean
|
176 |
*/
|
177 |
private function findMxHostViaDns($hostname) {
|
@@ -201,9 +201,9 @@ if (! class_exists ( 'PostmanSmtpDiscovery' )) {
|
|
201 |
* This is a custom implementation of mxrr for Windows PHP installations
|
202 |
* which don't have this method natively.
|
203 |
*
|
204 |
-
* @param
|
205 |
-
* @param
|
206 |
-
* @param
|
207 |
* @return boolean
|
208 |
*/
|
209 |
function getmxrr($hostname, &$mxhosts, &$mxweight) {
|
117 |
/**
|
118 |
* Constructor
|
119 |
*
|
120 |
+
* @param mixed $email
|
121 |
*/
|
122 |
public function __construct($email) {
|
123 |
$this->email = $email;
|
137 |
}
|
138 |
/**
|
139 |
*
|
140 |
+
* @param mixed $email
|
141 |
+
* @return string|bool
|
142 |
*/
|
143 |
private function validateEmail($email) {
|
144 |
return PostmanUtils::validateEmail ( $email );
|
171 |
/**
|
172 |
* Uses getmxrr to retrieve the MX records of a hostname
|
173 |
*
|
174 |
+
* @param mixed $hostname
|
175 |
* @return mixed|boolean
|
176 |
*/
|
177 |
private function findMxHostViaDns($hostname) {
|
201 |
* This is a custom implementation of mxrr for Windows PHP installations
|
202 |
* which don't have this method natively.
|
203 |
*
|
204 |
+
* @param mixed $hostname
|
205 |
+
* @param mixed $mxhosts
|
206 |
+
* @param mixed $mxweight
|
207 |
* @return boolean
|
208 |
*/
|
209 |
function getmxrr($hostname, &$mxhosts, &$mxweight) {
|
Postman/Postman-Connectivity-Test/Postman-PortTest.php
CHANGED
@@ -50,8 +50,8 @@ class PostmanPortTest {
|
|
50 |
/**
|
51 |
* Wrap the regDomain/getRegisteredDomain function
|
52 |
*
|
53 |
-
* @param
|
54 |
-
* @return
|
55 |
*/
|
56 |
private function getRegisteredDomain($hostname) {
|
57 |
$registeredDomain = getRegisteredDomain ( $hostname );
|
50 |
/**
|
51 |
* Wrap the regDomain/getRegisteredDomain function
|
52 |
*
|
53 |
+
* @param mixed $domain
|
54 |
+
* @return mixed
|
55 |
*/
|
56 |
private function getRegisteredDomain($hostname) {
|
57 |
$registeredDomain = getRegisteredDomain ( $hostname );
|
Postman/Postman-Connectivity-Test/PostmanConnectivityTestController.php
CHANGED
@@ -13,7 +13,7 @@ class PostmanConnectivityTestController {
|
|
13 |
/**
|
14 |
* Constructor
|
15 |
*
|
16 |
-
* @param
|
17 |
*/
|
18 |
public function __construct( $rootPluginFilenameAndPath ) {
|
19 |
assert( ! empty( $rootPluginFilenameAndPath ) );
|
@@ -77,7 +77,7 @@ class PostmanConnectivityTestController {
|
|
77 |
* Register the Email Test screen
|
78 |
*/
|
79 |
public function addPortTestSubmenu() {
|
80 |
-
$page = add_submenu_page( null, sprintf( __( '%s Setup',
|
81 |
$this,
|
82 |
'outputPortTestContent',
|
83 |
) );
|
@@ -93,26 +93,26 @@ class PostmanConnectivityTestController {
|
|
93 |
function enqueuePortTestResources() {
|
94 |
wp_enqueue_style( PostmanViewController::POSTMAN_STYLE );
|
95 |
wp_enqueue_script( 'postman_port_test_script' );
|
96 |
-
$warning = __( 'Warning',
|
97 |
wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_hostname_element_name', '#input_' . PostmanOptions::HOSTNAME );
|
98 |
PostmanConnectivityTestController::addLocalizeScriptForPortTest();
|
99 |
}
|
100 |
static function addLocalizeScriptForPortTest() {
|
101 |
wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_port_test', array(
|
102 |
-
'in_progress' => _x( 'Checking..', 'The "please wait" message',
|
103 |
-
'open' => _x( 'Open', 'The port is open',
|
104 |
-
'closed' => _x( 'Closed', 'The port is closed',
|
105 |
-
'yes' => __( 'Yes',
|
106 |
-
'no' => __( 'No',
|
107 |
/* translators: where %d is a port number */
|
108 |
-
'blocked' => __( 'No outbound route between this site and the Internet on Port %d.',
|
109 |
/* translators: where %d is a port number and %s is a hostname */
|
110 |
-
'try_dif_smtp' => __( 'Port %d is open, but not to %s.',
|
111 |
/* translators: where %d is the port number and %s is the hostname */
|
112 |
-
'success' => __( 'Port %d can be used for SMTP to %s.',
|
113 |
-
'mitm' => sprintf( '%s: %s', __( 'Warning',
|
114 |
/* translators: where %d is a port number and %s is the URL for the Postman Gmail Extension */
|
115 |
-
'https_success' => __( 'Port %d can be used with the %s.',
|
116 |
) );
|
117 |
}
|
118 |
|
@@ -132,46 +132,46 @@ class PostmanConnectivityTestController {
|
|
132 |
public function outputPortTestContent() {
|
133 |
print '<div class="wrap">';
|
134 |
|
135 |
-
PostmanViewController::outputChildPageHeader( __( 'Connectivity Test',
|
136 |
|
137 |
print '<p>';
|
138 |
-
print __( 'This test determines which well-known ports are available for Postman to use.',
|
139 |
print '<form id="port_test_form_id" method="post">';
|
140 |
-
printf( '<label for="hostname">%s</label>', __( 'Outgoing Mail Server Hostname',
|
141 |
$this->port_test_hostname_callback();
|
142 |
-
submit_button( _x( 'Begin Test', 'Button Label',
|
143 |
print '</form>';
|
144 |
print '<table id="connectivity_test_table">';
|
145 |
-
print sprintf( '<tr><th rowspan="2">%s</th><th rowspan="2">%s</th><th rowspan="2">%s</th><th rowspan="2">%s</th><th rowspan="2">%s</th><th colspan="5">%s</th></tr>', __( 'Transport',
|
146 |
print sprintf( '<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr>', 'None', 'Login', 'Plain', 'CRAM-MD5', 'OAuth 2.0' );
|
147 |
$sockets = PostmanTransportRegistry::getInstance()->getSocketsForSetupWizardToProbe();
|
148 |
foreach ( $sockets as $socket ) {
|
149 |
if ( $socket ['smtp'] ) {
|
150 |
print sprintf( '<tr id="%s"><th class="name">%s</th><td class="socket">%s:%s</td><td class="firewall resettable">-</td><td class="service resettable">-</td><td class="reported_id resettable">-</td><td class="auth_none resettable">-</td><td class="auth_login resettable">-</td><td class="auth_plain resettable">-</td><td class="auth_crammd5 resettable">-</td><td class="auth_xoauth2 resettable">-</td></tr>', $socket ['id'], $socket ['transport_name'], $socket ['host'], $socket ['port'] );
|
151 |
} else {
|
152 |
-
print sprintf( '<tr id="%s"><th class="name">%s</th><td class="socket">%s:%s</td><td class="firewall resettable">-</td><td class="service resettable">-</td><td class="reported_id resettable">-</td><td colspan="5">%s</td></tr>', $socket ['id'], $socket ['transport_name'], $socket ['host'], $socket ['port'], __( 'n/a',
|
153 |
}
|
154 |
}
|
155 |
print '</table>';
|
156 |
/* Translators: Where %s is the name of the service providing Internet connectivity test */
|
157 |
-
printf( '<p class="portquiz" style="display:none; font-size:0.8em">* %s</p>', sprintf( __( 'According to %s',
|
158 |
printf( '<p class="ajax-loader" style="display:none"><img src="%s"/></p>', plugins_url( 'post-smtp/style/ajax-loader.gif' ) );
|
159 |
print '<section id="conclusion" style="display:none">';
|
160 |
-
print sprintf( '<h3>%s:</h3>', __( 'Summary',
|
161 |
print '<ol class="conclusion">';
|
162 |
print '</ol>';
|
163 |
print '</section>';
|
164 |
print '<section id="blocked-port-help" style="display:none">';
|
165 |
-
print sprintf( '<p><b>%s</b></p>', __( 'A test with <span style="color:red">"No"</span> Service Available indicates one or more of these issues:',
|
166 |
print '<ol>';
|
167 |
-
printf( '<li>%s</li>', __( 'Your web host has placed a firewall between this site and the Internet',
|
168 |
-
printf( '<li>%s</li>', __( 'The SMTP hostname is wrong or the mail server does not provide service on this port',
|
169 |
/* translators: where (1) is the URL and (2) is the system */
|
170 |
-
$systemBlockMessage = __( 'Your <a href="%1$s">%2$s configuration</a> is preventing outbound connections',
|
171 |
printf( '<li>%s</li>', sprintf( $systemBlockMessage, 'http://php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen', 'PHP' ) );
|
172 |
printf( '<li>%s</li>', sprintf( $systemBlockMessage, 'http://wp-mix.com/disable-external-url-requests/', 'WordPress' ) );
|
173 |
print '</ol></p>';
|
174 |
-
print sprintf( '<p><b>%s</b></p>', __( 'If the issues above can not be resolved, your last option is to configure Postman to use an email account managed by your web host with an SMTP server managed by your web host.',
|
175 |
print '</section>';
|
176 |
print '</div>';
|
177 |
}
|
@@ -271,9 +271,9 @@ class PostmanPortTestAjaxController {
|
|
271 |
|
272 |
/**
|
273 |
*
|
274 |
-
* @param
|
275 |
-
* @param
|
276 |
-
* @param
|
277 |
*/
|
278 |
private function buildResponse( $hostname, $port, PostmanPortTest $portTest, $success, $transport = '' ) {
|
279 |
$this->logger->debug( sprintf( 'testing port result for %s:%s success=%s', $hostname, $port, $success ) );
|
13 |
/**
|
14 |
* Constructor
|
15 |
*
|
16 |
+
* @param mixed $rootPluginFilenameAndPath
|
17 |
*/
|
18 |
public function __construct( $rootPluginFilenameAndPath ) {
|
19 |
assert( ! empty( $rootPluginFilenameAndPath ) );
|
77 |
* Register the Email Test screen
|
78 |
*/
|
79 |
public function addPortTestSubmenu() {
|
80 |
+
$page = add_submenu_page( null, sprintf( __( '%s Setup', 'post-smtp' ), __( 'Postman SMTP', 'post-smtp' ) ), __( 'Postman SMTP', 'post-smtp' ), Postman::MANAGE_POSTMAN_CAPABILITY_NAME, PostmanConnectivityTestController::PORT_TEST_SLUG, array(
|
81 |
$this,
|
82 |
'outputPortTestContent',
|
83 |
) );
|
93 |
function enqueuePortTestResources() {
|
94 |
wp_enqueue_style( PostmanViewController::POSTMAN_STYLE );
|
95 |
wp_enqueue_script( 'postman_port_test_script' );
|
96 |
+
$warning = __( 'Warning', 'post-smtp' );
|
97 |
wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_hostname_element_name', '#input_' . PostmanOptions::HOSTNAME );
|
98 |
PostmanConnectivityTestController::addLocalizeScriptForPortTest();
|
99 |
}
|
100 |
static function addLocalizeScriptForPortTest() {
|
101 |
wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_port_test', array(
|
102 |
+
'in_progress' => _x( 'Checking..', 'The "please wait" message', 'post-smtp' ),
|
103 |
+
'open' => _x( 'Open', 'The port is open', 'post-smtp' ),
|
104 |
+
'closed' => _x( 'Closed', 'The port is closed', 'post-smtp' ),
|
105 |
+
'yes' => __( 'Yes', 'post-smtp' ),
|
106 |
+
'no' => __( 'No', 'post-smtp' ),
|
107 |
/* translators: where %d is a port number */
|
108 |
+
'blocked' => __( 'No outbound route between this site and the Internet on Port %d.', 'post-smtp' ),
|
109 |
/* translators: where %d is a port number and %s is a hostname */
|
110 |
+
'try_dif_smtp' => __( 'Port %d is open, but not to %s.', 'post-smtp' ),
|
111 |
/* translators: where %d is the port number and %s is the hostname */
|
112 |
+
'success' => __( 'Port %d can be used for SMTP to %s.', 'post-smtp' ),
|
113 |
+
'mitm' => sprintf( '%s: %s', __( 'Warning', 'post-smtp' ), __( 'connected to %1$s instead of %2$s.', 'post-smtp' ) ),
|
114 |
/* translators: where %d is a port number and %s is the URL for the Postman Gmail Extension */
|
115 |
+
'https_success' => __( 'Port %d can be used with the %s.', 'post-smtp' ),
|
116 |
) );
|
117 |
}
|
118 |
|
132 |
public function outputPortTestContent() {
|
133 |
print '<div class="wrap">';
|
134 |
|
135 |
+
PostmanViewController::outputChildPageHeader( __( 'Connectivity Test', 'post-smtp' ) );
|
136 |
|
137 |
print '<p>';
|
138 |
+
print __( 'This test determines which well-known ports are available for Postman to use.', 'post-smtp' );
|
139 |
print '<form id="port_test_form_id" method="post">';
|
140 |
+
printf( '<label for="hostname">%s</label>', __( 'Outgoing Mail Server Hostname', 'post-smtp' ) );
|
141 |
$this->port_test_hostname_callback();
|
142 |
+
submit_button( _x( 'Begin Test', 'Button Label', 'post-smtp' ), 'primary', 'begin-port-test', true );
|
143 |
print '</form>';
|
144 |
print '<table id="connectivity_test_table">';
|
145 |
+
print sprintf( '<tr><th rowspan="2">%s</th><th rowspan="2">%s</th><th rowspan="2">%s</th><th rowspan="2">%s</th><th rowspan="2">%s</th><th colspan="5">%s</th></tr>', __( 'Transport', 'post-smtp' ), _x( 'Socket', 'A socket is the network term for host and port together', 'post-smtp' ), __( 'Status', 'post-smtp' ) . '<sup>*</sup>', __( 'Service Available', 'post-smtp' ), __( 'Server ID', 'post-smtp' ), __( 'Authentication', 'post-smtp' ) );
|
146 |
print sprintf( '<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr>', 'None', 'Login', 'Plain', 'CRAM-MD5', 'OAuth 2.0' );
|
147 |
$sockets = PostmanTransportRegistry::getInstance()->getSocketsForSetupWizardToProbe();
|
148 |
foreach ( $sockets as $socket ) {
|
149 |
if ( $socket ['smtp'] ) {
|
150 |
print sprintf( '<tr id="%s"><th class="name">%s</th><td class="socket">%s:%s</td><td class="firewall resettable">-</td><td class="service resettable">-</td><td class="reported_id resettable">-</td><td class="auth_none resettable">-</td><td class="auth_login resettable">-</td><td class="auth_plain resettable">-</td><td class="auth_crammd5 resettable">-</td><td class="auth_xoauth2 resettable">-</td></tr>', $socket ['id'], $socket ['transport_name'], $socket ['host'], $socket ['port'] );
|
151 |
} else {
|
152 |
+
print sprintf( '<tr id="%s"><th class="name">%s</th><td class="socket">%s:%s</td><td class="firewall resettable">-</td><td class="service resettable">-</td><td class="reported_id resettable">-</td><td colspan="5">%s</td></tr>', $socket ['id'], $socket ['transport_name'], $socket ['host'], $socket ['port'], __( 'n/a', 'post-smtp' ) );
|
153 |
}
|
154 |
}
|
155 |
print '</table>';
|
156 |
/* Translators: Where %s is the name of the service providing Internet connectivity test */
|
157 |
+
printf( '<p class="portquiz" style="display:none; font-size:0.8em">* %s</p>', sprintf( __( 'According to %s', 'post-smtp' ), '<a target="_blank" href="https://downor.me/portquiz.net">portquiz.net</a>' ) );
|
158 |
printf( '<p class="ajax-loader" style="display:none"><img src="%s"/></p>', plugins_url( 'post-smtp/style/ajax-loader.gif' ) );
|
159 |
print '<section id="conclusion" style="display:none">';
|
160 |
+
print sprintf( '<h3>%s:</h3>', __( 'Summary', 'post-smtp' ) );
|
161 |
print '<ol class="conclusion">';
|
162 |
print '</ol>';
|
163 |
print '</section>';
|
164 |
print '<section id="blocked-port-help" style="display:none">';
|
165 |
+
print sprintf( '<p><b>%s</b></p>', __( 'A test with <span style="color:red">"No"</span> Service Available indicates one or more of these issues:', 'post-smtp' ) );
|
166 |
print '<ol>';
|
167 |
+
printf( '<li>%s</li>', __( 'Your web host has placed a firewall between this site and the Internet', 'post-smtp' ) );
|
168 |
+
printf( '<li>%s</li>', __( 'The SMTP hostname is wrong or the mail server does not provide service on this port', 'post-smtp' ) );
|
169 |
/* translators: where (1) is the URL and (2) is the system */
|
170 |
+
$systemBlockMessage = __( 'Your <a href="%1$s">%2$s configuration</a> is preventing outbound connections', 'post-smtp' );
|
171 |
printf( '<li>%s</li>', sprintf( $systemBlockMessage, 'http://php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen', 'PHP' ) );
|
172 |
printf( '<li>%s</li>', sprintf( $systemBlockMessage, 'http://wp-mix.com/disable-external-url-requests/', 'WordPress' ) );
|
173 |
print '</ol></p>';
|
174 |
+
print sprintf( '<p><b>%s</b></p>', __( 'If the issues above can not be resolved, your last option is to configure Postman to use an email account managed by your web host with an SMTP server managed by your web host.', 'post-smtp' ) );
|
175 |
print '</section>';
|
176 |
print '</div>';
|
177 |
}
|
271 |
|
272 |
/**
|
273 |
*
|
274 |
+
* @param mixed $hostname
|
275 |
+
* @param mixed $port
|
276 |
+
* @param mixed $success
|
277 |
*/
|
278 |
private function buildResponse( $hostname, $port, PostmanPortTest $portTest, $success, $transport = '' ) {
|
279 |
$this->logger->debug( sprintf( 'testing port result for %s:%s success=%s', $hostname, $port, $success ) );
|
Postman/Postman-Controller/PostmanAdminPointer.php
CHANGED
@@ -13,7 +13,7 @@ if (! class_exists ( 'PostmanAdminPointer' )) {
|
|
13 |
|
14 |
/**
|
15 |
*
|
16 |
-
* @param
|
17 |
*/
|
18 |
function __construct($rootPluginFilenameAndPath) {
|
19 |
$this->logger = new PostmanLogger ( get_class ( $this ) );
|
@@ -35,7 +35,7 @@ if (! class_exists ( 'PostmanAdminPointer' )) {
|
|
35 |
|
36 |
/**
|
37 |
*
|
38 |
-
* @param
|
39 |
*/
|
40 |
function wptuts_pointer_load($hook_suffix) {
|
41 |
// only do this for administrators
|
13 |
|
14 |
/**
|
15 |
*
|
16 |
+
* @param mixed $rootPluginFilenameAndPath
|
17 |
*/
|
18 |
function __construct($rootPluginFilenameAndPath) {
|
19 |
$this->logger = new PostmanLogger ( get_class ( $this ) );
|
35 |
|
36 |
/**
|
37 |
*
|
38 |
+
* @param mixed $hook_suffix
|
39 |
*/
|
40 |
function wptuts_pointer_load($hook_suffix) {
|
41 |
// only do this for administrators
|
Postman/Postman-Controller/PostmanDashboardWidgetController.php
CHANGED
@@ -54,7 +54,7 @@ if (! class_exists ( "PostmanDashboardWidgetController" )) {
|
|
54 |
public function addDashboardWidget() {
|
55 |
// only display to the widget to administrator
|
56 |
if (PostmanUtils::isAdmin ()) {
|
57 |
-
wp_add_dashboard_widget ( 'example_dashboard_widget', __ ( 'Postman SMTP',
|
58 |
$this,
|
59 |
'printDashboardWidget'
|
60 |
) ); // Display function.
|
@@ -67,7 +67,7 @@ if (! class_exists ( "PostmanDashboardWidgetController" )) {
|
|
67 |
public function addNetworkDashboardWidget() {
|
68 |
// only display to the widget to administrator
|
69 |
if (PostmanUtils::isAdmin ()) {
|
70 |
-
wp_add_dashboard_widget ( 'example_dashboard_widget', __ ( 'Postman SMTP',
|
71 |
$this,
|
72 |
'printNetworkDashboardWidget'
|
73 |
) ); // Display function.
|
@@ -78,8 +78,8 @@ if (! class_exists ( "PostmanDashboardWidgetController" )) {
|
|
78 |
* Create the function to output the contents of our Dashboard Widget.
|
79 |
*/
|
80 |
public function printDashboardWidget() {
|
81 |
-
$goToSettings = sprintf ( '<a href="%s">%s</a>', PostmanUtils::getSettingsPageUrl (), __ ( 'Settings',
|
82 |
-
$goToEmailLog = sprintf ( '%s', _x ( 'Email Log', 'The log of Emails that have been delivered',
|
83 |
if ($this->options->isMailLoggingEnabled ()) {
|
84 |
$goToEmailLog = sprintf ( '<a href="%s">%s</a>', PostmanUtils::getEmailLogPageUrl (), $goToEmailLog );
|
85 |
}
|
@@ -92,16 +92,16 @@ if (! class_exists ( "PostmanDashboardWidgetController" )) {
|
|
92 |
*/
|
93 |
public function print_postman_status() {
|
94 |
if (! PostmanPreRequisitesCheck::isReady ()) {
|
95 |
-
printf ( '<p><span style="color:red">%s</span></p>', __ ( 'Error: Postman is missing a required PHP library.',
|
96 |
} else if ($this->wpMailBinder->isUnboundDueToException ()) {
|
97 |
-
printf ( '<p><span style="color:red">%s</span></p>', __ ( 'Postman: wp_mail has been declared by another plugin or theme, so you won\'t be able to use Postman until the conflict is resolved.',
|
98 |
} else {
|
99 |
if ($this->options->getRunMode () != PostmanOptions::RUN_MODE_PRODUCTION) {
|
100 |
-
printf ( '<p><span style="background-color:yellow">%s</span></p>', __ ( 'Postman is in <em>non-Production</em> mode and is dumping all emails.',
|
101 |
} else if (PostmanTransportRegistry::getInstance ()->getSelectedTransport ()->isConfiguredAndReady ()) {
|
102 |
-
printf ( '<p class="wp-menu-image dashicons-before dashicons-email"> %s </p>', sprintf ( _n ( '<span style="color:green">Postman is configured</span> and has delivered <span style="color:green">%d</span> email.', '<span style="color:green">Postman is configured</span> and has delivered <span style="color:green">%d</span> emails.', PostmanState::getInstance ()->getSuccessfulDeliveries (),
|
103 |
} else {
|
104 |
-
printf ( '<p><span style="color:red">%s</span></p>', __ ( 'Postman is <em>not</em> configured and is mimicking out-of-the-box WordPress email delivery.',
|
105 |
}
|
106 |
$currentTransport = PostmanTransportRegistry::getInstance ()->getActiveTransport ();
|
107 |
$deliveryDetails = $currentTransport->getDeliveryDetails ( $this->options );
|
@@ -113,14 +113,14 @@ if (! class_exists ( "PostmanDashboardWidgetController" )) {
|
|
113 |
* Create the function to output the contents of our Dashboard Widget.
|
114 |
*/
|
115 |
public function printNetworkDashboardWidget() {
|
116 |
-
printf ( '<p class="wp-menu-image dashicons-before dashicons-email"> %s</p>', __ ( 'Postman is operating in per-site mode.',
|
117 |
}
|
118 |
|
119 |
/**
|
120 |
* From http://www.hughlashbrooke.com/2014/02/wordpress-add-items-glance-widget/
|
121 |
* http://coffeecupweb.com/how-to-add-custom-post-types-to-at-a-glance-dashboard-widget-in-wordpress/
|
122 |
*
|
123 |
-
* @param
|
124 |
* @return string
|
125 |
*/
|
126 |
function customizeAtAGlanceDashboardWidget($items = array()) {
|
@@ -143,7 +143,7 @@ if (! class_exists ( "PostmanDashboardWidgetController" )) {
|
|
143 |
$privated = intval ( $num_posts->private );
|
144 |
$post_type = get_post_type_object ( $type );
|
145 |
|
146 |
-
$text = _n ( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $privated,
|
147 |
$text = sprintf ( $text, number_format_i18n ( $privated ) );
|
148 |
|
149 |
$items [] = sprintf ( '<a class="%1$s-count" href="%3$s">%2$s</a>', $type, $text, PostmanUtils::getEmailLogPageUrl () ) . "\n";
|
54 |
public function addDashboardWidget() {
|
55 |
// only display to the widget to administrator
|
56 |
if (PostmanUtils::isAdmin ()) {
|
57 |
+
wp_add_dashboard_widget ( 'example_dashboard_widget', __ ( 'Postman SMTP', 'post-smtp' ), array (
|
58 |
$this,
|
59 |
'printDashboardWidget'
|
60 |
) ); // Display function.
|
67 |
public function addNetworkDashboardWidget() {
|
68 |
// only display to the widget to administrator
|
69 |
if (PostmanUtils::isAdmin ()) {
|
70 |
+
wp_add_dashboard_widget ( 'example_dashboard_widget', __ ( 'Postman SMTP', 'post-smtp' ), array (
|
71 |
$this,
|
72 |
'printNetworkDashboardWidget'
|
73 |
) ); // Display function.
|
78 |
* Create the function to output the contents of our Dashboard Widget.
|
79 |
*/
|
80 |
public function printDashboardWidget() {
|
81 |
+
$goToSettings = sprintf ( '<a href="%s">%s</a>', PostmanUtils::getSettingsPageUrl (), __ ( 'Settings', 'post-smtp' ) );
|
82 |
+
$goToEmailLog = sprintf ( '%s', _x ( 'Email Log', 'The log of Emails that have been delivered', 'post-smtp' ) );
|
83 |
if ($this->options->isMailLoggingEnabled ()) {
|
84 |
$goToEmailLog = sprintf ( '<a href="%s">%s</a>', PostmanUtils::getEmailLogPageUrl (), $goToEmailLog );
|
85 |
}
|
92 |
*/
|
93 |
public function print_postman_status() {
|
94 |
if (! PostmanPreRequisitesCheck::isReady ()) {
|
95 |
+
printf ( '<p><span style="color:red">%s</span></p>', __ ( 'Error: Postman is missing a required PHP library.', 'post-smtp' ) );
|
96 |
} else if ($this->wpMailBinder->isUnboundDueToException ()) {
|
97 |
+
printf ( '<p><span style="color:red">%s</span></p>', __ ( 'Postman: wp_mail has been declared by another plugin or theme, so you won\'t be able to use Postman until the conflict is resolved.', 'post-smtp' ) );
|
98 |
} else {
|
99 |
if ($this->options->getRunMode () != PostmanOptions::RUN_MODE_PRODUCTION) {
|
100 |
+
printf ( '<p><span style="background-color:yellow">%s</span></p>', __ ( 'Postman is in <em>non-Production</em> mode and is dumping all emails.', 'post-smtp' ) );
|
101 |
} else if (PostmanTransportRegistry::getInstance ()->getSelectedTransport ()->isConfiguredAndReady ()) {
|
102 |
+
printf ( '<p class="wp-menu-image dashicons-before dashicons-email"> %s </p>', sprintf ( _n ( '<span style="color:green">Postman is configured</span> and has delivered <span style="color:green">%d</span> email.', '<span style="color:green">Postman is configured</span> and has delivered <span style="color:green">%d</span> emails.', PostmanState::getInstance ()->getSuccessfulDeliveries (), 'post-smtp' ), PostmanState::getInstance ()->getSuccessfulDeliveries () ) );
|
103 |
} else {
|
104 |
+
printf ( '<p><span style="color:red">%s</span></p>', __ ( 'Postman is <em>not</em> configured and is mimicking out-of-the-box WordPress email delivery.', 'post-smtp' ) );
|
105 |
}
|
106 |
$currentTransport = PostmanTransportRegistry::getInstance ()->getActiveTransport ();
|
107 |
$deliveryDetails = $currentTransport->getDeliveryDetails ( $this->options );
|
113 |
* Create the function to output the contents of our Dashboard Widget.
|
114 |
*/
|
115 |
public function printNetworkDashboardWidget() {
|
116 |
+
printf ( '<p class="wp-menu-image dashicons-before dashicons-email"> %s</p>', __ ( 'Postman is operating in per-site mode.', 'post-smtp' ) );
|
117 |
}
|
118 |
|
119 |
/**
|
120 |
* From http://www.hughlashbrooke.com/2014/02/wordpress-add-items-glance-widget/
|
121 |
* http://coffeecupweb.com/how-to-add-custom-post-types-to-at-a-glance-dashboard-widget-in-wordpress/
|
122 |
*
|
123 |
+
* @param mixed $items
|
124 |
* @return string
|
125 |
*/
|
126 |
function customizeAtAGlanceDashboardWidget($items = array()) {
|
143 |
$privated = intval ( $num_posts->private );
|
144 |
$post_type = get_post_type_object ( $type );
|
145 |
|
146 |
+
$text = _n ( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $privated, 'post-smtp' );
|
147 |
$text = sprintf ( $text, number_format_i18n ( $privated ) );
|
148 |
|
149 |
$items [] = sprintf ( '<a class="%1$s-count" href="%3$s">%2$s</a>', $type, $text, PostmanUtils::getEmailLogPageUrl () ) . "\n";
|
Postman/Postman-Controller/PostmanManageConfigurationAjaxHandler.php
CHANGED
@@ -27,7 +27,7 @@ class PostmanWizardSocket {
|
|
27 |
|
28 |
/**
|
29 |
*
|
30 |
-
* @param
|
31 |
*/
|
32 |
function __construct($queryHostData) {
|
33 |
$this->hostname = $queryHostData ['hostname'];
|
27 |
|
28 |
/**
|
29 |
*
|
30 |
+
* @param mixed $queryHostData
|
31 |
*/
|
32 |
function __construct($queryHostData) {
|
33 |
$this->hostname = $queryHostData ['hostname'];
|
Postman/Postman-Controller/PostmanWelcomeController.php
CHANGED
@@ -19,8 +19,8 @@ class PostmanWelcomeController {
|
|
19 |
|
20 |
// About
|
21 |
add_dashboard_page(
|
22 |
-
__( 'Welcome',
|
23 |
-
__( 'Welcome',
|
24 |
'manage_options',
|
25 |
'post-about',
|
26 |
array( $this, 'about_screen' )
|
@@ -28,8 +28,8 @@ class PostmanWelcomeController {
|
|
28 |
|
29 |
// Credits
|
30 |
add_dashboard_page(
|
31 |
-
__( 'Credits',
|
32 |
-
__( 'Credits',
|
33 |
'manage_options',
|
34 |
'post-credits',
|
35 |
array( $this, 'credits_screen' )
|
@@ -72,36 +72,36 @@ class PostmanWelcomeController {
|
|
72 |
}
|
73 |
</style>
|
74 |
<div class="wrap about-wrap">
|
75 |
-
<h1><?php printf( esc_html__( 'Welcome to Post SMTP %s',
|
76 |
-
<div class="about-text"><?php printf( esc_html__( 'Thank you for updating! Post SMTP %s is bundled up and ready to take your SMTP needs to the next level!',
|
77 |
<?php printf( '<strong>%s</strong>','Post SMTP support every SMTP service: Gmail/G-suite, SendGrid, Mandrill, Office365, and more...' ); ?>
|
78 |
</div>
|
79 |
-
<div class="post-badge"><?php printf( esc_html__( 'Version %s',
|
80 |
|
81 |
<h2 class="nav-tab-wrapper">
|
82 |
<a class="nav-tab nav-tab-active" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'post-about' ), 'index.php' ) ) ); ?>">
|
83 |
-
<?php esc_html_e( 'What’s New',
|
84 |
</a><a class="nav-tab" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'post-credits' ), 'index.php' ) ) ); ?>">
|
85 |
-
<?php esc_html_e( 'Credits',
|
86 |
</a>
|
87 |
</h2>
|
88 |
|
89 |
<div class="changelog">
|
90 |
-
<h3><?php esc_html_e( 'Email Log',
|
91 |
|
92 |
<div class="feature-section col two-col">
|
93 |
<div class="last-feature">
|
94 |
-
<h4><?php esc_html_e( 'Email log filter',
|
95 |
<p>
|
96 |
-
<?php esc_html_e( 'You can easily filter by dates and search in your log.',
|
97 |
<img src="<?php echo $this->pluginUrl; ?>/images/filter-preview.gif">
|
98 |
</p>
|
99 |
</div>
|
100 |
|
101 |
<div>
|
102 |
-
<h4><?php esc_html_e( 'Multiple emails resend',
|
103 |
<p>
|
104 |
-
<?php esc_html_e( 'Resend any email to the original recipient or any other emails you choose.',
|
105 |
<img src="<?php echo $this->pluginUrl; ?>/images/resend-preview.gif">
|
106 |
</p>
|
107 |
</div>
|
@@ -109,7 +109,7 @@ class PostmanWelcomeController {
|
|
109 |
</div>
|
110 |
|
111 |
<div class="changelog">
|
112 |
-
<h3><?php esc_html_e( 'The best delivery experience',
|
113 |
|
114 |
<div class="feature-section col one-col">
|
115 |
<div class="last-feature">
|
@@ -120,30 +120,30 @@ class PostmanWelcomeController {
|
|
120 |
Supports forced recipients (cc, bcc, to) and custom email headers,
|
121 |
SASL Support: Plain/Login/CRAM-MD5/XOAUTH2 authentication,
|
122 |
Security Support: SMTPS and STARTTLS (SSL/TLS),
|
123 |
-
Copy configuration to other instances of Post.',
|
124 |
</div>
|
125 |
</div>
|
126 |
|
127 |
<div class="feature-section col three-col">
|
128 |
<div>
|
129 |
-
<h4><?php esc_html_e( 'Email log HTML preview',
|
130 |
-
<p><?php esc_html_e( 'You can now see sent emails as HTML.',
|
131 |
</div>
|
132 |
|
133 |
<div>
|
134 |
-
<h4><?php esc_html_e( 'Continues email delivery',
|
135 |
-
<p><?php esc_html_e( 'if email fail to sent you will get notified using the local mail system.',
|
136 |
</div>
|
137 |
|
138 |
<div class="last-feature">
|
139 |
-
<h4><?php esc_html_e( 'The best debugging tools.',
|
140 |
-
<p><?php esc_html_e( 'Full Transcripts, Connectivity Test, Diagnostic Test.',
|
141 |
</div>
|
142 |
</div>
|
143 |
</div>
|
144 |
|
145 |
<div class="return-to-dashboard">
|
146 |
-
<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'postman' ), 'admin.php' ) ) ); ?>"><?php esc_html_e( 'Go to Post SMTP Settings',
|
147 |
</div>
|
148 |
|
149 |
</div>
|
@@ -170,36 +170,36 @@ class PostmanWelcomeController {
|
|
170 |
}
|
171 |
</style>
|
172 |
<div class="wrap about-wrap">
|
173 |
-
<h1><?php printf( esc_html__( 'Welcome to Post SMTP %s',
|
174 |
-
<div class="about-text"><?php printf( esc_html__( 'Thank you for updating! bbPress %s is waxed, polished, and ready for you to take it for a lap or two around the block!',
|
175 |
-
<div class="post-badge"><?php printf( esc_html__( 'Version %s',
|
176 |
|
177 |
<h2 class="nav-tab-wrapper">
|
178 |
<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'post-about' ), 'index.php' ) ) ); ?>" class="nav-tab">
|
179 |
-
<?php esc_html_e( 'What’s New',
|
180 |
</a><a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'post-credits' ), 'index.php' ) ) ); ?>" class="nav-tab nav-tab-active">
|
181 |
-
<?php esc_html_e( 'Credits',
|
182 |
</a>
|
183 |
</h2>
|
184 |
|
185 |
-
<p class="about-description"><?php esc_html_e( 'Post SMTP started by Jason Hendriks, Jason left the project and Yehuda Hassine (me) continue his work.',
|
186 |
|
187 |
-
<h4 class="wp-people-group"><?php esc_html_e( 'Project Leaders',
|
188 |
<ul class="wp-people-group " id="wp-people-group-project-leaders">
|
189 |
<li class="wp-person" id="wp-person-jasonhendriks">
|
190 |
<a href="https://profiles.wordpress.org/jasonhendriks"><img src="https://secure.gravatar.com/avatar/8692c7b6084517a592f6cad107f7bcb0?s=60&d=mm&r=g" class="gravatar" alt="Jason Hendriks " /></a>
|
191 |
<a class="web" href="http://profiles.wordpress.org/matt">Jason Hendriks</a>
|
192 |
-
<span class="title"><?php esc_html_e( 'Founding Developer (abandoned)',
|
193 |
</li>
|
194 |
<li class="wp-person" id="wp-person-yehudah">
|
195 |
<a href="http://profiles.wordpress.org/yehudah"><img src="https://secure.gravatar.com/avatar/c561638d04ea8fef351f974dbb9ece39?s=60&d=mm&r=g" class="gravatar" alt="Yehuda Hassine" /></a>
|
196 |
<a class="web" href="http://profiles.wordpress.org/yehudah">Yehuda Hassine</a>
|
197 |
-
<span class="title"><?php esc_html_e( 'Lead Developer',
|
198 |
</li>
|
199 |
</ul>
|
200 |
|
201 |
-
<h4 class="wp-people-group"><?php esc_html_e( 'Top Community Members',
|
202 |
-
<h5><?php esc_html_e( 'Here I will list top users that help Post SMTP grow (bugs, features, etc...)',
|
203 |
<p class="wp-credits-list">
|
204 |
<a href="http://profiles.wordpress.org/diegocanal">diegocanal</a>,
|
205 |
<a href="http://profiles.wordpress.org/jyourstone">Johan Yourstone</a>,
|
@@ -209,7 +209,7 @@ class PostmanWelcomeController {
|
|
209 |
</p>
|
210 |
|
211 |
<div class="return-to-dashboard">
|
212 |
-
<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'postman' ), 'admin.php' ) ) ); ?>"><?php esc_html_e( 'Go to Post SMTP Settings',
|
213 |
</div>
|
214 |
|
215 |
</div>
|
19 |
|
20 |
// About
|
21 |
add_dashboard_page(
|
22 |
+
__( 'Welcome', 'post-smtp' ),
|
23 |
+
__( 'Welcome', 'post-smtp' ),
|
24 |
'manage_options',
|
25 |
'post-about',
|
26 |
array( $this, 'about_screen' )
|
28 |
|
29 |
// Credits
|
30 |
add_dashboard_page(
|
31 |
+
__( 'Credits', 'post-smtp' ),
|
32 |
+
__( 'Credits', 'post-smtp' ),
|
33 |
'manage_options',
|
34 |
'post-credits',
|
35 |
array( $this, 'credits_screen' )
|
72 |
}
|
73 |
</style>
|
74 |
<div class="wrap about-wrap">
|
75 |
+
<h1><?php printf( esc_html__( 'Welcome to Post SMTP %s', 'post-smtp' ), $this->version ); ?></h1>
|
76 |
+
<div class="about-text"><?php printf( esc_html__( 'Thank you for updating! Post SMTP %s is bundled up and ready to take your SMTP needs to the next level!', 'post-smtp' ), $this->version ); ?><br>
|
77 |
<?php printf( '<strong>%s</strong>','Post SMTP support every SMTP service: Gmail/G-suite, SendGrid, Mandrill, Office365, and more...' ); ?>
|
78 |
</div>
|
79 |
+
<div class="post-badge"><?php printf( esc_html__( 'Version %s', 'post-smtp' ), $this->version ); ?></div>
|
80 |
|
81 |
<h2 class="nav-tab-wrapper">
|
82 |
<a class="nav-tab nav-tab-active" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'post-about' ), 'index.php' ) ) ); ?>">
|
83 |
+
<?php esc_html_e( 'What’s New', 'post-smtp' ); ?>
|
84 |
</a><a class="nav-tab" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'post-credits' ), 'index.php' ) ) ); ?>">
|
85 |
+
<?php esc_html_e( 'Credits', 'post-smtp' ); ?>
|
86 |
</a>
|
87 |
</h2>
|
88 |
|
89 |
<div class="changelog">
|
90 |
+
<h3><?php esc_html_e( 'Email Log', 'post-smtp' ); ?></h3>
|
91 |
|
92 |
<div class="feature-section col two-col">
|
93 |
<div class="last-feature">
|
94 |
+
<h4><?php esc_html_e( 'Email log filter', 'post-smtp' ); ?></h4>
|
95 |
<p>
|
96 |
+
<?php esc_html_e( 'You can easily filter by dates and search in your log.', 'post-smtp' ); ?>
|
97 |
<img src="<?php echo $this->pluginUrl; ?>/images/filter-preview.gif">
|
98 |
</p>
|
99 |
</div>
|
100 |
|
101 |
<div>
|
102 |
+
<h4><?php esc_html_e( 'Multiple emails resend', 'post-smtp' ); ?></h4>
|
103 |
<p>
|
104 |
+
<?php esc_html_e( 'Resend any email to the original recipient or any other emails you choose.', 'post-smtp' ); ?>
|
105 |
<img src="<?php echo $this->pluginUrl; ?>/images/resend-preview.gif">
|
106 |
</p>
|
107 |
</div>
|
109 |
</div>
|
110 |
|
111 |
<div class="changelog">
|
112 |
+
<h3><?php esc_html_e( 'The best delivery experience', 'post-smtp' ); ?></h3>
|
113 |
|
114 |
<div class="feature-section col one-col">
|
115 |
<div class="last-feature">
|
120 |
Supports forced recipients (cc, bcc, to) and custom email headers,
|
121 |
SASL Support: Plain/Login/CRAM-MD5/XOAUTH2 authentication,
|
122 |
Security Support: SMTPS and STARTTLS (SSL/TLS),
|
123 |
+
Copy configuration to other instances of Post.', 'post-smtp' ); ?></p>
|
124 |
</div>
|
125 |
</div>
|
126 |
|
127 |
<div class="feature-section col three-col">
|
128 |
<div>
|
129 |
+
<h4><?php esc_html_e( 'Email log HTML preview', 'post-smtp' ); ?></h4>
|
130 |
+
<p><?php esc_html_e( 'You can now see sent emails as HTML.', 'post-smtp' ); ?></p>
|
131 |
</div>
|
132 |
|
133 |
<div>
|
134 |
+
<h4><?php esc_html_e( 'Continues email delivery', 'post-smtp' ); ?></h4>
|
135 |
+
<p><?php esc_html_e( 'if email fail to sent you will get notified using the local mail system.', 'post-smtp' ); ?></p>
|
136 |
</div>
|
137 |
|
138 |
<div class="last-feature">
|
139 |
+
<h4><?php esc_html_e( 'The best debugging tools.', 'post-smtp' ); ?></h4>
|
140 |
+
<p><?php esc_html_e( 'Full Transcripts, Connectivity Test, Diagnostic Test.', 'post-smtp' ); ?></p>
|
141 |
</div>
|
142 |
</div>
|
143 |
</div>
|
144 |
|
145 |
<div class="return-to-dashboard">
|
146 |
+
<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'postman' ), 'admin.php' ) ) ); ?>"><?php esc_html_e( 'Go to Post SMTP Settings', 'post-smtp' ); ?></a>
|
147 |
</div>
|
148 |
|
149 |
</div>
|
170 |
}
|
171 |
</style>
|
172 |
<div class="wrap about-wrap">
|
173 |
+
<h1><?php printf( esc_html__( 'Welcome to Post SMTP %s', 'post-smtp' ), $this->version ); ?></h1>
|
174 |
+
<div class="about-text"><?php printf( esc_html__( 'Thank you for updating! bbPress %s is waxed, polished, and ready for you to take it for a lap or two around the block!', 'post-smtp' ), $this->version ); ?></div>
|
175 |
+
<div class="post-badge"><?php printf( esc_html__( 'Version %s', 'post-smtp' ), $this->version ); ?></div>
|
176 |
|
177 |
<h2 class="nav-tab-wrapper">
|
178 |
<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'post-about' ), 'index.php' ) ) ); ?>" class="nav-tab">
|
179 |
+
<?php esc_html_e( 'What’s New', 'post-smtp' ); ?>
|
180 |
</a><a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'post-credits' ), 'index.php' ) ) ); ?>" class="nav-tab nav-tab-active">
|
181 |
+
<?php esc_html_e( 'Credits', 'post-smtp' ); ?>
|
182 |
</a>
|
183 |
</h2>
|
184 |
|
185 |
+
<p class="about-description"><?php esc_html_e( 'Post SMTP started by Jason Hendriks, Jason left the project and Yehuda Hassine (me) continue his work.', 'post-smtp' ); ?></p>
|
186 |
|
187 |
+
<h4 class="wp-people-group"><?php esc_html_e( 'Project Leaders', 'post-smtp' ); ?></h4>
|
188 |
<ul class="wp-people-group " id="wp-people-group-project-leaders">
|
189 |
<li class="wp-person" id="wp-person-jasonhendriks">
|
190 |
<a href="https://profiles.wordpress.org/jasonhendriks"><img src="https://secure.gravatar.com/avatar/8692c7b6084517a592f6cad107f7bcb0?s=60&d=mm&r=g" class="gravatar" alt="Jason Hendriks " /></a>
|
191 |
<a class="web" href="http://profiles.wordpress.org/matt">Jason Hendriks</a>
|
192 |
+
<span class="title"><?php esc_html_e( 'Founding Developer (abandoned)', 'post-smtp' ); ?></span>
|
193 |
</li>
|
194 |
<li class="wp-person" id="wp-person-yehudah">
|
195 |
<a href="http://profiles.wordpress.org/yehudah"><img src="https://secure.gravatar.com/avatar/c561638d04ea8fef351f974dbb9ece39?s=60&d=mm&r=g" class="gravatar" alt="Yehuda Hassine" /></a>
|
196 |
<a class="web" href="http://profiles.wordpress.org/yehudah">Yehuda Hassine</a>
|
197 |
+
<span class="title"><?php esc_html_e( 'Lead Developer', 'post-smtp' ); ?></span>
|
198 |
</li>
|
199 |
</ul>
|
200 |
|
201 |
+
<h4 class="wp-people-group"><?php esc_html_e( 'Top Community Members', 'post-smtp' ); ?></h4>
|
202 |
+
<h5><?php esc_html_e( 'Here I will list top users that help Post SMTP grow (bugs, features, etc...)', 'post-smtp' ); ?>
|
203 |
<p class="wp-credits-list">
|
204 |
<a href="http://profiles.wordpress.org/diegocanal">diegocanal</a>,
|
205 |
<a href="http://profiles.wordpress.org/jyourstone">Johan Yourstone</a>,
|
209 |
</p>
|
210 |
|
211 |
<div class="return-to-dashboard">
|
212 |
+
<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'postman' ), 'admin.php' ) ) ); ?>"><?php esc_html_e( 'Go to Post SMTP Settings', 'post-smtp' ); ?></a>
|
213 |
</div>
|
214 |
|
215 |
</div>
|
Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php
CHANGED
@@ -12,7 +12,7 @@ class PostmanDiagnosticTestController {
|
|
12 |
/**
|
13 |
* Constructor
|
14 |
*
|
15 |
-
* @param
|
16 |
*/
|
17 |
public function __construct( $rootPluginFilenameAndPath ) {
|
18 |
assert( ! empty( $rootPluginFilenameAndPath ) );
|
@@ -77,7 +77,7 @@ class PostmanDiagnosticTestController {
|
|
77 |
* Register the Diagnostics screen
|
78 |
*/
|
79 |
public function addDiagnosticsSubmenu() {
|
80 |
-
$page = add_submenu_page( null, sprintf( __( '%s Setup',
|
81 |
$this,
|
82 |
'outputDiagnosticsContent',
|
83 |
) );
|
@@ -98,14 +98,14 @@ class PostmanDiagnosticTestController {
|
|
98 |
// test features
|
99 |
print '<div class="wrap">';
|
100 |
|
101 |
-
PostmanViewController::outputChildPageHeader( __( 'Diagnostic Test',
|
102 |
|
103 |
-
printf( '<h4>%s</h4>', __( 'Are you having issues with Postman?',
|
104 |
/* translators: where %1$s and %2$s are the URLs to the Troubleshooting and Support Forums on WordPress.org */
|
105 |
-
printf( '<p style="margin:0 10px">%s</p>', sprintf( __( 'Please check the <a href="%1$s">troubleshooting and error messages</a> page and the <a href="%2$s">support forum</a>.',
|
106 |
-
printf( '<h4>%s</h4>', __( 'Diagnostic Test',
|
107 |
-
printf( '<p style="margin:0 10px">%s</p><br/>', sprintf( __( 'If you write for help, please include the following:',
|
108 |
-
printf( '<textarea readonly="readonly" id="diagnostic-text" cols="80" rows="15">%s</textarea>', _x( 'Checking..', 'The "please wait" message',
|
109 |
print '</div>';
|
110 |
}
|
111 |
}
|
@@ -210,6 +210,7 @@ class PostmanGetDiagnosticsViaAjax {
|
|
210 |
public function getDiagnostics() {
|
211 |
$curl = curl_version();
|
212 |
$transportRegistry = PostmanTransportRegistry::getInstance();
|
|
|
213 |
$this->addToDiagnostics( 'HostName', PostmanUtils::getServerName() );
|
214 |
$this->addToDiagnostics( 'cURL Version', $curl['version'] );
|
215 |
$this->addToDiagnostics( 'OpenSSL Version', $curl['ssl_version'] );
|
@@ -219,17 +220,15 @@ class PostmanGetDiagnosticsViaAjax {
|
|
219 |
$this->addToDiagnostics( 'WordPress', (is_multisite() ? 'Multisite ' : '') . get_bloginfo( 'version' ) . ' ' . get_locale() . ' ' . get_bloginfo( 'charset', 'display' ) );
|
220 |
$this->addToDiagnostics( 'WordPress Theme', wp_get_theme() );
|
221 |
$this->addToDiagnostics( 'WordPress Plugins', $this->getActivePlugins() );
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
if ( class_exists( 'ReflectionFunction' ) ) {
|
226 |
$wp_mail = new ReflectionFunction( 'wp_mail' );
|
227 |
$wp_mail_file_name = realpath( $wp_mail->getFileName() );
|
228 |
}
|
229 |
-
|
230 |
-
|
231 |
-
}
|
232 |
-
}
|
233 |
$this->addToDiagnostics( 'WordPress wp_mail Filter(s)', $this->getFilters( 'wp_mail' ) );
|
234 |
$this->addToDiagnostics( 'WordPress wp_mail_from Filter(s)', $this->getFilters( 'wp_mail_from' ) );
|
235 |
$this->addToDiagnostics( 'WordPress wp_mail_from_name Filter(s)', $this->getFilters( 'wp_mail_from_name' ) );
|
12 |
/**
|
13 |
* Constructor
|
14 |
*
|
15 |
+
* @param mixed $rootPluginFilenameAndPath
|
16 |
*/
|
17 |
public function __construct( $rootPluginFilenameAndPath ) {
|
18 |
assert( ! empty( $rootPluginFilenameAndPath ) );
|
77 |
* Register the Diagnostics screen
|
78 |
*/
|
79 |
public function addDiagnosticsSubmenu() {
|
80 |
+
$page = add_submenu_page( null, sprintf( __( '%s Setup', 'post-smtp' ), __( 'Postman SMTP', 'post-smtp' ) ), __( 'Postman SMTP', 'post-smtp' ), Postman::MANAGE_POSTMAN_CAPABILITY_NAME, PostmanDiagnosticTestController::DIAGNOSTICS_SLUG, array(
|
81 |
$this,
|
82 |
'outputDiagnosticsContent',
|
83 |
) );
|
98 |
// test features
|
99 |
print '<div class="wrap">';
|
100 |
|
101 |
+
PostmanViewController::outputChildPageHeader( __( 'Diagnostic Test', 'post-smtp' ) );
|
102 |
|
103 |
+
printf( '<h4>%s</h4>', __( 'Are you having issues with Postman?', 'post-smtp' ) );
|
104 |
/* translators: where %1$s and %2$s are the URLs to the Troubleshooting and Support Forums on WordPress.org */
|
105 |
+
printf( '<p style="margin:0 10px">%s</p>', sprintf( __( 'Please check the <a href="%1$s">troubleshooting and error messages</a> page and the <a href="%2$s">support forum</a>.', 'post-smtp' ), 'https://wordpress.org/plugins/post-smtp/other_notes/', 'https://wordpress.org/support/plugin/post-smtp' ) );
|
106 |
+
printf( '<h4>%s</h4>', __( 'Diagnostic Test', 'post-smtp' ) );
|
107 |
+
printf( '<p style="margin:0 10px">%s</p><br/>', sprintf( __( 'If you write for help, please include the following:', 'post-smtp' ), 'https://wordpress.org/plugins/post-smtp/other_notes/', 'https://wordpress.org/support/plugin/post-smtp' ) );
|
108 |
+
printf( '<textarea readonly="readonly" id="diagnostic-text" cols="80" rows="15">%s</textarea>', _x( 'Checking..', 'The "please wait" message', 'post-smtp' ) );
|
109 |
print '</div>';
|
110 |
}
|
111 |
}
|
210 |
public function getDiagnostics() {
|
211 |
$curl = curl_version();
|
212 |
$transportRegistry = PostmanTransportRegistry::getInstance();
|
213 |
+
$this->addToDiagnostics( 'Mailer', PostmanOptions::getInstance()->getSmtpMailer() );
|
214 |
$this->addToDiagnostics( 'HostName', PostmanUtils::getServerName() );
|
215 |
$this->addToDiagnostics( 'cURL Version', $curl['version'] );
|
216 |
$this->addToDiagnostics( 'OpenSSL Version', $curl['ssl_version'] );
|
220 |
$this->addToDiagnostics( 'WordPress', (is_multisite() ? 'Multisite ' : '') . get_bloginfo( 'version' ) . ' ' . get_locale() . ' ' . get_bloginfo( 'charset', 'display' ) );
|
221 |
$this->addToDiagnostics( 'WordPress Theme', wp_get_theme() );
|
222 |
$this->addToDiagnostics( 'WordPress Plugins', $this->getActivePlugins() );
|
223 |
+
|
224 |
+
$bindResult = apply_filters( 'postman_wp_mail_bind_status', null );
|
225 |
+
$wp_mail_file_name = 'n/a';
|
226 |
if ( class_exists( 'ReflectionFunction' ) ) {
|
227 |
$wp_mail = new ReflectionFunction( 'wp_mail' );
|
228 |
$wp_mail_file_name = realpath( $wp_mail->getFileName() );
|
229 |
}
|
230 |
+
|
231 |
+
$this->addToDiagnostics( 'WordPress wp_mail Owner', $wp_mail_file_name );
|
|
|
|
|
232 |
$this->addToDiagnostics( 'WordPress wp_mail Filter(s)', $this->getFilters( 'wp_mail' ) );
|
233 |
$this->addToDiagnostics( 'WordPress wp_mail_from Filter(s)', $this->getFilters( 'wp_mail_from' ) );
|
234 |
$this->addToDiagnostics( 'WordPress wp_mail_from_name Filter(s)', $this->getFilters( 'wp_mail_from_name' ) );
|
Postman/Postman-Email-Log/PostmanEmailLogController.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
require_once 'PostmanEmailLogService.php';
|
3 |
require_once 'PostmanEmailLogView.php';
|
4 |
|
@@ -77,8 +78,7 @@ class PostmanEmailLogController {
|
|
77 |
// get the email address of the recipient from the HTTP Request
|
78 |
$postid = $this->getRequestParameter( 'email' );
|
79 |
if ( ! empty( $postid ) ) {
|
80 |
-
$
|
81 |
-
$meta_values = get_post_meta( $postid );
|
82 |
|
83 |
if ( isset( $_POST['mail_to'] ) && ! empty( $_POST['mail_to'] ) ) {
|
84 |
$emails = explode( ',', $_POST['mail_to'] );
|
@@ -87,7 +87,7 @@ class PostmanEmailLogController {
|
|
87 |
$to = $meta_values ['original_to'] [0];
|
88 |
}
|
89 |
|
90 |
-
$success = wp_mail( $to, $meta_values ['original_subject'] [0], $meta_values ['original_message'] [0], $meta_values ['original_headers'] [0] );
|
91 |
|
92 |
// Postman API: retrieve the result of sending this message from Postman
|
93 |
$result = apply_filters( 'postman_wp_mail_result', null );
|
@@ -97,7 +97,7 @@ class PostmanEmailLogController {
|
|
97 |
if ( $success ) {
|
98 |
$this->logger->debug( 'Email was successfully re-sent' );
|
99 |
// the message was sent successfully, generate an appropriate message for the user
|
100 |
-
$statusMessage = sprintf( __( 'Your message was delivered (%d ms) to the SMTP server! Congratulations :)',
|
101 |
|
102 |
// compose the JSON response for the caller
|
103 |
$response = array(
|
@@ -134,8 +134,8 @@ class PostmanEmailLogController {
|
|
134 |
/**
|
135 |
* TODO move this somewhere reusable
|
136 |
*
|
137 |
-
* @param
|
138 |
-
* @return
|
139 |
*/
|
140 |
private function getRequestParameter( $parameterName ) {
|
141 |
if ( isset( $_POST [ $parameterName ] ) ) {
|
@@ -163,7 +163,7 @@ class PostmanEmailLogController {
|
|
163 |
$purger->verifyLogItemExistsAndRemove( $postid );
|
164 |
}
|
165 |
$mh = new PostmanMessageHandler();
|
166 |
-
$mh->addMessage( __( 'Mail Log Entries were deleted.',
|
167 |
} else {
|
168 |
$this->logger->warn( sprintf( 'action "%s" not recognized', $_REQUEST ['action'] ) );
|
169 |
}
|
@@ -186,7 +186,7 @@ class PostmanEmailLogController {
|
|
186 |
$purger = new PostmanEmailLogPurger();
|
187 |
$purger->verifyLogItemExistsAndRemove( $postid );
|
188 |
$mh = new PostmanMessageHandler();
|
189 |
-
$mh->addMessage( __( 'Mail Log Entry was deleted.',
|
190 |
} else {
|
191 |
$this->logger->warn( sprintf( 'nonce "%s" failed validation', $_REQUEST ['_wpnonce'] ) );
|
192 |
}
|
@@ -202,7 +202,7 @@ class PostmanEmailLogController {
|
|
202 |
$this->logger->trace( 'handling view item' );
|
203 |
$postid = $_REQUEST ['email'];
|
204 |
$post = get_post( $postid );
|
205 |
-
$meta_values =
|
206 |
// https://css-tricks.com/examples/hrs/
|
207 |
print '<html><head><style>body {font-family: monospace;} hr {
|
208 |
border: 0;
|
@@ -211,29 +211,29 @@ class PostmanEmailLogController {
|
|
211 |
}</style></head><body>';
|
212 |
print '<table>';
|
213 |
if ( ! empty( $meta_values ['from_header'] [0] ) ) {
|
214 |
-
printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'From', 'Who is this message From?',
|
215 |
}
|
216 |
// show the To header (it's optional)
|
217 |
if ( ! empty( $meta_values ['to_header'] [0] ) ) {
|
218 |
-
printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'To', 'Who is this message To?',
|
219 |
}
|
220 |
// show the Cc header (it's optional)
|
221 |
if ( ! empty( $meta_values ['cc_header'] [0] ) ) {
|
222 |
-
printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Cc', 'Who is this message Cc\'d to?',
|
223 |
}
|
224 |
// show the Bcc header (it's optional)
|
225 |
if ( ! empty( $meta_values ['bcc_header'] [0] ) ) {
|
226 |
-
printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Bcc', 'Who is this message Bcc\'d to?',
|
227 |
}
|
228 |
// show the Reply-To header (it's optional)
|
229 |
if ( ! empty( $meta_values ['reply_to_header'] [0] ) ) {
|
230 |
-
printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', __( 'Reply-To',
|
231 |
}
|
232 |
-
printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Date', 'What is the date today?',
|
233 |
-
printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Subject', 'What is the subject of this message?',
|
234 |
// The Transport UI is always there, in more recent versions that is
|
235 |
if ( ! empty( $meta_values ['transport_uri'] [0] ) ) {
|
236 |
-
printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Delivery-URI', 'What is the unique URI of the configuration?',
|
237 |
}
|
238 |
print '</table>';
|
239 |
print '<hr/>';
|
@@ -260,21 +260,21 @@ class PostmanEmailLogController {
|
|
260 |
$this->logger->trace( 'handling view transcript item' );
|
261 |
$postid = $_REQUEST ['email'];
|
262 |
$post = get_post( $postid );
|
263 |
-
$meta_values =
|
264 |
// https://css-tricks.com/examples/hrs/
|
265 |
print '<html><head><style>body {font-family: monospace;} hr {
|
266 |
border: 0;
|
267 |
border-bottom: 1px dashed #ccc;
|
268 |
background: #bbb;
|
269 |
}</style></head><body>';
|
270 |
-
printf( '<p>%s</p>', __( 'This is the conversation between Postman and the mail server. It can be useful for diagnosing problems. <b>DO NOT</b> post it on-line, it may contain your account password.',
|
271 |
print '<hr/>';
|
272 |
print '<pre>';
|
273 |
if ( ! empty( $meta_values ['session_transcript'] [0] ) ) {
|
274 |
print esc_html( $meta_values ['session_transcript'] [0] );
|
275 |
} else {
|
276 |
/* Translators: Meaning "Not Applicable" */
|
277 |
-
print __( 'n/a',
|
278 |
}
|
279 |
print '</pre>';
|
280 |
print '</body></html>';
|
@@ -299,8 +299,8 @@ class PostmanEmailLogController {
|
|
299 |
$this->logger->trace( 'created PostmanEmailLog admin menu item' );
|
300 |
/*
|
301 |
Translators where (%s) is the name of the plugin */
|
302 |
-
$pageTitle = sprintf( __( '%s Email Log',
|
303 |
-
$pluginName = _x( 'Email Log', 'The log of Emails that have been delivered',
|
304 |
|
305 |
$page = add_submenu_page( PostmanViewController::POSTMAN_MENU_SLUG, $pageTitle, $pluginName, Postman::MANAGE_POSTMAN_CAPABILITY_LOGS, 'postman_email_log', array( $this, 'postman_render_email_page' ) );
|
306 |
|
@@ -317,10 +317,10 @@ class PostmanEmailLogController {
|
|
317 |
wp_enqueue_style( 'postman_email_log' );
|
318 |
wp_enqueue_script( 'postman_resend_email_script' );
|
319 |
wp_enqueue_script( 'sprintf' );
|
320 |
-
wp_localize_script( 'postman_resend_email_script', 'postman_js_email_was_resent', __( 'Email was successfully resent (but without attachments)',
|
321 |
/* Translators: Where %s is an error message */
|
322 |
-
wp_localize_script( 'postman_resend_email_script', 'postman_js_email_not_resent', __( 'Email could not be resent. Error: %s',
|
323 |
-
wp_localize_script( 'postman_resend_email_script', 'postman_js_resend_label', __( 'Resend',
|
324 |
}
|
325 |
|
326 |
/**
|
@@ -349,13 +349,15 @@ class PostmanEmailLogController {
|
|
349 |
</div>
|
350 |
<h2><?php
|
351 |
/* Translators where (%s) is the name of the plugin */
|
352 |
-
echo sprintf( __( '%s Email Log',
|
|
|
|
|
353 |
|
354 |
<div
|
355 |
style="background: #ECECEC; border: 1px solid #CCC; padding: 0 10px; margin-top: 5px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px;">
|
356 |
<p><?php
|
357 |
|
358 |
-
echo __( 'This is a record of deliveries made to the mail server. It does not neccessarily indicate sucessful delivery to the recipient.',
|
359 |
</div>
|
360 |
|
361 |
<?php
|
@@ -369,19 +371,19 @@ class PostmanEmailLogController {
|
|
369 |
<form id="postman-email-log-filter" method="post">
|
370 |
<div id="email-log-filter" class="postman-log-row">
|
371 |
<div class="form-control">
|
372 |
-
<label for="from_date"><?php _e( 'From Date',
|
373 |
-
<input id="from_date" class="email-log-date" value="<?php echo $from_date; ?>" type="text" name="from_date" placeholder="<?php _e( 'From Date',
|
374 |
</div>
|
375 |
<div class="form-control">
|
376 |
-
<label for="to_date"><?php _e( 'To Date',
|
377 |
-
<input id="to_date" class="email-log-date" value="<?php echo $to_date; ?>" type="text" name="to_date" placeholder="<?php _e( 'To Date',
|
378 |
</div>
|
379 |
<div class="form-control">
|
380 |
-
<label for="search"><?php _e( 'Search',
|
381 |
-
<input id="search" type="text" name="search" value="<?php echo $search; ?>" placeholder="<?php _e( 'Search',
|
382 |
</div>
|
383 |
<div class="form-control">
|
384 |
-
<label id="postman_page_records"><?php _e( 'Records per page',
|
385 |
<select id="postman_page_records" name="postman_page_records">
|
386 |
<?php
|
387 |
foreach ( $page_records as $value ) {
|
@@ -392,10 +394,10 @@ class PostmanEmailLogController {
|
|
392 |
</select>
|
393 |
</div>
|
394 |
<div class="form-control" style="padding: 0 5px 0 5px;">
|
395 |
-
<button type="submit" name="filter" class="button button-primary"><?php _e( 'Filter/Search',
|
396 |
</div>
|
397 |
<div class="form-control">
|
398 |
-
<button type="submit" id="postman_trash_all" name="postman_trash_all" class="button button-primary"><?php _e( 'Trash All',
|
399 |
</div>
|
400 |
</div>
|
401 |
<div class="error">Please notice: when you select a date for example 11/20/2017, behind the scene the query select <b>11/20/2017 00:00:00</b>.<br>So if you searching for an email arrived that day at any hour you need to select 11/20/2017 as the <b>From Date</b> and 11/21/2017 as the <b>To Date</b>.</div>
|
1 |
<?php
|
2 |
+
require_once dirname(__DIR__) . '/PostmanEmailLogs.php';
|
3 |
require_once 'PostmanEmailLogService.php';
|
4 |
require_once 'PostmanEmailLogView.php';
|
5 |
|
78 |
// get the email address of the recipient from the HTTP Request
|
79 |
$postid = $this->getRequestParameter( 'email' );
|
80 |
if ( ! empty( $postid ) ) {
|
81 |
+
$meta_values = PostmanEmailLogs::get_data( $postid );
|
|
|
82 |
|
83 |
if ( isset( $_POST['mail_to'] ) && ! empty( $_POST['mail_to'] ) ) {
|
84 |
$emails = explode( ',', $_POST['mail_to'] );
|
87 |
$to = $meta_values ['original_to'] [0];
|
88 |
}
|
89 |
|
90 |
+
$success = wp_mail( $to, $meta_values ['original_subject'] [0], maybe_unserialize( $meta_values ['original_message'] [0] ), $meta_values ['original_headers'] [0] );
|
91 |
|
92 |
// Postman API: retrieve the result of sending this message from Postman
|
93 |
$result = apply_filters( 'postman_wp_mail_result', null );
|
97 |
if ( $success ) {
|
98 |
$this->logger->debug( 'Email was successfully re-sent' );
|
99 |
// the message was sent successfully, generate an appropriate message for the user
|
100 |
+
$statusMessage = sprintf( __( 'Your message was delivered (%d ms) to the SMTP server! Congratulations :)', 'post-smtp' ), $result ['time'] );
|
101 |
|
102 |
// compose the JSON response for the caller
|
103 |
$response = array(
|
134 |
/**
|
135 |
* TODO move this somewhere reusable
|
136 |
*
|
137 |
+
* @param mixed $parameterName
|
138 |
+
* @return mixed
|
139 |
*/
|
140 |
private function getRequestParameter( $parameterName ) {
|
141 |
if ( isset( $_POST [ $parameterName ] ) ) {
|
163 |
$purger->verifyLogItemExistsAndRemove( $postid );
|
164 |
}
|
165 |
$mh = new PostmanMessageHandler();
|
166 |
+
$mh->addMessage( __( 'Mail Log Entries were deleted.', 'post-smtp' ) );
|
167 |
} else {
|
168 |
$this->logger->warn( sprintf( 'action "%s" not recognized', $_REQUEST ['action'] ) );
|
169 |
}
|
186 |
$purger = new PostmanEmailLogPurger();
|
187 |
$purger->verifyLogItemExistsAndRemove( $postid );
|
188 |
$mh = new PostmanMessageHandler();
|
189 |
+
$mh->addMessage( __( 'Mail Log Entry was deleted.', 'post-smtp' ) );
|
190 |
} else {
|
191 |
$this->logger->warn( sprintf( 'nonce "%s" failed validation', $_REQUEST ['_wpnonce'] ) );
|
192 |
}
|
202 |
$this->logger->trace( 'handling view item' );
|
203 |
$postid = $_REQUEST ['email'];
|
204 |
$post = get_post( $postid );
|
205 |
+
$meta_values = PostmanEmailLogs::get_data( $postid );
|
206 |
// https://css-tricks.com/examples/hrs/
|
207 |
print '<html><head><style>body {font-family: monospace;} hr {
|
208 |
border: 0;
|
211 |
}</style></head><body>';
|
212 |
print '<table>';
|
213 |
if ( ! empty( $meta_values ['from_header'] [0] ) ) {
|
214 |
+
printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'From', 'Who is this message From?', 'post-smtp' ), esc_html( $meta_values ['from_header'] [0] ) );
|
215 |
}
|
216 |
// show the To header (it's optional)
|
217 |
if ( ! empty( $meta_values ['to_header'] [0] ) ) {
|
218 |
+
printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'To', 'Who is this message To?', 'post-smtp' ), esc_html( $meta_values ['to_header'] [0] ) );
|
219 |
}
|
220 |
// show the Cc header (it's optional)
|
221 |
if ( ! empty( $meta_values ['cc_header'] [0] ) ) {
|
222 |
+
printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Cc', 'Who is this message Cc\'d to?', 'post-smtp' ), esc_html( $meta_values ['cc_header'] [0] ) );
|
223 |
}
|
224 |
// show the Bcc header (it's optional)
|
225 |
if ( ! empty( $meta_values ['bcc_header'] [0] ) ) {
|
226 |
+
printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Bcc', 'Who is this message Bcc\'d to?', 'post-smtp' ), esc_html( $meta_values ['bcc_header'] [0] ) );
|
227 |
}
|
228 |
// show the Reply-To header (it's optional)
|
229 |
if ( ! empty( $meta_values ['reply_to_header'] [0] ) ) {
|
230 |
+
printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', __( 'Reply-To', 'post-smtp' ), esc_html( $meta_values ['reply_to_header'] [0] ) );
|
231 |
}
|
232 |
+
printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Date', 'What is the date today?', 'post-smtp' ), $post->post_date );
|
233 |
+
printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Subject', 'What is the subject of this message?', 'post-smtp' ), esc_html( $post->post_title ) );
|
234 |
// The Transport UI is always there, in more recent versions that is
|
235 |
if ( ! empty( $meta_values ['transport_uri'] [0] ) ) {
|
236 |
+
printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Delivery-URI', 'What is the unique URI of the configuration?', 'post-smtp' ), esc_html( $meta_values ['transport_uri'] [0] ) );
|
237 |
}
|
238 |
print '</table>';
|
239 |
print '<hr/>';
|
260 |
$this->logger->trace( 'handling view transcript item' );
|
261 |
$postid = $_REQUEST ['email'];
|
262 |
$post = get_post( $postid );
|
263 |
+
$meta_values = PostmanEmailLogs::get_data( $postid );
|
264 |
// https://css-tricks.com/examples/hrs/
|
265 |
print '<html><head><style>body {font-family: monospace;} hr {
|
266 |
border: 0;
|
267 |
border-bottom: 1px dashed #ccc;
|
268 |
background: #bbb;
|
269 |
}</style></head><body>';
|
270 |
+
printf( '<p>%s</p>', __( 'This is the conversation between Postman and the mail server. It can be useful for diagnosing problems. <b>DO NOT</b> post it on-line, it may contain your account password.', 'post-smtp' ) );
|
271 |
print '<hr/>';
|
272 |
print '<pre>';
|
273 |
if ( ! empty( $meta_values ['session_transcript'] [0] ) ) {
|
274 |
print esc_html( $meta_values ['session_transcript'] [0] );
|
275 |
} else {
|
276 |
/* Translators: Meaning "Not Applicable" */
|
277 |
+
print __( 'n/a', 'post-smtp' );
|
278 |
}
|
279 |
print '</pre>';
|
280 |
print '</body></html>';
|
299 |
$this->logger->trace( 'created PostmanEmailLog admin menu item' );
|
300 |
/*
|
301 |
Translators where (%s) is the name of the plugin */
|
302 |
+
$pageTitle = sprintf( __( '%s Email Log', 'post-smtp' ), __( 'Post SMTP', 'post-smtp' ) );
|
303 |
+
$pluginName = _x( 'Email Log', 'The log of Emails that have been delivered', 'post-smtp' );
|
304 |
|
305 |
$page = add_submenu_page( PostmanViewController::POSTMAN_MENU_SLUG, $pageTitle, $pluginName, Postman::MANAGE_POSTMAN_CAPABILITY_LOGS, 'postman_email_log', array( $this, 'postman_render_email_page' ) );
|
306 |
|
317 |
wp_enqueue_style( 'postman_email_log' );
|
318 |
wp_enqueue_script( 'postman_resend_email_script' );
|
319 |
wp_enqueue_script( 'sprintf' );
|
320 |
+
wp_localize_script( 'postman_resend_email_script', 'postman_js_email_was_resent', __( 'Email was successfully resent (but without attachments)', 'post-smtp' ) );
|
321 |
/* Translators: Where %s is an error message */
|
322 |
+
wp_localize_script( 'postman_resend_email_script', 'postman_js_email_not_resent', __( 'Email could not be resent. Error: %s', 'post-smtp' ) );
|
323 |
+
wp_localize_script( 'postman_resend_email_script', 'postman_js_resend_label', __( 'Resend', 'post-smtp' ) );
|
324 |
}
|
325 |
|
326 |
/**
|
349 |
</div>
|
350 |
<h2><?php
|
351 |
/* Translators where (%s) is the name of the plugin */
|
352 |
+
echo sprintf( __( '%s Email Log', 'post-smtp' ), __( 'Post SMTP', 'post-smtp' ) )?></h2>
|
353 |
+
|
354 |
+
<?php include_once POST_PATH . '/Postman/extra/donation.php'; ?>
|
355 |
|
356 |
<div
|
357 |
style="background: #ECECEC; border: 1px solid #CCC; padding: 0 10px; margin-top: 5px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px;">
|
358 |
<p><?php
|
359 |
|
360 |
+
echo __( 'This is a record of deliveries made to the mail server. It does not neccessarily indicate sucessful delivery to the recipient.', 'post-smtp' )?></p>
|
361 |
</div>
|
362 |
|
363 |
<?php
|
371 |
<form id="postman-email-log-filter" method="post">
|
372 |
<div id="email-log-filter" class="postman-log-row">
|
373 |
<div class="form-control">
|
374 |
+
<label for="from_date"><?php _e( 'From Date', 'post-smtp' ); ?></label>
|
375 |
+
<input id="from_date" class="email-log-date" value="<?php echo $from_date; ?>" type="text" name="from_date" placeholder="<?php _e( 'From Date', 'post-smtp' ); ?>">
|
376 |
</div>
|
377 |
<div class="form-control">
|
378 |
+
<label for="to_date"><?php _e( 'To Date', 'post-smtp' ); ?></label>
|
379 |
+
<input id="to_date" class="email-log-date" value="<?php echo $to_date; ?>" type="text" name="to_date" placeholder="<?php _e( 'To Date', 'post-smtp' ); ?>">
|
380 |
</div>
|
381 |
<div class="form-control">
|
382 |
+
<label for="search"><?php _e( 'Search', 'post-smtp' ); ?></label>
|
383 |
+
<input id="search" type="text" name="search" value="<?php echo $search; ?>" placeholder="<?php _e( 'Search', 'post-smtp' ); ?>">
|
384 |
</div>
|
385 |
<div class="form-control">
|
386 |
+
<label id="postman_page_records"><?php _e( 'Records per page', 'post-smtp' ); ?></label>
|
387 |
<select id="postman_page_records" name="postman_page_records">
|
388 |
<?php
|
389 |
foreach ( $page_records as $value ) {
|
394 |
</select>
|
395 |
</div>
|
396 |
<div class="form-control" style="padding: 0 5px 0 5px;">
|
397 |
+
<button type="submit" name="filter" class="button button-primary"><?php _e( 'Filter/Search', 'post-smtp' ); ?></button>
|
398 |
</div>
|
399 |
<div class="form-control">
|
400 |
+
<button type="submit" id="postman_trash_all" name="postman_trash_all" class="button button-primary"><?php _e( 'Trash All', 'post-smtp' ); ?></button>
|
401 |
</div>
|
402 |
</div>
|
403 |
<div class="error">Please notice: when you select a date for example 11/20/2017, behind the scene the query select <b>11/20/2017 00:00:00</b>.<br>So if you searching for an email arrived that day at any hour you need to select 11/20/2017 as the <b>From Date</b> and 11/21/2017 as the <b>To Date</b>.</div>
|
Postman/Postman-Email-Log/PostmanEmailLogPostType.php
CHANGED
@@ -34,8 +34,8 @@ if (! class_exists ( 'PostmanEmailLogPostType' )) {
|
|
34 |
public static function create_post_type() {
|
35 |
register_post_type ( self::POSTMAN_CUSTOM_POST_TYPE_SLUG, array (
|
36 |
'labels' => array (
|
37 |
-
'name' => _x ( 'Sent Emails', 'The group of Emails that have been delivered',
|
38 |
-
'singular_name' => _x ( 'Sent Email', 'An Email that has been delivered',
|
39 |
),
|
40 |
'capability_type' => '',
|
41 |
'capabilities' => array ()
|
34 |
public static function create_post_type() {
|
35 |
register_post_type ( self::POSTMAN_CUSTOM_POST_TYPE_SLUG, array (
|
36 |
'labels' => array (
|
37 |
+
'name' => _x ( 'Sent Emails', 'The group of Emails that have been delivered', 'post-smtp' ),
|
38 |
+
'singular_name' => _x ( 'Sent Email', 'An Email that has been delivered', 'post-smtp' )
|
39 |
),
|
40 |
'capability_type' => '',
|
41 |
'capabilities' => array ()
|
Postman/Postman-Email-Log/PostmanEmailLogService.php
CHANGED
@@ -67,7 +67,7 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) {
|
|
67 |
* Logs successful email attempts
|
68 |
*
|
69 |
* @param PostmanMessage $message
|
70 |
-
* @param
|
71 |
* @param PostmanModuleTransport $transport
|
72 |
*/
|
73 |
public function writeSuccessLog( PostmanEmailLog $log, PostmanMessage $message, $transcript, PostmanModuleTransport $transport ) {
|
@@ -76,7 +76,7 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) {
|
|
76 |
$status = true;
|
77 |
$subject = $message->getSubject();
|
78 |
if ( empty( $subject ) ) {
|
79 |
-
$statusMessage = sprintf( '%s: %s', __( 'Warning',
|
80 |
$status = 'WARN';
|
81 |
}
|
82 |
$this->createLog( $log, $message, $transcript, $statusMessage, $status, $transport );
|
@@ -88,13 +88,13 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) {
|
|
88 |
* Logs failed email attempts, requires more metadata so the email can be resent in the future
|
89 |
*
|
90 |
* @param PostmanMessage $message
|
91 |
-
* @param
|
92 |
* @param PostmanModuleTransport $transport
|
93 |
-
* @param
|
94 |
-
* @param
|
95 |
-
* @param
|
96 |
-
* @param
|
97 |
-
* @param
|
98 |
*/
|
99 |
public function writeFailureLog( PostmanEmailLog $log, PostmanMessage $message = null, $transcript, PostmanModuleTransport $transport, $statusMessage ) {
|
100 |
if ( PostmanOptions::getInstance()->isMailLoggingEnabled() ) {
|
@@ -182,9 +182,9 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) {
|
|
182 |
}
|
183 |
|
184 |
private function checkForLogErrors( PostmanEmailLog $log, $postMessage ) {
|
185 |
-
$message = __( 'You getting this message because an error detected while delivered your email.',
|
186 |
-
$message .= "\r\n" . sprintf( __( 'For the domain: %1$s',
|
187 |
-
$message .= "\r\n" . __( 'The log to paste when you open a support issue:',
|
188 |
|
189 |
if ( $log->statusMessage && ! empty( $log->statusMessage ) ) {
|
190 |
require_once POST_PATH . '/Postman/notifications/PostmanNotify.php';
|
@@ -227,9 +227,9 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) {
|
|
227 |
* Creates a Log object for use by writeToEmailLog()
|
228 |
*
|
229 |
* @param PostmanMessage $message
|
230 |
-
* @param
|
231 |
-
* @param
|
232 |
-
* @param
|
233 |
* @param PostmanModuleTransport $transport
|
234 |
* @return PostmanEmailLog
|
235 |
*/
|
@@ -263,7 +263,7 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) {
|
|
263 |
$count = 0;
|
264 |
foreach ( $addresses as $address ) {
|
265 |
if ( $count >= 3 ) {
|
266 |
-
$flat .= sprintf( __( '.. +%d more',
|
267 |
break;
|
268 |
}
|
269 |
if ( $count > 0 ) {
|
@@ -284,7 +284,7 @@ if ( ! class_exists( 'PostmanEmailLogPurger' ) ) {
|
|
284 |
|
285 |
/**
|
286 |
*
|
287 |
-
* @return
|
288 |
*/
|
289 |
function __construct( $args = array() ) {
|
290 |
$this->logger = new PostmanLogger( get_class( $this ) );
|
@@ -313,7 +313,7 @@ if ( ! class_exists( 'PostmanEmailLogPurger' ) ) {
|
|
313 |
/**
|
314 |
*
|
315 |
* @param array $posts
|
316 |
-
* @param
|
317 |
*/
|
318 |
function verifyLogItemExistsAndRemove( $postid ) {
|
319 |
$force_delete = true;
|
@@ -336,7 +336,7 @@ if ( ! class_exists( 'PostmanEmailLogPurger' ) ) {
|
|
336 |
|
337 |
/**
|
338 |
*
|
339 |
-
* @param
|
340 |
*/
|
341 |
function truncateLogItems( $size ) {
|
342 |
$index = count( $this->posts );
|
67 |
* Logs successful email attempts
|
68 |
*
|
69 |
* @param PostmanMessage $message
|
70 |
+
* @param mixed $transcript
|
71 |
* @param PostmanModuleTransport $transport
|
72 |
*/
|
73 |
public function writeSuccessLog( PostmanEmailLog $log, PostmanMessage $message, $transcript, PostmanModuleTransport $transport ) {
|
76 |
$status = true;
|
77 |
$subject = $message->getSubject();
|
78 |
if ( empty( $subject ) ) {
|
79 |
+
$statusMessage = sprintf( '%s: %s', __( 'Warning', 'post-smtp' ), __( 'An empty subject line can result in delivery failure.', 'post-smtp' ) );
|
80 |
$status = 'WARN';
|
81 |
}
|
82 |
$this->createLog( $log, $message, $transcript, $statusMessage, $status, $transport );
|
88 |
* Logs failed email attempts, requires more metadata so the email can be resent in the future
|
89 |
*
|
90 |
* @param PostmanMessage $message
|
91 |
+
* @param mixed $transcript
|
92 |
* @param PostmanModuleTransport $transport
|
93 |
+
* @param mixed $statusMessage
|
94 |
+
* @param mixed $originalTo
|
95 |
+
* @param mixed $originalSubject
|
96 |
+
* @param mixed $originalMessage
|
97 |
+
* @param mixed $originalHeaders
|
98 |
*/
|
99 |
public function writeFailureLog( PostmanEmailLog $log, PostmanMessage $message = null, $transcript, PostmanModuleTransport $transport, $statusMessage ) {
|
100 |
if ( PostmanOptions::getInstance()->isMailLoggingEnabled() ) {
|
182 |
}
|
183 |
|
184 |
private function checkForLogErrors( PostmanEmailLog $log, $postMessage ) {
|
185 |
+
$message = __( 'You getting this message because an error detected while delivered your email.', 'post-smtp' );
|
186 |
+
$message .= "\r\n" . sprintf( __( 'For the domain: %1$s','post-smtp' ), get_bloginfo('url') );
|
187 |
+
$message .= "\r\n" . __( 'The log to paste when you open a support issue:', 'post-smtp' ) . "\r\n";
|
188 |
|
189 |
if ( $log->statusMessage && ! empty( $log->statusMessage ) ) {
|
190 |
require_once POST_PATH . '/Postman/notifications/PostmanNotify.php';
|
227 |
* Creates a Log object for use by writeToEmailLog()
|
228 |
*
|
229 |
* @param PostmanMessage $message
|
230 |
+
* @param mixed $transcript
|
231 |
+
* @param mixed $statusMessage
|
232 |
+
* @param mixed $success
|
233 |
* @param PostmanModuleTransport $transport
|
234 |
* @return PostmanEmailLog
|
235 |
*/
|
263 |
$count = 0;
|
264 |
foreach ( $addresses as $address ) {
|
265 |
if ( $count >= 3 ) {
|
266 |
+
$flat .= sprintf( __( '.. +%d more', 'post-smtp' ), sizeof( $addresses ) - $count );
|
267 |
break;
|
268 |
}
|
269 |
if ( $count > 0 ) {
|
284 |
|
285 |
/**
|
286 |
*
|
287 |
+
* @return mixed
|
288 |
*/
|
289 |
function __construct( $args = array() ) {
|
290 |
$this->logger = new PostmanLogger( get_class( $this ) );
|
313 |
/**
|
314 |
*
|
315 |
* @param array $posts
|
316 |
+
* @param mixed $postid
|
317 |
*/
|
318 |
function verifyLogItemExistsAndRemove( $postid ) {
|
319 |
$force_delete = true;
|
336 |
|
337 |
/**
|
338 |
*
|
339 |
+
* @param mixed $size
|
340 |
*/
|
341 |
function truncateLogItems( $size ) {
|
342 |
$index = count( $this->posts );
|
Postman/Postman-Email-Log/PostmanEmailLogView.php
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
3 |
/**
|
4 |
* See http://wpengineer.com/2426/wp_list_table-a-step-by-step-guide/
|
5 |
*/
|
@@ -92,25 +94,25 @@ class PostmanEmailLogView extends WP_List_Table {
|
|
92 |
$transcriptUrl = admin_url( sprintf( $iframeUri, 'transcript', $item ['ID'] ) );
|
93 |
$resendUrl = admin_url( sprintf( $iframeUri, 'resend', $item ['ID'] ) );
|
94 |
|
95 |
-
$meta_values =
|
96 |
|
97 |
$actions = array(
|
98 |
-
'delete' => sprintf( '<a href="%s">%s</a>', $deleteUrl, _x( 'Delete', 'Delete an item from the email log',
|
99 |
-
'view' => sprintf( '<a href="%s" class="thickbox">%s</a>', $viewUrl, _x( 'View', 'View an item from the email log',
|
100 |
);
|
101 |
|
102 |
if ( ! empty( $meta_values ['session_transcript'] [0] ) ) {
|
103 |
-
$actions ['transcript'] = sprintf( '<a href="%1$s" class="thickbox">%2$s</a>', $transcriptUrl, __( 'Session Transcript',
|
104 |
} else {
|
105 |
-
$actions ['transcript'] = sprintf( '%2$s', $transcriptUrl, __( 'Session Transcript',
|
106 |
}
|
107 |
if ( ! (empty( $meta_values ['original_to'] [0] ) && empty( $meta_values ['originalHeaders'] [0] )) ) {
|
108 |
-
// $actions ['resend'] = sprintf ( '<a href="%s">%s</a>', $resendUrl, __ ( 'Resend',
|
109 |
$emails = maybe_unserialize( $meta_values ['original_to'] [0] );
|
110 |
$to = is_array( $emails ) ? implode( ',', $emails ) : $emails;
|
111 |
-
$actions ['resend'] = sprintf( '<span id="%3$s"><a class="postman-open-resend" href="#">%2$s</a></span><div style="display:none;"><input type="hidden" name="security" value="%6$s"><input type="text" name="mail_to" class="regular-text ltr" data-id="%1$s" value="%4$s"><button class="postman-resend button button-primary">%2$s</button><i style="color: black;">%5$s</i></div>', $item ['ID'], __( 'Resend',
|
112 |
} else {
|
113 |
-
$actions ['resend'] = sprintf( '%2$s', $resendUrl, __( 'Resend',
|
114 |
}
|
115 |
|
116 |
// Return the title contents
|
@@ -159,10 +161,10 @@ class PostmanEmailLogView extends WP_List_Table {
|
|
159 |
function get_columns() {
|
160 |
$columns = array(
|
161 |
'cb' => '<input type="checkbox" />', // Render a checkbox instead of text
|
162 |
-
'title' => _x( 'Subject', 'What is the subject of this message?',
|
163 |
-
'sent_to' => __( 'Sent To',
|
164 |
-
'status' => __( 'Status',
|
165 |
-
'date' => _x( 'Delivery Time', 'When was this email sent?',
|
166 |
);
|
167 |
return $columns;
|
168 |
}
|
@@ -222,7 +224,7 @@ class PostmanEmailLogView extends WP_List_Table {
|
|
222 |
*/
|
223 |
function get_bulk_actions() {
|
224 |
$actions = array(
|
225 |
-
'bulk_delete' => _x( 'Delete', 'Delete an item from the email log',
|
226 |
);
|
227 |
return $actions;
|
228 |
}
|
@@ -363,16 +365,16 @@ class PostmanEmailLogView extends WP_List_Table {
|
|
363 |
// if this PHP system support humanTime, than use it
|
364 |
if ( ! empty( $humanTime ) ) {
|
365 |
/* Translators: where %s indicates the relative time from now */
|
366 |
-
$date = sprintf( _x( '%s ago', 'A relative time as in "five days ago"',
|
367 |
}
|
368 |
-
$meta_values =
|
369 |
$sent_to = array_map( 'sanitize_email', explode( ',' , $meta_values ['to_header'] [0] ) );
|
370 |
$flattenedPost = array(
|
371 |
// the post title must be escaped as they are displayed in the HTML output
|
372 |
'sent_to' => implode( ', ', $sent_to ),
|
373 |
'title' => esc_html( $post->post_title ),
|
374 |
// the post status must be escaped as they are displayed in the HTML output
|
375 |
-
'status' => ($post->post_excerpt != null ? esc_html( $post->post_excerpt ) : __( 'Sent',
|
376 |
'date' => date( "$date_format $time_format", strtotime( $post->post_date ) ),
|
377 |
'ID' => $post->ID,
|
378 |
);
|
1 |
<?php
|
2 |
|
3 |
+
require_once dirname(__DIR__) . '/PostmanEmailLogs.php';
|
4 |
+
|
5 |
/**
|
6 |
* See http://wpengineer.com/2426/wp_list_table-a-step-by-step-guide/
|
7 |
*/
|
94 |
$transcriptUrl = admin_url( sprintf( $iframeUri, 'transcript', $item ['ID'] ) );
|
95 |
$resendUrl = admin_url( sprintf( $iframeUri, 'resend', $item ['ID'] ) );
|
96 |
|
97 |
+
$meta_values = PostmanEmailLogs::get_data( $item ['ID'] );
|
98 |
|
99 |
$actions = array(
|
100 |
+
'delete' => sprintf( '<a href="%s">%s</a>', $deleteUrl, _x( 'Delete', 'Delete an item from the email log', 'post-smtp' ) ),
|
101 |
+
'view' => sprintf( '<a href="%s" class="thickbox">%s</a>', $viewUrl, _x( 'View', 'View an item from the email log', 'post-smtp' ) ),
|
102 |
);
|
103 |
|
104 |
if ( ! empty( $meta_values ['session_transcript'] [0] ) ) {
|
105 |
+
$actions ['transcript'] = sprintf( '<a href="%1$s" class="thickbox">%2$s</a>', $transcriptUrl, __( 'Session Transcript', 'post-smtp' ) );
|
106 |
} else {
|
107 |
+
$actions ['transcript'] = sprintf( '%2$s', $transcriptUrl, __( 'Session Transcript', 'post-smtp' ) );
|
108 |
}
|
109 |
if ( ! (empty( $meta_values ['original_to'] [0] ) && empty( $meta_values ['originalHeaders'] [0] )) ) {
|
110 |
+
// $actions ['resend'] = sprintf ( '<a href="%s">%s</a>', $resendUrl, __ ( 'Resend', 'post-smtp' ) );
|
111 |
$emails = maybe_unserialize( $meta_values ['original_to'] [0] );
|
112 |
$to = is_array( $emails ) ? implode( ',', $emails ) : $emails;
|
113 |
+
$actions ['resend'] = sprintf( '<span id="%3$s"><a class="postman-open-resend" href="#">%2$s</a></span><div style="display:none;"><input type="hidden" name="security" value="%6$s"><input type="text" name="mail_to" class="regular-text ltr" data-id="%1$s" value="%4$s"><button class="postman-resend button button-primary">%2$s</button><i style="color: black;">%5$s</i></div>', $item ['ID'], __( 'Resend', 'post-smtp' ), 'resend-' . $item ['ID'], esc_attr( $to ), __( 'comma-separated for multiple emails', 'post-smtp' ), wp_create_nonce( 'resend' ) );
|
114 |
} else {
|
115 |
+
$actions ['resend'] = sprintf( '%2$s', $resendUrl, __( 'Resend', 'post-smtp' ) );
|
116 |
}
|
117 |
|
118 |
// Return the title contents
|
161 |
function get_columns() {
|
162 |
$columns = array(
|
163 |
'cb' => '<input type="checkbox" />', // Render a checkbox instead of text
|
164 |
+
'title' => _x( 'Subject', 'What is the subject of this message?', 'post-smtp' ),
|
165 |
+
'sent_to' => __( 'Sent To', 'post-smtp' ),
|
166 |
+
'status' => __( 'Status', 'post-smtp' ),
|
167 |
+
'date' => _x( 'Delivery Time', 'When was this email sent?', 'post-smtp' ),
|
168 |
);
|
169 |
return $columns;
|
170 |
}
|
224 |
*/
|
225 |
function get_bulk_actions() {
|
226 |
$actions = array(
|
227 |
+
'bulk_delete' => _x( 'Delete', 'Delete an item from the email log', 'post-smtp' ),
|
228 |
);
|
229 |
return $actions;
|
230 |
}
|
365 |
// if this PHP system support humanTime, than use it
|
366 |
if ( ! empty( $humanTime ) ) {
|
367 |
/* Translators: where %s indicates the relative time from now */
|
368 |
+
$date = sprintf( _x( '%s ago', 'A relative time as in "five days ago"', 'post-smtp' ), $humanTime );
|
369 |
}
|
370 |
+
$meta_values = PostmanEmailLogs::get_data( $post->ID );
|
371 |
$sent_to = array_map( 'sanitize_email', explode( ',' , $meta_values ['to_header'] [0] ) );
|
372 |
$flattenedPost = array(
|
373 |
// the post title must be escaped as they are displayed in the HTML output
|
374 |
'sent_to' => implode( ', ', $sent_to ),
|
375 |
'title' => esc_html( $post->post_title ),
|
376 |
// the post status must be escaped as they are displayed in the HTML output
|
377 |
+
'status' => ($post->post_excerpt != null ? esc_html( $post->post_excerpt ) : __( 'Sent', 'post-smtp' )),
|
378 |
'date' => date( "$date_format $time_format", strtotime( $post->post_date ) ),
|
379 |
'ID' => $post->ID,
|
380 |
);
|
Postman/Postman-Mail/PostmanDefaultModuleTransport.php
CHANGED
@@ -8,7 +8,7 @@ if (! class_exists ( 'PostmanSmtpModuleTransport' )) {
|
|
8 |
|
9 |
/**
|
10 |
*
|
11 |
-
* @param
|
12 |
*/
|
13 |
public function __construct($rootPluginFilenameAndPath) {
|
14 |
parent::__construct ( $rootPluginFilenameAndPath );
|
@@ -102,7 +102,7 @@ if (! class_exists ( 'PostmanSmtpModuleTransport' )) {
|
|
102 |
return self::SLUG;
|
103 |
}
|
104 |
public function getName() {
|
105 |
-
return __ ( 'Default',
|
106 |
}
|
107 |
public function getHostname() {
|
108 |
return 'localhost';
|
8 |
|
9 |
/**
|
10 |
*
|
11 |
+
* @param mixed $rootPluginFilenameAndPath
|
12 |
*/
|
13 |
public function __construct($rootPluginFilenameAndPath) {
|
14 |
parent::__construct ( $rootPluginFilenameAndPath );
|
102 |
return self::SLUG;
|
103 |
}
|
104 |
public function getName() {
|
105 |
+
return __ ( 'Default', 'post-smtp' );
|
106 |
}
|
107 |
public function getHostname() {
|
108 |
return 'localhost';
|
Postman/Postman-Mail/PostmanEmailAddress.php
CHANGED
@@ -61,8 +61,8 @@ if (! class_exists ( 'PostmanEmailAddress' )) {
|
|
61 |
/**
|
62 |
* Accept a String of addresses or an array and return an array
|
63 |
*
|
64 |
-
* @param
|
65 |
-
* @param
|
66 |
*/
|
67 |
public static function convertToArray($emails) {
|
68 |
assert ( ! empty ( $emails ) );
|
61 |
/**
|
62 |
* Accept a String of addresses or an array and return an array
|
63 |
*
|
64 |
+
* @param mixed $recipientList
|
65 |
+
* @param mixed $recipients
|
66 |
*/
|
67 |
public static function convertToArray($emails) {
|
68 |
assert ( ! empty ( $emails ) );
|
Postman/Postman-Mail/PostmanGmailApiModuleTransport.php
CHANGED
@@ -98,7 +98,7 @@ class PostmanGmailApiModuleTransport extends PostmanAbstractZendModuleTransport
|
|
98 |
return self::SLUG;
|
99 |
}
|
100 |
public function getName() {
|
101 |
-
return __ ( 'Gmail API',
|
102 |
}
|
103 |
public function isEnvelopeFromValidationSupported() {
|
104 |
return false;
|
@@ -148,7 +148,7 @@ class PostmanGmailApiModuleTransport extends PostmanAbstractZendModuleTransport
|
|
148 |
*/
|
149 |
public function getDeliveryDetails() {
|
150 |
/* translators: where (1) is the secure icon and (2) is the transport name */
|
151 |
-
return sprintf ( __ ( 'Postman will send mail via the <b>%1$s %2$s</b>.',
|
152 |
}
|
153 |
|
154 |
/**
|
@@ -162,7 +162,7 @@ class PostmanGmailApiModuleTransport extends PostmanAbstractZendModuleTransport
|
|
162 |
$this->setReadyForOAuthGrant ();
|
163 |
if ($this->isPermissionNeeded ()) {
|
164 |
/* translators: %1$s is the Client ID label, and %2$s is the Client Secret label */
|
165 |
-
$message = sprintf ( __ ( 'You have configured OAuth 2.0 authentication, but have not received permission to use it.',
|
166 |
$message .= sprintf ( ' <a href="%s">%s</a>.', PostmanUtils::getGrantOAuthPermissionUrl (), $this->getScribe ()->getRequestPermissionLinkText () );
|
167 |
array_push ( $messages, $message );
|
168 |
$this->setNotConfiguredAndReady ();
|
@@ -189,7 +189,7 @@ class PostmanGmailApiModuleTransport extends PostmanAbstractZendModuleTransport
|
|
189 |
*
|
190 |
* 70 gmail api on port 465 to www.googleapis.com
|
191 |
*
|
192 |
-
* @param
|
193 |
*/
|
194 |
public function getConfigurationBid(PostmanWizardSocket $hostData, $userAuthOverride, $originalSmtpServer) {
|
195 |
$recommendation = array ();
|
@@ -217,7 +217,7 @@ class PostmanGmailApiModuleTransport extends PostmanAbstractZendModuleTransport
|
|
217 |
$overrideItem ['auth_items'] = array (
|
218 |
array (
|
219 |
'selected' => true,
|
220 |
-
'name' => __ ( 'OAuth 2.0 (requires Client ID and Client Secret)',
|
221 |
'value' => 'oauth2'
|
222 |
)
|
223 |
);
|
98 |
return self::SLUG;
|
99 |
}
|
100 |
public function getName() {
|
101 |
+
return __ ( 'Gmail API', 'post-smtp' );
|
102 |
}
|
103 |
public function isEnvelopeFromValidationSupported() {
|
104 |
return false;
|
148 |
*/
|
149 |
public function getDeliveryDetails() {
|
150 |
/* translators: where (1) is the secure icon and (2) is the transport name */
|
151 |
+
return sprintf ( __ ( 'Postman will send mail via the <b>%1$s %2$s</b>.', 'post-smtp' ), '🔐', $this->getName () );
|
152 |
}
|
153 |
|
154 |
/**
|
162 |
$this->setReadyForOAuthGrant ();
|
163 |
if ($this->isPermissionNeeded ()) {
|
164 |
/* translators: %1$s is the Client ID label, and %2$s is the Client Secret label */
|
165 |
+
$message = sprintf ( __ ( 'You have configured OAuth 2.0 authentication, but have not received permission to use it.', 'post-smtp' ), $this->getScribe ()->getClientIdLabel (), $this->getScribe ()->getClientSecretLabel () );
|
166 |
$message .= sprintf ( ' <a href="%s">%s</a>.', PostmanUtils::getGrantOAuthPermissionUrl (), $this->getScribe ()->getRequestPermissionLinkText () );
|
167 |
array_push ( $messages, $message );
|
168 |
$this->setNotConfiguredAndReady ();
|
189 |
*
|
190 |
* 70 gmail api on port 465 to www.googleapis.com
|
191 |
*
|
192 |
+
* @param mixed $hostData
|
193 |
*/
|
194 |
public function getConfigurationBid(PostmanWizardSocket $hostData, $userAuthOverride, $originalSmtpServer) {
|
195 |
$recommendation = array ();
|
217 |
$overrideItem ['auth_items'] = array (
|
218 |
array (
|
219 |
'selected' => true,
|
220 |
+
'name' => __ ( 'OAuth 2.0 (requires Client ID and Client Secret)', 'post-smtp' ),
|
221 |
'value' => 'oauth2'
|
222 |
)
|
223 |
);
|
Postman/Postman-Mail/PostmanGmailApiModuleZendMailTransport.php
CHANGED
@@ -112,7 +112,7 @@ if (! class_exists ( 'PostmanGmailApiModuleZendMailTransport' )) {
|
|
112 |
*
|
113 |
* @param string $host
|
114 |
* OPTIONAL (Default: 127.0.0.1)
|
115 |
-
* @param array
|
116 |
* OPTIONAL (Default: null)
|
117 |
* @return void
|
118 |
*
|
@@ -165,7 +165,7 @@ if (! class_exists ( 'PostmanGmailApiModuleZendMailTransport' )) {
|
|
165 |
/**
|
166 |
* Gets the connection protocol instance
|
167 |
*
|
168 |
-
* @return
|
169 |
*/
|
170 |
public function getConnection() {
|
171 |
return $this->_connection;
|
112 |
*
|
113 |
* @param string $host
|
114 |
* OPTIONAL (Default: 127.0.0.1)
|
115 |
+
* @param array $config
|
116 |
* OPTIONAL (Default: null)
|
117 |
* @return void
|
118 |
*
|
165 |
/**
|
166 |
* Gets the connection protocol instance
|
167 |
*
|
168 |
+
* @return Postman_Zend_Mail_Protocol_Abstract|null
|
169 |
*/
|
170 |
public function getConnection() {
|
171 |
return $this->_connection;
|
Postman/Postman-Mail/PostmanMailgunMailEngine.php
CHANGED
@@ -27,8 +27,8 @@ if ( ! class_exists( 'PostmanMailgunMailEngine' ) ) {
|
|
27 |
|
28 |
/**
|
29 |
*
|
30 |
-
* @param
|
31 |
-
* @param
|
32 |
*/
|
33 |
function __construct( $apiKey, $domainName ) {
|
34 |
assert( ! empty( $apiKey ) );
|
27 |
|
28 |
/**
|
29 |
*
|
30 |
+
* @param mixed $senderEmail
|
31 |
+
* @param mixed $accessToken
|
32 |
*/
|
33 |
function __construct( $apiKey, $domainName ) {
|
34 |
assert( ! empty( $apiKey ) );
|
Postman/Postman-Mail/PostmanMailgunTransport.php
CHANGED
@@ -16,7 +16,7 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements
|
|
16 |
|
17 |
/**
|
18 |
*
|
19 |
-
* @param
|
20 |
*/
|
21 |
public function __construct( $rootPluginFilenameAndPath ) {
|
22 |
parent::__construct( $rootPluginFilenameAndPath );
|
@@ -36,7 +36,7 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements
|
|
36 |
return self::SLUG;
|
37 |
}
|
38 |
public function getName() {
|
39 |
-
return __( 'Mailgun API',
|
40 |
}
|
41 |
/**
|
42 |
* v0.2.1
|
@@ -49,7 +49,7 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements
|
|
49 |
/**
|
50 |
* v0.2.1
|
51 |
*
|
52 |
-
* @return
|
53 |
*/
|
54 |
public function getPort() {
|
55 |
return self::PORT;
|
@@ -78,12 +78,12 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements
|
|
78 |
}
|
79 |
public function getDeliveryDetails() {
|
80 |
/* translators: where (1) is the secure icon and (2) is the transport name */
|
81 |
-
return sprintf( __( 'Post SMTP will send mail via the <b>%1$s %2$s</b>.',
|
82 |
}
|
83 |
|
84 |
/**
|
85 |
*
|
86 |
-
* @param
|
87 |
*/
|
88 |
public function prepareOptionsForExport( $data ) {
|
89 |
$data = parent::prepareOptionsForExport( $data );
|
@@ -102,17 +102,17 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements
|
|
102 |
$domainName = $this->options->getMailgunDomainName();
|
103 |
|
104 |
if ( empty( $apiKey ) ) {
|
105 |
-
array_push( $messages, __( 'API Key can not be empty',
|
106 |
$this->setNotConfiguredAndReady();
|
107 |
}
|
108 |
|
109 |
if ( empty( $domainName ) ) {
|
110 |
-
array_push( $messages, __( 'Domain Name can not be empty',
|
111 |
$this->setNotConfiguredAndReady();
|
112 |
}
|
113 |
|
114 |
if ( ! $this->isSenderConfigured() ) {
|
115 |
-
array_push( $messages, __( 'Message From Address can not be empty',
|
116 |
$this->setNotConfiguredAndReady();
|
117 |
}
|
118 |
return $messages;
|
@@ -139,8 +139,8 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements
|
|
139 |
|
140 |
/**
|
141 |
*
|
142 |
-
* @param
|
143 |
-
* @param
|
144 |
*/
|
145 |
public function populateConfiguration( $hostname ) {
|
146 |
$response = parent::populateConfiguration( $hostname );
|
@@ -155,7 +155,7 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements
|
|
155 |
$overrideItem ['auth_items'] = array(
|
156 |
array(
|
157 |
'selected' => true,
|
158 |
-
'name' => __( 'API Key',
|
159 |
'value' => 'api_key',
|
160 |
),
|
161 |
);
|
@@ -184,40 +184,40 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements
|
|
184 |
*/
|
185 |
public function addSettings() {
|
186 |
// the Mailgun Auth section
|
187 |
-
add_settings_section( PostmanMailgunTransport::MAILGUN_AUTH_SECTION, __( 'Authentication',
|
188 |
$this,
|
189 |
'printMailgunAuthSectionInfo',
|
190 |
), PostmanMailgunTransport::MAILGUN_AUTH_OPTIONS );
|
191 |
|
192 |
-
add_settings_field( PostmanOptions::MAILGUN_API_KEY, __( 'API Key',
|
193 |
$this,
|
194 |
'mailgun_api_key_callback',
|
195 |
), PostmanMailgunTransport::MAILGUN_AUTH_OPTIONS, PostmanMailgunTransport::MAILGUN_AUTH_SECTION );
|
196 |
|
197 |
-
add_settings_field( PostmanOptions::MAILGUN_DOMAIN_NAME, __( 'Domain Name',
|
198 |
$this,
|
199 |
'mailgun_domain_name_callback',
|
200 |
), PostmanMailgunTransport::MAILGUN_AUTH_OPTIONS, PostmanMailgunTransport::MAILGUN_AUTH_SECTION );
|
201 |
|
202 |
-
add_settings_field( PostmanOptions::MAILGUN_REGION, __( 'Mailgun Europe Region?',
|
203 |
$this,
|
204 |
'mailgun_region_callback',
|
205 |
), PostmanMailgunTransport::MAILGUN_AUTH_OPTIONS, PostmanMailgunTransport::MAILGUN_AUTH_SECTION );
|
206 |
}
|
207 |
public function printMailgunAuthSectionInfo() {
|
208 |
/* Translators: Where (1) is the service URL and (2) is the service name and (3) is a api key URL */
|
209 |
-
printf( '<p id="wizard_mailgun_auth_help">%s</p>', sprintf( __( 'Create an account at <a href="%1$s" target="_blank">%2$s</a> and enter <a href="%3$s" target="_blank">an API key</a> below.',
|
210 |
}
|
211 |
|
212 |
/**
|
213 |
*/
|
214 |
public function mailgun_api_key_callback() {
|
215 |
-
printf( '<input type="password" autocomplete="off" id="mailgun_api_key" name="postman_options[mailgun_api_key]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getMailgunApiKey() ? esc_attr( PostmanUtils::obfuscatePassword( $this->options->getMailgunApiKey() ) ) : '', __( 'Required',
|
216 |
print '<input type="button" id="toggleMailgunApiKey" value="Show Password" class="button button-secondary" style="visibility:hidden" />';
|
217 |
}
|
218 |
|
219 |
function mailgun_domain_name_callback() {
|
220 |
-
printf( '<input type="text" autocomplete="off" id="mailgun_domain_name" name="postman_options[mailgun_domain_name]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getMailgunDomainName() ? esc_attr( $this->options->getMailgunDomainName() ) : '', __( 'Required',
|
221 |
}
|
222 |
|
223 |
function mailgun_region_callback() {
|
@@ -248,14 +248,14 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements
|
|
248 |
public function printWizardAuthenticationStep() {
|
249 |
print '<section class="wizard_mailgun">';
|
250 |
$this->printMailgunAuthSectionInfo();
|
251 |
-
printf( '<label for="api_key">%s</label>', __( 'API Key',
|
252 |
print '<br />';
|
253 |
print $this->mailgun_api_key_callback();
|
254 |
-
printf( '<label for="domain_name">%s</label>', __( 'Domain Name',
|
255 |
print '<br />';
|
256 |
print $this->mailgun_domain_name_callback();
|
257 |
print '<br />';
|
258 |
-
printf( '<label for="mailgun_region">%s</label>', __( 'Mailgun Europe Region?',
|
259 |
print '<br />';
|
260 |
print $this->mailgun_region_callback();
|
261 |
print '</section>';
|
16 |
|
17 |
/**
|
18 |
*
|
19 |
+
* @param mixed $rootPluginFilenameAndPath
|
20 |
*/
|
21 |
public function __construct( $rootPluginFilenameAndPath ) {
|
22 |
parent::__construct( $rootPluginFilenameAndPath );
|
36 |
return self::SLUG;
|
37 |
}
|
38 |
public function getName() {
|
39 |
+
return __( 'Mailgun API', 'post-smtp' );
|
40 |
}
|
41 |
/**
|
42 |
* v0.2.1
|
49 |
/**
|
50 |
* v0.2.1
|
51 |
*
|
52 |
+
* @return int
|
53 |
*/
|
54 |
public function getPort() {
|
55 |
return self::PORT;
|
78 |
}
|
79 |
public function getDeliveryDetails() {
|
80 |
/* translators: where (1) is the secure icon and (2) is the transport name */
|
81 |
+
return sprintf( __( 'Post SMTP will send mail via the <b>%1$s %2$s</b>.', 'post-smtp' ), '🔐', $this->getName() );
|
82 |
}
|
83 |
|
84 |
/**
|
85 |
*
|
86 |
+
* @param mixed $data
|
87 |
*/
|
88 |
public function prepareOptionsForExport( $data ) {
|
89 |
$data = parent::prepareOptionsForExport( $data );
|
102 |
$domainName = $this->options->getMailgunDomainName();
|
103 |
|
104 |
if ( empty( $apiKey ) ) {
|
105 |
+
array_push( $messages, __( 'API Key can not be empty', 'post-smtp' ) . '.' );
|
106 |
$this->setNotConfiguredAndReady();
|
107 |
}
|
108 |
|
109 |
if ( empty( $domainName ) ) {
|
110 |
+
array_push( $messages, __( 'Domain Name can not be empty', 'post-smtp' ) . '.' );
|
111 |
$this->setNotConfiguredAndReady();
|
112 |
}
|
113 |
|
114 |
if ( ! $this->isSenderConfigured() ) {
|
115 |
+
array_push( $messages, __( 'Message From Address can not be empty', 'post-smtp' ) . '.' );
|
116 |
$this->setNotConfiguredAndReady();
|
117 |
}
|
118 |
return $messages;
|
139 |
|
140 |
/**
|
141 |
*
|
142 |
+
* @param mixed $hostname
|
143 |
+
* @param mixed $response
|
144 |
*/
|
145 |
public function populateConfiguration( $hostname ) {
|
146 |
$response = parent::populateConfiguration( $hostname );
|
155 |
$overrideItem ['auth_items'] = array(
|
156 |
array(
|
157 |
'selected' => true,
|
158 |
+
'name' => __( 'API Key', 'post-smtp' ),
|
159 |
'value' => 'api_key',
|
160 |
),
|
161 |
);
|
184 |
*/
|
185 |
public function addSettings() {
|
186 |
// the Mailgun Auth section
|
187 |
+
add_settings_section( PostmanMailgunTransport::MAILGUN_AUTH_SECTION, __( 'Authentication', 'post-smtp' ), array(
|
188 |
$this,
|
189 |
'printMailgunAuthSectionInfo',
|
190 |
), PostmanMailgunTransport::MAILGUN_AUTH_OPTIONS );
|
191 |
|
192 |
+
add_settings_field( PostmanOptions::MAILGUN_API_KEY, __( 'API Key', 'post-smtp' ), array(
|
193 |
$this,
|
194 |
'mailgun_api_key_callback',
|
195 |
), PostmanMailgunTransport::MAILGUN_AUTH_OPTIONS, PostmanMailgunTransport::MAILGUN_AUTH_SECTION );
|
196 |
|
197 |
+
add_settings_field( PostmanOptions::MAILGUN_DOMAIN_NAME, __( 'Domain Name', 'post-smtp' ), array(
|
198 |
$this,
|
199 |
'mailgun_domain_name_callback',
|
200 |
), PostmanMailgunTransport::MAILGUN_AUTH_OPTIONS, PostmanMailgunTransport::MAILGUN_AUTH_SECTION );
|
201 |
|
202 |
+
add_settings_field( PostmanOptions::MAILGUN_REGION, __( 'Mailgun Europe Region?', 'post-smtp' ), array(
|
203 |
$this,
|
204 |
'mailgun_region_callback',
|
205 |
), PostmanMailgunTransport::MAILGUN_AUTH_OPTIONS, PostmanMailgunTransport::MAILGUN_AUTH_SECTION );
|
206 |
}
|
207 |
public function printMailgunAuthSectionInfo() {
|
208 |
/* Translators: Where (1) is the service URL and (2) is the service name and (3) is a api key URL */
|
209 |
+
printf( '<p id="wizard_mailgun_auth_help">%s</p>', sprintf( __( 'Create an account at <a href="%1$s" target="_blank">%2$s</a> and enter <a href="%3$s" target="_blank">an API key</a> below.', 'post-smtp' ), 'https://mailgun.com', 'mailgun.com', 'https://app.mailgun.com/app/domains/' ) );
|
210 |
}
|
211 |
|
212 |
/**
|
213 |
*/
|
214 |
public function mailgun_api_key_callback() {
|
215 |
+
printf( '<input type="password" autocomplete="off" id="mailgun_api_key" name="postman_options[mailgun_api_key]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getMailgunApiKey() ? esc_attr( PostmanUtils::obfuscatePassword( $this->options->getMailgunApiKey() ) ) : '', __( 'Required', 'post-smtp' ) );
|
216 |
print '<input type="button" id="toggleMailgunApiKey" value="Show Password" class="button button-secondary" style="visibility:hidden" />';
|
217 |
}
|
218 |
|
219 |
function mailgun_domain_name_callback() {
|
220 |
+
printf( '<input type="text" autocomplete="off" id="mailgun_domain_name" name="postman_options[mailgun_domain_name]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getMailgunDomainName() ? esc_attr( $this->options->getMailgunDomainName() ) : '', __( 'Required', 'post-smtp' ) );
|
221 |
}
|
222 |
|
223 |
function mailgun_region_callback() {
|
248 |
public function printWizardAuthenticationStep() {
|
249 |
print '<section class="wizard_mailgun">';
|
250 |
$this->printMailgunAuthSectionInfo();
|
251 |
+
printf( '<label for="api_key">%s</label>', __( 'API Key', 'post-smtp' ) );
|
252 |
print '<br />';
|
253 |
print $this->mailgun_api_key_callback();
|
254 |
+
printf( '<label for="domain_name">%s</label>', __( 'Domain Name', 'post-smtp' ) );
|
255 |
print '<br />';
|
256 |
print $this->mailgun_domain_name_callback();
|
257 |
print '<br />';
|
258 |
+
printf( '<label for="mailgun_region">%s</label>', __( 'Mailgun Europe Region?', 'post-smtp' ) );
|
259 |
print '<br />';
|
260 |
print $this->mailgun_region_callback();
|
261 |
print '</section>';
|
Postman/Postman-Mail/PostmanMandrillMailEngine.php
CHANGED
@@ -22,8 +22,8 @@ if ( ! class_exists( 'PostmanMandrillMailEngine' ) ) {
|
|
22 |
|
23 |
/**
|
24 |
*
|
25 |
-
* @param
|
26 |
-
* @param
|
27 |
*/
|
28 |
function __construct( $apiKey ) {
|
29 |
assert( ! empty( $apiKey ) );
|
22 |
|
23 |
/**
|
24 |
*
|
25 |
+
* @param mixed $senderEmail
|
26 |
+
* @param mixed $accessToken
|
27 |
*/
|
28 |
function __construct( $apiKey ) {
|
29 |
assert( ! empty( $apiKey ) );
|
Postman/Postman-Mail/PostmanMandrillTransport.php
CHANGED
@@ -25,7 +25,7 @@ class PostmanMandrillTransport extends PostmanAbstractModuleTransport implements
|
|
25 |
|
26 |
/**
|
27 |
*
|
28 |
-
* @param
|
29 |
*/
|
30 |
public function prepareOptionsForExport($data) {
|
31 |
$data = parent::prepareOptionsForExport ( $data );
|
@@ -41,7 +41,7 @@ class PostmanMandrillTransport extends PostmanAbstractModuleTransport implements
|
|
41 |
return self::SLUG;
|
42 |
}
|
43 |
public function getName() {
|
44 |
-
return __ ( 'Mandrill API',
|
45 |
}
|
46 |
/**
|
47 |
* v0.2.1
|
@@ -54,7 +54,7 @@ class PostmanMandrillTransport extends PostmanAbstractModuleTransport implements
|
|
54 |
/**
|
55 |
* v0.2.1
|
56 |
*
|
57 |
-
* @return
|
58 |
*/
|
59 |
public function getPort() {
|
60 |
return self::PORT;
|
@@ -132,7 +132,7 @@ class PostmanMandrillTransport extends PostmanAbstractModuleTransport implements
|
|
132 |
*/
|
133 |
public function getDeliveryDetails() {
|
134 |
/* translators: where (1) is the secure icon and (2) is the transport name */
|
135 |
-
return sprintf ( __ ( 'Postman will send mail via the <b>%1$s %2$s</b>.',
|
136 |
}
|
137 |
|
138 |
/**
|
@@ -144,11 +144,11 @@ class PostmanMandrillTransport extends PostmanAbstractModuleTransport implements
|
|
144 |
$messages = parent::validateTransportConfiguration ();
|
145 |
$apiKey = $this->options->getMandrillApiKey ();
|
146 |
if (empty ( $apiKey )) {
|
147 |
-
array_push ( $messages, __ ( 'API Key can not be empty',
|
148 |
$this->setNotConfiguredAndReady ();
|
149 |
}
|
150 |
if (! $this->isSenderConfigured ()) {
|
151 |
-
array_push ( $messages, __ ( 'Message From Address can not be empty',
|
152 |
$this->setNotConfiguredAndReady ();
|
153 |
}
|
154 |
return $messages;
|
@@ -191,7 +191,7 @@ class PostmanMandrillTransport extends PostmanAbstractModuleTransport implements
|
|
191 |
$overrideItem ['auth_items'] = array (
|
192 |
array (
|
193 |
'selected' => true,
|
194 |
-
'name' => __ ( 'API Key',
|
195 |
'value' => 'api_key'
|
196 |
)
|
197 |
);
|
@@ -220,12 +220,12 @@ class PostmanMandrillTransport extends PostmanAbstractModuleTransport implements
|
|
220 |
*/
|
221 |
public function addSettings() {
|
222 |
// the Mandrill Auth section
|
223 |
-
add_settings_section ( PostmanMandrillTransport::MANDRILL_AUTH_SECTION, __ ( 'Authentication',
|
224 |
$this,
|
225 |
'printMandrillAuthSectionInfo'
|
226 |
), PostmanMandrillTransport::MANDRILL_AUTH_OPTIONS );
|
227 |
|
228 |
-
add_settings_field ( PostmanOptions::MANDRILL_API_KEY, __ ( 'API Key',
|
229 |
$this,
|
230 |
'mandrill_api_key_callback'
|
231 |
), PostmanMandrillTransport::MANDRILL_AUTH_OPTIONS, PostmanMandrillTransport::MANDRILL_AUTH_SECTION );
|
@@ -235,13 +235,13 @@ class PostmanMandrillTransport extends PostmanAbstractModuleTransport implements
|
|
235 |
*/
|
236 |
public function printMandrillAuthSectionInfo() {
|
237 |
/* Translators: Where (1) is the service URL and (2) is the service name and (3) is a api key URL */
|
238 |
-
printf ( '<p id="wizard_mandrill_auth_help">%s</p>', sprintf ( __ ( 'Create an account at <a href="%1$s" target="_blank">%2$s</a> and enter <a href="%3$s" target="_blank">an API key</a> below.',
|
239 |
}
|
240 |
|
241 |
/**
|
242 |
*/
|
243 |
public function mandrill_api_key_callback() {
|
244 |
-
printf ( '<input type="password" autocomplete="off" id="mandrill_api_key" name="postman_options[mandrill_api_key]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getMandrillApiKey () ? esc_attr ( PostmanUtils::obfuscatePassword ( $this->options->getMandrillApiKey () ) ) : '', __ ( 'Required',
|
245 |
print ' <input type="button" id="toggleMandrillApiKey" value="Show Password" class="button button-secondary" style="visibility:hidden" />';
|
246 |
}
|
247 |
|
@@ -268,7 +268,7 @@ class PostmanMandrillTransport extends PostmanAbstractModuleTransport implements
|
|
268 |
public function printWizardAuthenticationStep() {
|
269 |
print '<section class="wizard_mandrill">';
|
270 |
$this->printMandrillAuthSectionInfo ();
|
271 |
-
printf ( '<label for="api_key">%s</label>', __ ( 'API Key',
|
272 |
print '<br />';
|
273 |
print $this->mandrill_api_key_callback ();
|
274 |
print '</section>';
|
25 |
|
26 |
/**
|
27 |
*
|
28 |
+
* @param mixed $data
|
29 |
*/
|
30 |
public function prepareOptionsForExport($data) {
|
31 |
$data = parent::prepareOptionsForExport ( $data );
|
41 |
return self::SLUG;
|
42 |
}
|
43 |
public function getName() {
|
44 |
+
return __ ( 'Mandrill API', 'post-smtp' );
|
45 |
}
|
46 |
/**
|
47 |
* v0.2.1
|
54 |
/**
|
55 |
* v0.2.1
|
56 |
*
|
57 |
+
* @return int
|
58 |
*/
|
59 |
public function getPort() {
|
60 |
return self::PORT;
|
132 |
*/
|
133 |
public function getDeliveryDetails() {
|
134 |
/* translators: where (1) is the secure icon and (2) is the transport name */
|
135 |
+
return sprintf ( __ ( 'Postman will send mail via the <b>%1$s %2$s</b>.', 'post-smtp' ), '🔐', $this->getName () );
|
136 |
}
|
137 |
|
138 |
/**
|
144 |
$messages = parent::validateTransportConfiguration ();
|
145 |
$apiKey = $this->options->getMandrillApiKey ();
|
146 |
if (empty ( $apiKey )) {
|
147 |
+
array_push ( $messages, __ ( 'API Key can not be empty', 'post-smtp' ) . '.' );
|
148 |
$this->setNotConfiguredAndReady ();
|
149 |
}
|
150 |
if (! $this->isSenderConfigured ()) {
|
151 |
+
array_push ( $messages, __ ( 'Message From Address can not be empty', 'post-smtp' ) . '.' );
|
152 |
$this->setNotConfiguredAndReady ();
|
153 |
}
|
154 |
return $messages;
|
191 |
$overrideItem ['auth_items'] = array (
|
192 |
array (
|
193 |
'selected' => true,
|
194 |
+
'name' => __ ( 'API Key', 'post-smtp' ),
|
195 |
'value' => 'api_key'
|
196 |
)
|
197 |
);
|
220 |
*/
|
221 |
public function addSettings() {
|
222 |
// the Mandrill Auth section
|
223 |
+
add_settings_section ( PostmanMandrillTransport::MANDRILL_AUTH_SECTION, __ ( 'Authentication', 'post-smtp' ), array (
|
224 |
$this,
|
225 |
'printMandrillAuthSectionInfo'
|
226 |
), PostmanMandrillTransport::MANDRILL_AUTH_OPTIONS );
|
227 |
|
228 |
+
add_settings_field ( PostmanOptions::MANDRILL_API_KEY, __ ( 'API Key', 'post-smtp' ), array (
|
229 |
$this,
|
230 |
'mandrill_api_key_callback'
|
231 |
), PostmanMandrillTransport::MANDRILL_AUTH_OPTIONS, PostmanMandrillTransport::MANDRILL_AUTH_SECTION );
|
235 |
*/
|
236 |
public function printMandrillAuthSectionInfo() {
|
237 |
/* Translators: Where (1) is the service URL and (2) is the service name and (3) is a api key URL */
|
238 |
+
printf ( '<p id="wizard_mandrill_auth_help">%s</p>', sprintf ( __ ( 'Create an account at <a href="%1$s" target="_blank">%2$s</a> and enter <a href="%3$s" target="_blank">an API key</a> below.', 'post-smtp' ), 'https://mandrillapp.com', 'Mandrillapp.com', 'https://mandrillapp.com/settings' ) );
|
239 |
}
|
240 |
|
241 |
/**
|
242 |
*/
|
243 |
public function mandrill_api_key_callback() {
|
244 |
+
printf ( '<input type="password" autocomplete="off" id="mandrill_api_key" name="postman_options[mandrill_api_key]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getMandrillApiKey () ? esc_attr ( PostmanUtils::obfuscatePassword ( $this->options->getMandrillApiKey () ) ) : '', __ ( 'Required', 'post-smtp' ) );
|
245 |
print ' <input type="button" id="toggleMandrillApiKey" value="Show Password" class="button button-secondary" style="visibility:hidden" />';
|
246 |
}
|
247 |
|
268 |
public function printWizardAuthenticationStep() {
|
269 |
print '<section class="wizard_mandrill">';
|
270 |
$this->printMandrillAuthSectionInfo ();
|
271 |
+
printf ( '<label for="api_key">%s</label>', __ ( 'API Key', 'post-smtp' ) );
|
272 |
print '<br />';
|
273 |
print $this->mandrill_api_key_callback ();
|
274 |
print '</section>';
|
Postman/Postman-Mail/PostmanMessage.php
CHANGED
@@ -52,7 +52,7 @@ if ( ! class_exists( 'PostmanMessage' ) ) {
|
|
52 |
}
|
53 |
|
54 |
function __get( $name ) {
|
55 |
-
$message = __( '<code>%1$s</code> property of a <code>PostmanMessage</code> object is <strong>not supported</strong>. For now all of this class properties are private.',
|
56 |
|
57 |
if ( WP_DEBUG ) {
|
58 |
trigger_error( sprintf( $message, $name ) );
|
@@ -63,7 +63,7 @@ if ( ! class_exists( 'PostmanMessage' ) ) {
|
|
63 |
$class = new ReflectionClass(__CLASS__);
|
64 |
$methods = $class->getMethods(ReflectionMethod::IS_PUBLIC );
|
65 |
|
66 |
-
$message = __( '<code>%1$s</code> method of a <code>PostmanMessage</code> object is <strong>not supported</strong>. Use one of the following methods <pre><code>%2$s</code></pre>',
|
67 |
|
68 |
if ( WP_DEBUG ) {
|
69 |
trigger_error( sprintf( $message, $name, print_r( $methods, true ) ) );
|
@@ -291,7 +291,7 @@ if ( ! class_exists( 'PostmanMessage' ) ) {
|
|
291 |
/**
|
292 |
* Set the charset
|
293 |
*
|
294 |
-
* @param
|
295 |
*/
|
296 |
public function setCharset( $charset ) {
|
297 |
$this->charset = $charset;
|
@@ -310,7 +310,7 @@ if ( ! class_exists( 'PostmanMessage' ) ) {
|
|
310 |
}
|
311 |
/**
|
312 |
*
|
313 |
-
* @param
|
314 |
* Array or comma-separated list of email addresses to send message.
|
315 |
* @throws Exception
|
316 |
*/
|
@@ -319,7 +319,7 @@ if ( ! class_exists( 'PostmanMessage' ) ) {
|
|
319 |
}
|
320 |
/**
|
321 |
*
|
322 |
-
* @param
|
323 |
* Array or comma-separated list of email addresses to send message.
|
324 |
* @throws Exception
|
325 |
*/
|
@@ -328,7 +328,7 @@ if ( ! class_exists( 'PostmanMessage' ) ) {
|
|
328 |
}
|
329 |
/**
|
330 |
*
|
331 |
-
* @param
|
332 |
* Array or comma-separated list of email addresses to send message.
|
333 |
* @throws Exception
|
334 |
*/
|
@@ -337,7 +337,7 @@ if ( ! class_exists( 'PostmanMessage' ) ) {
|
|
337 |
}
|
338 |
/**
|
339 |
*
|
340 |
-
* @param
|
341 |
* Array or comma-separated list of email addresses to send message.
|
342 |
* @throws Exception
|
343 |
*/
|
@@ -391,8 +391,8 @@ if ( ! class_exists( 'PostmanMessage' ) ) {
|
|
391 |
* Add the headers that were processed in processHeaders()
|
392 |
* Zend requires that several headers are specially handled.
|
393 |
*
|
394 |
-
* @param
|
395 |
-
* @param
|
396 |
* @param Postman_Zend_Mail $mail
|
397 |
*/
|
398 |
private function processHeader( $name, $content ) {
|
@@ -477,9 +477,9 @@ if ( ! class_exists( 'PostmanMessage' ) ) {
|
|
477 |
|
478 |
/**
|
479 |
*
|
480 |
-
* @param
|
481 |
-
* @param
|
482 |
-
* @param
|
483 |
*/
|
484 |
private function logProcessHeader( $desc, $name, $content ) {
|
485 |
$this->logger->debug( 'Processing ' . $desc . ' Header - ' . $name . ': ' . $content );
|
52 |
}
|
53 |
|
54 |
function __get( $name ) {
|
55 |
+
$message = __( '<code>%1$s</code> property of a <code>PostmanMessage</code> object is <strong>not supported</strong>. For now all of this class properties are private.', 'post-smtp' );
|
56 |
|
57 |
if ( WP_DEBUG ) {
|
58 |
trigger_error( sprintf( $message, $name ) );
|
63 |
$class = new ReflectionClass(__CLASS__);
|
64 |
$methods = $class->getMethods(ReflectionMethod::IS_PUBLIC );
|
65 |
|
66 |
+
$message = __( '<code>%1$s</code> method of a <code>PostmanMessage</code> object is <strong>not supported</strong>. Use one of the following methods <pre><code>%2$s</code></pre>', 'post-smtp' );
|
67 |
|
68 |
if ( WP_DEBUG ) {
|
69 |
trigger_error( sprintf( $message, $name, print_r( $methods, true ) ) );
|
291 |
/**
|
292 |
* Set the charset
|
293 |
*
|
294 |
+
* @param mixed $charset
|
295 |
*/
|
296 |
public function setCharset( $charset ) {
|
297 |
$this->charset = $charset;
|
310 |
}
|
311 |
/**
|
312 |
*
|
313 |
+
* @param mixed $recipients
|
314 |
* Array or comma-separated list of email addresses to send message.
|
315 |
* @throws Exception
|
316 |
*/
|
319 |
}
|
320 |
/**
|
321 |
*
|
322 |
+
* @param mixed $recipients
|
323 |
* Array or comma-separated list of email addresses to send message.
|
324 |
* @throws Exception
|
325 |
*/
|
328 |
}
|
329 |
/**
|
330 |
*
|
331 |
+
* @param mixed $recipients
|
332 |
* Array or comma-separated list of email addresses to send message.
|
333 |
* @throws Exception
|
334 |
*/
|
337 |
}
|
338 |
/**
|
339 |
*
|
340 |
+
* @param mixed $recipients
|
341 |
* Array or comma-separated list of email addresses to send message.
|
342 |
* @throws Exception
|
343 |
*/
|
391 |
* Add the headers that were processed in processHeaders()
|
392 |
* Zend requires that several headers are specially handled.
|
393 |
*
|
394 |
+
* @param mixed $name
|
395 |
+
* @param mixed $value
|
396 |
* @param Postman_Zend_Mail $mail
|
397 |
*/
|
398 |
private function processHeader( $name, $content ) {
|
477 |
|
478 |
/**
|
479 |
*
|
480 |
+
* @param mixed $desc
|
481 |
+
* @param mixed $name
|
482 |
+
* @param mixed $content
|
483 |
*/
|
484 |
private function logProcessHeader( $desc, $name, $content ) {
|
485 |
$this->logger->debug( 'Processing ' . $desc . ' Header - ' . $name . ': ' . $content );
|
Postman/Postman-Mail/PostmanModuleTransport.php
CHANGED
@@ -43,6 +43,7 @@ interface PostmanModuleTransport extends PostmanTransport {
|
|
43 |
public function isReadyToSendMail();
|
44 |
public function getFromEmailAddress();
|
45 |
public function getFromName();
|
|
|
46 |
public function getProtocol();
|
47 |
public function isEmailValidationSupported();
|
48 |
public function getPort();
|
@@ -68,7 +69,7 @@ abstract class PostmanAbstractModuleTransport implements PostmanModuleTransport
|
|
68 |
/**
|
69 |
* These internal variables are exposed for the subclasses to use
|
70 |
*
|
71 |
-
* @var
|
72 |
*/
|
73 |
protected $logger;
|
74 |
protected $options;
|
@@ -124,7 +125,7 @@ abstract class PostmanAbstractModuleTransport implements PostmanModuleTransport
|
|
124 |
|
125 |
/**
|
126 |
*
|
127 |
-
* @param
|
128 |
*/
|
129 |
public function prepareOptionsForExport($data) {
|
130 |
// no-op
|
@@ -139,7 +140,7 @@ abstract class PostmanAbstractModuleTransport implements PostmanModuleTransport
|
|
139 |
|
140 |
/**
|
141 |
*
|
142 |
-
* @param
|
143 |
*/
|
144 |
protected function createScribe($hostname) {
|
145 |
$scribe = new PostmanNonOAuthScribe ( $hostname );
|
@@ -281,8 +282,8 @@ abstract class PostmanAbstractModuleTransport implements PostmanModuleTransport
|
|
281 |
|
282 |
/**
|
283 |
*
|
284 |
-
* @param
|
285 |
-
* @param
|
286 |
*/
|
287 |
public function populateConfiguration($hostname) {
|
288 |
$configuration = array ();
|
@@ -290,8 +291,8 @@ abstract class PostmanAbstractModuleTransport implements PostmanModuleTransport
|
|
290 |
}
|
291 |
/**
|
292 |
*
|
293 |
-
* @param
|
294 |
-
* @param
|
295 |
*/
|
296 |
public function populateConfigurationFromRecommendation($winningRecommendation) {
|
297 |
$configuration = array ();
|
@@ -421,7 +422,7 @@ abstract class PostmanAbstractZendModuleTransport extends PostmanAbstractModuleT
|
|
421 |
|
422 |
/**
|
423 |
*
|
424 |
-
* @param
|
425 |
*/
|
426 |
public function prepareOptionsForExport($data) {
|
427 |
$data = parent::prepareOptionsForExport ( $data );
|
@@ -455,7 +456,7 @@ abstract class PostmanAbstractZendModuleTransport extends PostmanAbstractModuleT
|
|
455 |
|
456 |
/**
|
457 |
*
|
458 |
-
* @param
|
459 |
*/
|
460 |
protected function createScribe($hostname) {
|
461 |
$scribe = null;
|
@@ -503,12 +504,12 @@ abstract class PostmanAbstractZendModuleTransport extends PostmanAbstractModuleT
|
|
503 |
$deliveryDetails ['host'] = $this->getHostname () . ':' . $this->getPort ();
|
504 |
$deliveryDetails ['auth_desc'] = $this->getAuthenticationDescription ( $this->getAuthenticationType () );
|
505 |
/* translators: where (1) is the transport type, (2) is the host, and (3) is the Authentication Type (e.g. Postman will send mail via smtp.gmail.com:465 using OAuth 2.0 authentication.) */
|
506 |
-
return sprintf ( __ ( 'Postman will send mail via %1$s to %2$s using %3$s authentication.',
|
507 |
}
|
508 |
|
509 |
/**
|
510 |
*
|
511 |
-
* @param
|
512 |
* @return string
|
513 |
*/
|
514 |
protected function getTransportDescription($encType) {
|
@@ -525,13 +526,13 @@ abstract class PostmanAbstractZendModuleTransport extends PostmanAbstractModuleT
|
|
525 |
|
526 |
/**
|
527 |
*
|
528 |
-
* @param
|
529 |
*/
|
530 |
protected function getAuthenticationDescription($authType) {
|
531 |
if (PostmanOptions::AUTHENTICATION_TYPE_OAUTH2 == $authType) {
|
532 |
return 'OAuth 2.0';
|
533 |
} else if (PostmanOptions::AUTHENTICATION_TYPE_NONE == $authType) {
|
534 |
-
return _x ( 'no', 'as in "There is no Spoon"',
|
535 |
} else {
|
536 |
switch ($authType) {
|
537 |
case PostmanOptions::AUTHENTICATION_TYPE_CRAMMD5 :
|
@@ -550,7 +551,7 @@ abstract class PostmanAbstractZendModuleTransport extends PostmanAbstractModuleT
|
|
550 |
$authDescription = $authType;
|
551 |
break;
|
552 |
}
|
553 |
-
return sprintf ( '%s (%s)', __ ( 'Password',
|
554 |
}
|
555 |
}
|
556 |
|
@@ -575,13 +576,13 @@ abstract class PostmanAbstractZendModuleTransport extends PostmanAbstractModuleT
|
|
575 |
parent::validateTransportConfiguration ();
|
576 |
$messages = parent::validateTransportConfiguration ();
|
577 |
if (! $this->isSenderConfigured ()) {
|
578 |
-
array_push ( $messages, __ ( 'Message From Address can not be empty',
|
579 |
$this->setNotConfiguredAndReady ();
|
580 |
}
|
581 |
if ($this->getAuthenticationType () == PostmanOptions::AUTHENTICATION_TYPE_OAUTH2) {
|
582 |
if (! $this->isOAuth2ClientIdAndClientSecretConfigured ()) {
|
583 |
/* translators: %1$s is the Client ID label, and %2$s is the Client Secret label (e.g. Warning: OAuth 2.0 authentication requires an OAuth 2.0-capable Outgoing Mail Server, Sender Email Address, Client ID, and Client Secret.) */
|
584 |
-
array_push ( $messages, sprintf ( __ ( 'OAuth 2.0 authentication requires a %1$s and %2$s.',
|
585 |
$this->setNotConfiguredAndReady ();
|
586 |
}
|
587 |
}
|
@@ -621,8 +622,8 @@ abstract class PostmanAbstractZendModuleTransport extends PostmanAbstractModuleT
|
|
621 |
|
622 |
/**
|
623 |
*
|
624 |
-
* @param
|
625 |
-
* @param
|
626 |
*/
|
627 |
public function populateConfiguration($hostname) {
|
628 |
$response = parent::populateConfiguration ( $hostname );
|
@@ -650,8 +651,8 @@ abstract class PostmanAbstractZendModuleTransport extends PostmanAbstractModuleT
|
|
650 |
/**
|
651 |
* Populate the Ajax response for the Setup Wizard / Manual Configuration
|
652 |
*
|
653 |
-
* @param
|
654 |
-
* @param
|
655 |
*/
|
656 |
public function populateConfigurationFromRecommendation($winningRecommendation) {
|
657 |
$response = parent::populateConfigurationFromRecommendation ( $winningRecommendation );
|
@@ -703,21 +704,21 @@ abstract class PostmanAbstractZendModuleTransport extends PostmanAbstractModuleT
|
|
703 |
if ($socket->auth_crammd5 || $socket->auth_login || $socket->authPlain) {
|
704 |
array_push ( $overrideAuthItems, array (
|
705 |
'selected' => $passwordMode,
|
706 |
-
'name' => __ ( 'Password (requires username and password)',
|
707 |
'value' => 'password'
|
708 |
) );
|
709 |
}
|
710 |
if ($socket->auth_xoauth || $winningRecommendation ['auth'] == 'oauth2') {
|
711 |
array_push ( $overrideAuthItems, array (
|
712 |
'selected' => $oauth2Mode,
|
713 |
-
'name' => __ ( 'OAuth 2.0 (requires Client ID and Client Secret)',
|
714 |
'value' => 'oauth2'
|
715 |
) );
|
716 |
}
|
717 |
if ($socket->auth_none) {
|
718 |
array_push ( $overrideAuthItems, array (
|
719 |
'selected' => $noAuthMode,
|
720 |
-
'name' => __ ( 'None',
|
721 |
'value' => 'none'
|
722 |
) );
|
723 |
}
|
43 |
public function isReadyToSendMail();
|
44 |
public function getFromEmailAddress();
|
45 |
public function getFromName();
|
46 |
+
public function getHostname();
|
47 |
public function getProtocol();
|
48 |
public function isEmailValidationSupported();
|
49 |
public function getPort();
|
69 |
/**
|
70 |
* These internal variables are exposed for the subclasses to use
|
71 |
*
|
72 |
+
* @var mixed
|
73 |
*/
|
74 |
protected $logger;
|
75 |
protected $options;
|
125 |
|
126 |
/**
|
127 |
*
|
128 |
+
* @param mixed $data
|
129 |
*/
|
130 |
public function prepareOptionsForExport($data) {
|
131 |
// no-op
|
140 |
|
141 |
/**
|
142 |
*
|
143 |
+
* @param mixed $queryHostname
|
144 |
*/
|
145 |
protected function createScribe($hostname) {
|
146 |
$scribe = new PostmanNonOAuthScribe ( $hostname );
|
282 |
|
283 |
/**
|
284 |
*
|
285 |
+
* @param mixed $hostname
|
286 |
+
* @param mixed $response
|
287 |
*/
|
288 |
public function populateConfiguration($hostname) {
|
289 |
$configuration = array ();
|
291 |
}
|
292 |
/**
|
293 |
*
|
294 |
+
* @param mixed $winningRecommendation
|
295 |
+
* @param mixed $response
|
296 |
*/
|
297 |
public function populateConfigurationFromRecommendation($winningRecommendation) {
|
298 |
$configuration = array ();
|
422 |
|
423 |
/**
|
424 |
*
|
425 |
+
* @param mixed $data
|
426 |
*/
|
427 |
public function prepareOptionsForExport($data) {
|
428 |
$data = parent::prepareOptionsForExport ( $data );
|
456 |
|
457 |
/**
|
458 |
*
|
459 |
+
* @param mixed $queryHostname
|
460 |
*/
|
461 |
protected function createScribe($hostname) {
|
462 |
$scribe = null;
|
504 |
$deliveryDetails ['host'] = $this->getHostname () . ':' . $this->getPort ();
|
505 |
$deliveryDetails ['auth_desc'] = $this->getAuthenticationDescription ( $this->getAuthenticationType () );
|
506 |
/* translators: where (1) is the transport type, (2) is the host, and (3) is the Authentication Type (e.g. Postman will send mail via smtp.gmail.com:465 using OAuth 2.0 authentication.) */
|
507 |
+
return sprintf ( __ ( 'Postman will send mail via %1$s to %2$s using %3$s authentication.', 'post-smtp' ), '<b>' . $deliveryDetails ['transport_name'] . '</b>', '<b>' . $deliveryDetails ['host'] . '</b>', '<b>' . $deliveryDetails ['auth_desc'] . '</b>' );
|
508 |
}
|
509 |
|
510 |
/**
|
511 |
*
|
512 |
+
* @param mixed $encType
|
513 |
* @return string
|
514 |
*/
|
515 |
protected function getTransportDescription($encType) {
|
526 |
|
527 |
/**
|
528 |
*
|
529 |
+
* @param mixed $authType
|
530 |
*/
|
531 |
protected function getAuthenticationDescription($authType) {
|
532 |
if (PostmanOptions::AUTHENTICATION_TYPE_OAUTH2 == $authType) {
|
533 |
return 'OAuth 2.0';
|
534 |
} else if (PostmanOptions::AUTHENTICATION_TYPE_NONE == $authType) {
|
535 |
+
return _x ( 'no', 'as in "There is no Spoon"', 'post-smtp' );
|
536 |
} else {
|
537 |
switch ($authType) {
|
538 |
case PostmanOptions::AUTHENTICATION_TYPE_CRAMMD5 :
|
551 |
$authDescription = $authType;
|
552 |
break;
|
553 |
}
|
554 |
+
return sprintf ( '%s (%s)', __ ( 'Password', 'post-smtp' ), $authDescription );
|
555 |
}
|
556 |
}
|
557 |
|
576 |
parent::validateTransportConfiguration ();
|
577 |
$messages = parent::validateTransportConfiguration ();
|
578 |
if (! $this->isSenderConfigured ()) {
|
579 |
+
array_push ( $messages, __ ( 'Message From Address can not be empty', 'post-smtp' ) . '.' );
|
580 |
$this->setNotConfiguredAndReady ();
|
581 |
}
|
582 |
if ($this->getAuthenticationType () == PostmanOptions::AUTHENTICATION_TYPE_OAUTH2) {
|
583 |
if (! $this->isOAuth2ClientIdAndClientSecretConfigured ()) {
|
584 |
/* translators: %1$s is the Client ID label, and %2$s is the Client Secret label (e.g. Warning: OAuth 2.0 authentication requires an OAuth 2.0-capable Outgoing Mail Server, Sender Email Address, Client ID, and Client Secret.) */
|
585 |
+
array_push ( $messages, sprintf ( __ ( 'OAuth 2.0 authentication requires a %1$s and %2$s.', 'post-smtp' ), $this->getScribe ()->getClientIdLabel (), $this->getScribe ()->getClientSecretLabel () ) );
|
586 |
$this->setNotConfiguredAndReady ();
|
587 |
}
|
588 |
}
|
622 |
|
623 |
/**
|
624 |
*
|
625 |
+
* @param mixed $hostname
|
626 |
+
* @param mixed $response
|
627 |
*/
|
628 |
public function populateConfiguration($hostname) {
|
629 |
$response = parent::populateConfiguration ( $hostname );
|
651 |
/**
|
652 |
* Populate the Ajax response for the Setup Wizard / Manual Configuration
|
653 |
*
|
654 |
+
* @param mixed $hostname
|
655 |
+
* @param mixed $response
|
656 |
*/
|
657 |
public function populateConfigurationFromRecommendation($winningRecommendation) {
|
658 |
$response = parent::populateConfigurationFromRecommendation ( $winningRecommendation );
|
704 |
if ($socket->auth_crammd5 || $socket->auth_login || $socket->authPlain) {
|
705 |
array_push ( $overrideAuthItems, array (
|
706 |
'selected' => $passwordMode,
|
707 |
+
'name' => __ ( 'Password (requires username and password)', 'post-smtp' ),
|
708 |
'value' => 'password'
|
709 |
) );
|
710 |
}
|
711 |
if ($socket->auth_xoauth || $winningRecommendation ['auth'] == 'oauth2') {
|
712 |
array_push ( $overrideAuthItems, array (
|
713 |
'selected' => $oauth2Mode,
|
714 |
+
'name' => __ ( 'OAuth 2.0 (requires Client ID and Client Secret)', 'post-smtp' ),
|
715 |
'value' => 'oauth2'
|
716 |
) );
|
717 |
}
|
718 |
if ($socket->auth_none) {
|
719 |
array_push ( $overrideAuthItems, array (
|
720 |
'selected' => $noAuthMode,
|
721 |
+
'name' => __ ( 'None', 'post-smtp' ),
|
722 |
'value' => 'none'
|
723 |
) );
|
724 |
}
|
Postman/Postman-Mail/PostmanMyMailConnector.php
CHANGED
@@ -155,7 +155,6 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) {
|
|
155 |
*
|
156 |
* @access public
|
157 |
* @param mixed $message
|
158 |
-
* @return array
|
159 |
*/
|
160 |
public function reset() {
|
161 |
update_option( '_transient__mailster_send_period_timeout', false );
|
@@ -169,10 +168,10 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) {
|
|
169 |
*
|
170 |
* @access public
|
171 |
* @param mixed $delivery_methods
|
172 |
-
* @return
|
173 |
*/
|
174 |
public function delivery_method( $delivery_methods ) {
|
175 |
-
$delivery_methods [ MAILSTER_POSTMAN_ID ] = __( 'Postman SMTP',
|
176 |
return $delivery_methods;
|
177 |
}
|
178 |
|
@@ -196,7 +195,7 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) {
|
|
196 |
*/
|
197 |
public function activate() {
|
198 |
if ( defined( 'MAILSTER_VERSION' ) && version_compare( MAILSTER_POSTMAN_REQUIRED_VERSION, MAILSTER_VERSION, '<=' ) ) {
|
199 |
-
mailster_notice( sprintf( __( 'MyMail: Change the delivery method in the %s!',
|
200 |
$this->reset();
|
201 |
}
|
202 |
}
|
@@ -212,7 +211,7 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) {
|
|
212 |
if ( mailster_option( 'deliverymethod' ) == MAILSTER_POSTMAN_ID ) {
|
213 |
mailster_update_option( 'deliverymethod', 'simple' );
|
214 |
/* Translators where %s is the name of the page */
|
215 |
-
mailster_notice( sprintf( __( 'MyMail: Change the delivery method in the %s!',
|
216 |
}
|
217 |
}
|
218 |
}
|
155 |
*
|
156 |
* @access public
|
157 |
* @param mixed $message
|
|
|
158 |
*/
|
159 |
public function reset() {
|
160 |
update_option( '_transient__mailster_send_period_timeout', false );
|
168 |
*
|
169 |
* @access public
|
170 |
* @param mixed $delivery_methods
|
171 |
+
* @return mixed
|
172 |
*/
|
173 |
public function delivery_method( $delivery_methods ) {
|
174 |
+
$delivery_methods [ MAILSTER_POSTMAN_ID ] = __( 'Postman SMTP', 'post-smtp' );
|
175 |
return $delivery_methods;
|
176 |
}
|
177 |
|
195 |
*/
|
196 |
public function activate() {
|
197 |
if ( defined( 'MAILSTER_VERSION' ) && version_compare( MAILSTER_POSTMAN_REQUIRED_VERSION, MAILSTER_VERSION, '<=' ) ) {
|
198 |
+
mailster_notice( sprintf( __( 'MyMail: Change the delivery method in the %s!', 'post-smtp' ), sprintf( '<a href="edit.php?post_type=newsletter&page=mailster_settings&mailster_remove_notice=mailster_delivery_method#delivery">%s</a>', __( 'Settings', 'postman-smtp' ) ) ), '', false, 'delivery_method' );
|
199 |
$this->reset();
|
200 |
}
|
201 |
}
|
211 |
if ( mailster_option( 'deliverymethod' ) == MAILSTER_POSTMAN_ID ) {
|
212 |
mailster_update_option( 'deliverymethod', 'simple' );
|
213 |
/* Translators where %s is the name of the page */
|
214 |
+
mailster_notice( sprintf( __( 'MyMail: Change the delivery method in the %s!', 'post-smtp' ), sprintf( '<a href="edit.php?post_type=newsletter&page=mailster_settings&mailster_remove_notice=mailster_delivery_method#delivery">%s</a>', __( 'Settings', 'postman-smtp' ) ) ), '', false, 'delivery_method' );
|
215 |
}
|
216 |
}
|
217 |
}
|
Postman/Postman-Mail/PostmanSendGridMailEngine.php
CHANGED
@@ -22,8 +22,8 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
|
|
22 |
|
23 |
/**
|
24 |
*
|
25 |
-
* @param
|
26 |
-
* @param
|
27 |
*/
|
28 |
function __construct( $apiKey ) {
|
29 |
assert( ! empty( $apiKey ) );
|
@@ -41,86 +41,62 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
|
|
41 |
public function send( PostmanMessage $message ) {
|
42 |
$options = PostmanOptions::getInstance();
|
43 |
|
44 |
-
|
|
|
|
|
45 |
$sender = $message->getFromAddress();
|
46 |
|
47 |
$senderEmail = ! empty( $sender->getEmail() ) ? $sender->getEmail() : $options->getMessageSenderEmail();
|
48 |
$senderName = ! empty( $sender->getName() ) ? $sender->getName() : $options->getMessageSenderName();
|
49 |
|
50 |
-
|
51 |
|
52 |
-
|
53 |
$sender->log( $this->logger, 'From' );
|
54 |
|
55 |
-
|
56 |
-
$counter = 0;
|
57 |
-
$emails = array();
|
58 |
-
/**
|
59 |
-
* @todo: Find a better approch.
|
60 |
-
*/
|
61 |
-
$duplicates = array();
|
62 |
foreach ( ( array ) $message->getToRecipients() as $recipient ) {
|
63 |
-
|
64 |
-
|
65 |
-
$email = $recipient->getEmail();
|
66 |
-
if ( $counter == 0 ) {
|
67 |
-
$this->logger->debug( 'Adding to=' . $recipient->getEmail() );
|
68 |
-
$to = new SendGrid\Email($recipient->getName(), $recipient->getEmail() );
|
69 |
-
$duplicates[] = $email;
|
70 |
-
} else {
|
71 |
-
if ( ! in_array( $email, $duplicates ) ) {
|
72 |
-
$duplicates[] = $email;
|
73 |
-
$this->logger->debug( 'Adding personalization to=' . $recipient->getEmail() );
|
74 |
-
$emails[] = new SendGrid\Email($recipient->getName(), $recipient->getEmail() );
|
75 |
-
}
|
76 |
-
}
|
77 |
-
|
78 |
-
$counter++;
|
79 |
}
|
80 |
|
|
|
|
|
81 |
// add the subject
|
82 |
if ( null !== $message->getSubject() ) {
|
83 |
-
|
84 |
-
|
85 |
|
86 |
// add the message content
|
87 |
|
88 |
$textPart = $message->getBodyTextPart();
|
89 |
if ( ! empty( $textPart ) ) {
|
90 |
$this->logger->debug( 'Adding body as text' );
|
91 |
-
|
92 |
-
|
93 |
|
94 |
$htmlPart = $message->getBodyHtmlPart();
|
95 |
if ( ! empty( $htmlPart ) ) {
|
96 |
$this->logger->debug( 'Adding body as html' );
|
97 |
-
|
98 |
-
}
|
99 |
-
|
100 |
-
$mail = new SendGrid\Mail($from, $subject, $to, $content);
|
101 |
-
|
102 |
-
foreach ( $emails as $email) {
|
103 |
-
$mail->personalization[0]->addTo($email);
|
104 |
}
|
105 |
|
106 |
// add the reply-to
|
107 |
$replyTo = $message->getReplyTo();
|
108 |
// $replyTo is null or a PostmanEmailAddress object
|
109 |
if ( isset( $replyTo ) ) {
|
110 |
-
$
|
111 |
-
$mail->setReplyTo($reply_to);
|
112 |
}
|
113 |
|
114 |
// add the Postman signature - append it to whatever the user may have set
|
115 |
if ( ! $options->isStealthModeEnabled() ) {
|
116 |
$pluginData = apply_filters( 'postman_get_plugin_metadata', null );
|
117 |
-
|
118 |
}
|
119 |
|
120 |
// add the headers - see http://framework.zend.com/manual/1.12/en/zend.mail.additional-headers.html
|
121 |
foreach ( ( array ) $message->getHeaders() as $header ) {
|
122 |
$this->logger->debug( sprintf( 'Adding user header %s=%s', $header ['name'], $header ['content'] ) );
|
123 |
-
|
124 |
}
|
125 |
|
126 |
// if the caller set a Content-Type header, use it
|
@@ -130,28 +106,25 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
|
|
130 |
}
|
131 |
|
132 |
// add the cc recipients
|
|
|
133 |
foreach ( ( array ) $message->getCcRecipients() as $recipient ) {
|
134 |
-
|
135 |
-
|
136 |
-
$email = new SendGrid\Email( $recipient->getName(), $recipient->getEmail() );
|
137 |
-
$mail->personalization[0]->addCc( $email );
|
138 |
-
}
|
139 |
-
|
140 |
}
|
|
|
141 |
|
142 |
-
|
|
|
143 |
foreach ( ( array ) $message->getBccRecipients() as $recipient ) {
|
144 |
-
|
145 |
-
|
146 |
-
$email = new SendGrid\Email($recipient->getName(), $recipient->getEmail());
|
147 |
-
$mail->personalization[0]->addBcc($email);
|
148 |
-
}
|
149 |
}
|
|
|
150 |
|
151 |
-
|
152 |
$messageId = $message->getMessageId();
|
153 |
if ( ! empty( $messageId ) ) {
|
154 |
-
$
|
155 |
}
|
156 |
|
157 |
// add attachments
|
@@ -160,13 +133,13 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
|
|
160 |
$attachments = $this->addAttachmentsToMail( $message );
|
161 |
|
162 |
foreach ( $attachments as $index => $attachment ) {
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
}
|
171 |
|
172 |
try {
|
@@ -174,14 +147,14 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
|
|
174 |
if ( $this->logger->isDebug() ) {
|
175 |
$this->logger->debug( 'Creating SendGrid service with apiKey=' . $this->apiKey );
|
176 |
}
|
177 |
-
$sendgrid = new SendGrid( $this->apiKey );
|
178 |
|
179 |
// send the message
|
180 |
if ( $this->logger->isDebug() ) {
|
181 |
$this->logger->debug( 'Sending mail' );
|
182 |
}
|
183 |
|
184 |
-
$response = $sendgrid->
|
185 |
if ( $this->logger->isInfo() ) {
|
186 |
$this->logger->info( sprintf( 'Message %d accepted for delivery', PostmanState::getInstance()->getSuccessfulDeliveries() + 1 ) );
|
187 |
}
|
@@ -196,7 +169,7 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
|
|
196 |
$e = ! $email_sent ? $this->errorCodesMap($response_code) : $response_body->errors[0]->message;
|
197 |
$this->transcript = $e;
|
198 |
$this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS;
|
199 |
-
$this->transcript .= print_r( $
|
200 |
|
201 |
$this->logger->debug( 'Transcript=' . $this->transcript );
|
202 |
|
@@ -204,11 +177,11 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
|
|
204 |
}
|
205 |
$this->transcript = print_r( $response->body(), true );
|
206 |
$this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS;
|
207 |
-
$this->transcript .= print_r( $
|
208 |
} catch ( SendGrid\Exception $e ) {
|
209 |
$this->transcript = $e->getMessage();
|
210 |
$this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS;
|
211 |
-
$this->transcript .= print_r( $
|
212 |
$this->logger->debug( 'Transcript=' . $this->transcript );
|
213 |
|
214 |
throw $e;
|
@@ -219,22 +192,22 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
|
|
219 |
private function errorCodesMap($error_code) {
|
220 |
switch ($error_code) {
|
221 |
case 413:
|
222 |
-
$message = sprintf( __( 'ERROR: The JSON payload you have included in your request is too large. Status code is %1$s',
|
223 |
break;
|
224 |
case 429:
|
225 |
-
$message = sprintf( __( 'ERROR: The number of requests you have made exceeds SendGrid rate limitations. Status code is %1$s',
|
226 |
break;
|
227 |
case 500:
|
228 |
-
$message = sprintf( __( 'ERROR: An error occurred on a SendGrid server. Status code is %1$s',
|
229 |
break;
|
230 |
case 513:
|
231 |
-
$message = sprintf( __( 'ERROR: The SendGrid v3 Web API is not available. Status code is %1$s',
|
232 |
break;
|
233 |
case 502:
|
234 |
-
$message = sprintf( __( 'ERROR: No recipient supplied. Status code is %1$s',
|
235 |
break;
|
236 |
default:
|
237 |
-
$message = sprintf( __( 'ERROR: Status code is %1$s',
|
238 |
}
|
239 |
|
240 |
return $message;
|
22 |
|
23 |
/**
|
24 |
*
|
25 |
+
* @param mixed $senderEmail
|
26 |
+
* @param mixed $accessToken
|
27 |
*/
|
28 |
function __construct( $apiKey ) {
|
29 |
assert( ! empty( $apiKey ) );
|
41 |
public function send( PostmanMessage $message ) {
|
42 |
$options = PostmanOptions::getInstance();
|
43 |
|
44 |
+
$email = new \SendGrid\Mail\Mail();
|
45 |
+
|
46 |
+
// add the From Header
|
47 |
$sender = $message->getFromAddress();
|
48 |
|
49 |
$senderEmail = ! empty( $sender->getEmail() ) ? $sender->getEmail() : $options->getMessageSenderEmail();
|
50 |
$senderName = ! empty( $sender->getName() ) ? $sender->getName() : $options->getMessageSenderName();
|
51 |
|
52 |
+
$email->setFrom($senderEmail, $senderName);
|
53 |
|
54 |
+
// now log it
|
55 |
$sender->log( $this->logger, 'From' );
|
56 |
|
57 |
+
// add the to recipients
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
foreach ( ( array ) $message->getToRecipients() as $recipient ) {
|
59 |
+
$emails[] = new \SendGrid\Mail\To($recipient->getEmail(), $recipient->getName() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
}
|
61 |
|
62 |
+
$email->addTos( $emails );
|
63 |
+
|
64 |
// add the subject
|
65 |
if ( null !== $message->getSubject() ) {
|
66 |
+
$email->setSubject($message->getSubject());
|
67 |
+
}
|
68 |
|
69 |
// add the message content
|
70 |
|
71 |
$textPart = $message->getBodyTextPart();
|
72 |
if ( ! empty( $textPart ) ) {
|
73 |
$this->logger->debug( 'Adding body as text' );
|
74 |
+
$email->addContent("text/plain", $textPart);
|
75 |
+
}
|
76 |
|
77 |
$htmlPart = $message->getBodyHtmlPart();
|
78 |
if ( ! empty( $htmlPart ) ) {
|
79 |
$this->logger->debug( 'Adding body as html' );
|
80 |
+
$email->addContent("text/html", $htmlPart);
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
}
|
82 |
|
83 |
// add the reply-to
|
84 |
$replyTo = $message->getReplyTo();
|
85 |
// $replyTo is null or a PostmanEmailAddress object
|
86 |
if ( isset( $replyTo ) ) {
|
87 |
+
$email->setReplyTo( $replyTo->getEmail(), $replyTo->getName() );
|
|
|
88 |
}
|
89 |
|
90 |
// add the Postman signature - append it to whatever the user may have set
|
91 |
if ( ! $options->isStealthModeEnabled() ) {
|
92 |
$pluginData = apply_filters( 'postman_get_plugin_metadata', null );
|
93 |
+
$email->addHeader( 'X-Mailer', sprintf( 'Postman SMTP %s for WordPress (%s)', $pluginData ['version'], 'https://wordpress.org/plugins/post-smtp/' ) );
|
94 |
}
|
95 |
|
96 |
// add the headers - see http://framework.zend.com/manual/1.12/en/zend.mail.additional-headers.html
|
97 |
foreach ( ( array ) $message->getHeaders() as $header ) {
|
98 |
$this->logger->debug( sprintf( 'Adding user header %s=%s', $header ['name'], $header ['content'] ) );
|
99 |
+
$email->addHeader( $header ['name'], $header ['content'] );
|
100 |
}
|
101 |
|
102 |
// if the caller set a Content-Type header, use it
|
106 |
}
|
107 |
|
108 |
// add the cc recipients
|
109 |
+
$ccEmails = array();
|
110 |
foreach ( ( array ) $message->getCcRecipients() as $recipient ) {
|
111 |
+
$recipient->log( $this->logger, 'Cc' );
|
112 |
+
$ccEmails[] = new \SendGrid\Mail\Cc( $recipient->getEmail(), $recipient->getName() );
|
|
|
|
|
|
|
|
|
113 |
}
|
114 |
+
$email->addCcs($ccEmails);
|
115 |
|
116 |
+
// add the bcc recipients
|
117 |
+
$bccEmails = array();
|
118 |
foreach ( ( array ) $message->getBccRecipients() as $recipient ) {
|
119 |
+
$recipient->log($this->logger, 'Bcc');
|
120 |
+
$bccEmails[] = new \SendGrid\Mail\Cc( $recipient->getEmail(), $recipient->getName() );
|
|
|
|
|
|
|
121 |
}
|
122 |
+
$email->addBccs($bccEmails);
|
123 |
|
124 |
+
// add the messageId
|
125 |
$messageId = $message->getMessageId();
|
126 |
if ( ! empty( $messageId ) ) {
|
127 |
+
$email->addHeader( 'message-id', $messageId );
|
128 |
}
|
129 |
|
130 |
// add attachments
|
133 |
$attachments = $this->addAttachmentsToMail( $message );
|
134 |
|
135 |
foreach ( $attachments as $index => $attachment ) {
|
136 |
+
|
137 |
+
$email->addAttachment(
|
138 |
+
$attachment['content'],
|
139 |
+
$attachment['type'],
|
140 |
+
$attachment['file_name'],
|
141 |
+
"attachment"
|
142 |
+
);
|
143 |
}
|
144 |
|
145 |
try {
|
147 |
if ( $this->logger->isDebug() ) {
|
148 |
$this->logger->debug( 'Creating SendGrid service with apiKey=' . $this->apiKey );
|
149 |
}
|
150 |
+
$sendgrid = new \SendGrid( $this->apiKey );
|
151 |
|
152 |
// send the message
|
153 |
if ( $this->logger->isDebug() ) {
|
154 |
$this->logger->debug( 'Sending mail' );
|
155 |
}
|
156 |
|
157 |
+
$response = $sendgrid->send($email);
|
158 |
if ( $this->logger->isInfo() ) {
|
159 |
$this->logger->info( sprintf( 'Message %d accepted for delivery', PostmanState::getInstance()->getSuccessfulDeliveries() + 1 ) );
|
160 |
}
|
169 |
$e = ! $email_sent ? $this->errorCodesMap($response_code) : $response_body->errors[0]->message;
|
170 |
$this->transcript = $e;
|
171 |
$this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS;
|
172 |
+
$this->transcript .= print_r( $email, true );
|
173 |
|
174 |
$this->logger->debug( 'Transcript=' . $this->transcript );
|
175 |
|
177 |
}
|
178 |
$this->transcript = print_r( $response->body(), true );
|
179 |
$this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS;
|
180 |
+
$this->transcript .= print_r( $email, true );
|
181 |
} catch ( SendGrid\Exception $e ) {
|
182 |
$this->transcript = $e->getMessage();
|
183 |
$this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS;
|
184 |
+
$this->transcript .= print_r( $email, true );
|
185 |
$this->logger->debug( 'Transcript=' . $this->transcript );
|
186 |
|
187 |
throw $e;
|
192 |
private function errorCodesMap($error_code) {
|
193 |
switch ($error_code) {
|
194 |
case 413:
|
195 |
+
$message = sprintf( __( 'ERROR: The JSON payload you have included in your request is too large. Status code is %1$s', 'post-smtp' ), $error_code );
|
196 |
break;
|
197 |
case 429:
|
198 |
+
$message = sprintf( __( 'ERROR: The number of requests you have made exceeds SendGrid rate limitations. Status code is %1$s', 'post-smtp' ), $error_code );
|
199 |
break;
|
200 |
case 500:
|
201 |
+
$message = sprintf( __( 'ERROR: An error occurred on a SendGrid server. Status code is %1$s', 'post-smtp' ), $error_code );
|
202 |
break;
|
203 |
case 513:
|
204 |
+
$message = sprintf( __( 'ERROR: The SendGrid v3 Web API is not available. Status code is %1$s', 'post-smtp' ), $error_code );
|
205 |
break;
|
206 |
case 502:
|
207 |
+
$message = sprintf( __( 'ERROR: No recipient supplied. Status code is %1$s', 'post-smtp' ), $error_code );
|
208 |
break;
|
209 |
default:
|
210 |
+
$message = sprintf( __( 'ERROR: Status code is %1$s', 'post-smtp' ), $error_code );
|
211 |
}
|
212 |
|
213 |
return $message;
|
Postman/Postman-Mail/PostmanSendGridTransport.php
CHANGED
@@ -16,7 +16,7 @@ class PostmanSendGridTransport extends PostmanAbstractModuleTransport implements
|
|
16 |
|
17 |
/**
|
18 |
*
|
19 |
-
* @param
|
20 |
*/
|
21 |
public function __construct($rootPluginFilenameAndPath) {
|
22 |
parent::__construct ( $rootPluginFilenameAndPath );
|
@@ -36,7 +36,7 @@ class PostmanSendGridTransport extends PostmanAbstractModuleTransport implements
|
|
36 |
return self::SLUG;
|
37 |
}
|
38 |
public function getName() {
|
39 |
-
return __ ( 'SendGrid API',
|
40 |
}
|
41 |
/**
|
42 |
* v0.2.1
|
@@ -49,7 +49,7 @@ class PostmanSendGridTransport extends PostmanAbstractModuleTransport implements
|
|
49 |
/**
|
50 |
* v0.2.1
|
51 |
*
|
52 |
-
* @return
|
53 |
*/
|
54 |
public function getPort() {
|
55 |
return self::PORT;
|
@@ -76,12 +76,12 @@ class PostmanSendGridTransport extends PostmanAbstractModuleTransport implements
|
|
76 |
}
|
77 |
public function getDeliveryDetails() {
|
78 |
/* translators: where (1) is the secure icon and (2) is the transport name */
|
79 |
-
return sprintf ( __ ( 'Postman will send mail via the <b>%1$s %2$s</b>.',
|
80 |
}
|
81 |
|
82 |
/**
|
83 |
*
|
84 |
-
* @param
|
85 |
*/
|
86 |
public function prepareOptionsForExport($data) {
|
87 |
$data = parent::prepareOptionsForExport ( $data );
|
@@ -98,11 +98,11 @@ class PostmanSendGridTransport extends PostmanAbstractModuleTransport implements
|
|
98 |
$messages = parent::validateTransportConfiguration ();
|
99 |
$apiKey = $this->options->getSendGridApiKey ();
|
100 |
if (empty ( $apiKey )) {
|
101 |
-
array_push ( $messages, __ ( 'API Key can not be empty',
|
102 |
$this->setNotConfiguredAndReady ();
|
103 |
}
|
104 |
if (! $this->isSenderConfigured ()) {
|
105 |
-
array_push ( $messages, __ ( 'Message From Address can not be empty',
|
106 |
$this->setNotConfiguredAndReady ();
|
107 |
}
|
108 |
return $messages;
|
@@ -129,8 +129,8 @@ class PostmanSendGridTransport extends PostmanAbstractModuleTransport implements
|
|
129 |
|
130 |
/**
|
131 |
*
|
132 |
-
* @param
|
133 |
-
* @param
|
134 |
*/
|
135 |
public function populateConfiguration($hostname) {
|
136 |
$response = parent::populateConfiguration ( $hostname );
|
@@ -145,7 +145,7 @@ class PostmanSendGridTransport extends PostmanAbstractModuleTransport implements
|
|
145 |
$overrideItem ['auth_items'] = array (
|
146 |
array (
|
147 |
'selected' => true,
|
148 |
-
'name' => __ ( 'API Key',
|
149 |
'value' => 'api_key'
|
150 |
)
|
151 |
);
|
@@ -174,25 +174,25 @@ class PostmanSendGridTransport extends PostmanAbstractModuleTransport implements
|
|
174 |
*/
|
175 |
public function addSettings() {
|
176 |
// the SendGrid Auth section
|
177 |
-
add_settings_section ( PostmanSendGridTransport::SENDGRID_AUTH_SECTION, __ ( 'Authentication',
|
178 |
$this,
|
179 |
'printSendGridAuthSectionInfo'
|
180 |
), PostmanSendGridTransport::SENDGRID_AUTH_OPTIONS );
|
181 |
|
182 |
-
add_settings_field ( PostmanOptions::SENDGRID_API_KEY, __ ( 'API Key',
|
183 |
$this,
|
184 |
'sendgrid_api_key_callback'
|
185 |
), PostmanSendGridTransport::SENDGRID_AUTH_OPTIONS, PostmanSendGridTransport::SENDGRID_AUTH_SECTION );
|
186 |
}
|
187 |
public function printSendGridAuthSectionInfo() {
|
188 |
/* Translators: Where (1) is the service URL and (2) is the service name and (3) is a api key URL */
|
189 |
-
printf ( '<p id="wizard_sendgrid_auth_help">%s</p>', sprintf ( __ ( 'Create an account at <a href="%1$s" target="_blank">%2$s</a> and enter <a href="%3$s" target="_blank">an API key</a> below.',
|
190 |
}
|
191 |
|
192 |
/**
|
193 |
*/
|
194 |
public function sendgrid_api_key_callback() {
|
195 |
-
printf ( '<input type="password" autocomplete="off" id="sendgrid_api_key" name="postman_options[sendgrid_api_key]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getSendGridApiKey () ? esc_attr ( PostmanUtils::obfuscatePassword ( $this->options->getSendGridApiKey () ) ) : '', __ ( 'Required',
|
196 |
print ' <input type="button" id="toggleSendGridApiKey" value="Show Password" class="button button-secondary" style="visibility:hidden" />';
|
197 |
}
|
198 |
|
@@ -219,7 +219,7 @@ class PostmanSendGridTransport extends PostmanAbstractModuleTransport implements
|
|
219 |
public function printWizardAuthenticationStep() {
|
220 |
print '<section class="wizard_sendgrid">';
|
221 |
$this->printSendGridAuthSectionInfo ();
|
222 |
-
printf ( '<label for="api_key">%s</label>', __ ( 'API Key',
|
223 |
print '<br />';
|
224 |
print $this->sendgrid_api_key_callback ();
|
225 |
print '</section>';
|
16 |
|
17 |
/**
|
18 |
*
|
19 |
+
* @param mixed $rootPluginFilenameAndPath
|
20 |
*/
|
21 |
public function __construct($rootPluginFilenameAndPath) {
|
22 |
parent::__construct ( $rootPluginFilenameAndPath );
|
36 |
return self::SLUG;
|
37 |
}
|
38 |
public function getName() {
|
39 |
+
return __ ( 'SendGrid API', 'post-smtp' );
|
40 |
}
|
41 |
/**
|
42 |
* v0.2.1
|
49 |
/**
|
50 |
* v0.2.1
|
51 |
*
|
52 |
+
* @return int
|
53 |
*/
|
54 |
public function getPort() {
|
55 |
return self::PORT;
|
76 |
}
|
77 |
public function getDeliveryDetails() {
|
78 |
/* translators: where (1) is the secure icon and (2) is the transport name */
|
79 |
+
return sprintf ( __ ( 'Postman will send mail via the <b>%1$s %2$s</b>.', 'post-smtp' ), '🔐', $this->getName () );
|
80 |
}
|
81 |
|
82 |
/**
|
83 |
*
|
84 |
+
* @param mixed $data
|
85 |
*/
|
86 |
public function prepareOptionsForExport($data) {
|
87 |
$data = parent::prepareOptionsForExport ( $data );
|
98 |
$messages = parent::validateTransportConfiguration ();
|
99 |
$apiKey = $this->options->getSendGridApiKey ();
|
100 |
if (empty ( $apiKey )) {
|
101 |
+
array_push ( $messages, __ ( 'API Key can not be empty', 'post-smtp' ) . '.' );
|
102 |
$this->setNotConfiguredAndReady ();
|
103 |
}
|
104 |
if (! $this->isSenderConfigured ()) {
|
105 |
+
array_push ( $messages, __ ( 'Message From Address can not be empty', 'post-smtp' ) . '.' );
|
106 |
$this->setNotConfiguredAndReady ();
|
107 |
}
|
108 |
return $messages;
|
129 |
|
130 |
/**
|
131 |
*
|
132 |
+
* @param mixed $hostname
|
133 |
+
* @param mixed $response
|
134 |
*/
|
135 |
public function populateConfiguration($hostname) {
|
136 |
$response = parent::populateConfiguration ( $hostname );
|
145 |
$overrideItem ['auth_items'] = array (
|
146 |
array (
|
147 |
'selected' => true,
|
148 |
+
'name' => __ ( 'API Key', 'post-smtp' ),
|
149 |
'value' => 'api_key'
|
150 |
)
|
151 |
);
|
174 |
*/
|
175 |
public function addSettings() {
|
176 |
// the SendGrid Auth section
|
177 |
+
add_settings_section ( PostmanSendGridTransport::SENDGRID_AUTH_SECTION, __ ( 'Authentication', 'post-smtp' ), array (
|
178 |
$this,
|
179 |
'printSendGridAuthSectionInfo'
|
180 |
), PostmanSendGridTransport::SENDGRID_AUTH_OPTIONS );
|
181 |
|
182 |
+
add_settings_field ( PostmanOptions::SENDGRID_API_KEY, __ ( 'API Key', 'post-smtp' ), array (
|
183 |
$this,
|
184 |
'sendgrid_api_key_callback'
|
185 |
), PostmanSendGridTransport::SENDGRID_AUTH_OPTIONS, PostmanSendGridTransport::SENDGRID_AUTH_SECTION );
|
186 |
}
|
187 |
public function printSendGridAuthSectionInfo() {
|
188 |
/* Translators: Where (1) is the service URL and (2) is the service name and (3) is a api key URL */
|
189 |
+
printf ( '<p id="wizard_sendgrid_auth_help">%s</p>', sprintf ( __ ( 'Create an account at <a href="%1$s" target="_blank">%2$s</a> and enter <a href="%3$s" target="_blank">an API key</a> below.', 'post-smtp' ), 'https://sendgrid.com', 'SendGrid.com', 'https://app.sendgrid.com/settings/api_keys' ) );
|
190 |
}
|
191 |
|
192 |
/**
|
193 |
*/
|
194 |
public function sendgrid_api_key_callback() {
|
195 |
+
printf ( '<input type="password" autocomplete="off" id="sendgrid_api_key" name="postman_options[sendgrid_api_key]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getSendGridApiKey () ? esc_attr ( PostmanUtils::obfuscatePassword ( $this->options->getSendGridApiKey () ) ) : '', __ ( 'Required', 'post-smtp' ) );
|
196 |
print ' <input type="button" id="toggleSendGridApiKey" value="Show Password" class="button button-secondary" style="visibility:hidden" />';
|
197 |
}
|
198 |
|
219 |
public function printWizardAuthenticationStep() {
|
220 |
print '<section class="wizard_sendgrid">';
|
221 |
$this->printSendGridAuthSectionInfo ();
|
222 |
+
printf ( '<label for="api_key">%s</label>', __ ( 'API Key', 'post-smtp' ) );
|
223 |
print '<br />';
|
224 |
print $this->sendgrid_api_key_callback ();
|
225 |
print '</section>';
|
Postman/Postman-Mail/PostmanSmtpModuleTransport.php
CHANGED
@@ -91,21 +91,21 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl
|
|
91 |
protected function validateTransportConfiguration() {
|
92 |
$messages = parent::validateTransportConfiguration();
|
93 |
if ( ! $this->isHostConfigured( $this->options ) ) {
|
94 |
-
array_push( $messages, __( 'Outgoing Mail Server Hostname and Port can not be empty.',
|
95 |
$this->setNotConfiguredAndReady();
|
96 |
}
|
97 |
if ( ! $this->isEnvelopeFromConfigured() ) {
|
98 |
-
array_push( $messages, __( 'Envelope-From Email Address can not be empty',
|
99 |
$this->setNotConfiguredAndReady();
|
100 |
}
|
101 |
if ( $this->options->isAuthTypePassword() && ! $this->isPasswordAuthenticationConfigured( $this->options ) ) {
|
102 |
-
array_push( $messages, __( 'Username and password can not be empty.',
|
103 |
$this->setNotConfiguredAndReady();
|
104 |
}
|
105 |
if ( $this->getAuthenticationType() == PostmanOptions::AUTHENTICATION_TYPE_OAUTH2 ) {
|
106 |
if ( ! $this->isOAuth2SupportedHostConfigured() ) {
|
107 |
/* translators: %1$s is the Client ID label, and %2$s is the Client Secret label (e.g. Warning: OAuth 2.0 authentication requires an OAuth 2.0-capable Outgoing Mail Server, Sender Email Address, Client ID, and Client Secret.) */
|
108 |
-
array_push( $messages, sprintf( __( 'OAuth 2.0 authentication requires a supported OAuth 2.0-capable Outgoing Mail Server.',
|
109 |
$this->setNotConfiguredAndReady();
|
110 |
}
|
111 |
}
|
@@ -113,7 +113,7 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl
|
|
113 |
$this->setReadyForOAuthGrant();
|
114 |
if ( $this->isPermissionNeeded( $this->options, $this->getOAuthToken() ) ) {
|
115 |
/* translators: %1$s is the Client ID label, and %2$s is the Client Secret label */
|
116 |
-
$message = sprintf( __( 'You have configured OAuth 2.0 authentication, but have not received permission to use it.',
|
117 |
$message .= sprintf( ' <a href="%s">%s</a>.', PostmanUtils::getGrantOAuthPermissionUrl(), $this->getScribe()->getRequestPermissionLinkText() );
|
118 |
array_push( $messages, $message );
|
119 |
$this->setNotConfiguredAndReady();
|
@@ -160,7 +160,7 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl
|
|
160 |
/**
|
161 |
* SendGrid will never recommend it's configuration
|
162 |
*
|
163 |
-
* @param
|
164 |
*/
|
165 |
public function getConfigurationBid( PostmanWizardSocket $hostData, $userAuthOverride, $originalSmtpServer ) {
|
166 |
$port = $hostData->port;
|
@@ -265,7 +265,7 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl
|
|
265 |
$authDesc = $this->getAuthenticationDescription( $recommendation ['auth'] );
|
266 |
$recommendation ['label'] = sprintf( 'SMTP - %2$s:%3$d', $transportDescription, $hostData->hostnameDomainOnly, $port );
|
267 |
/* translators: where %1$s is a description of the transport (eg. SMTPS-SSL), %2$s is a description of the authentication (eg. Password-CRAMMD5), %3$d is the TCP port (eg. 465), %4$d is the hostname */
|
268 |
-
$recommendation ['message'] = sprintf( __( 'Postman recommends %1$s with %2$s authentication to host %4$s on port %3$d.',
|
269 |
}
|
270 |
|
271 |
// fill-in the rest of the recommendation
|
@@ -322,53 +322,53 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl
|
|
322 |
$oauthScribe = $transport->getScribe();
|
323 |
|
324 |
// Sanitize
|
325 |
-
add_settings_section( PostmanAdminController::SMTP_SECTION, __( 'Transport Settings',
|
326 |
$this,
|
327 |
'printSmtpSectionInfo',
|
328 |
), PostmanAdminController::SMTP_OPTIONS );
|
329 |
|
330 |
-
add_settings_field( PostmanOptions::HOSTNAME, __( 'Outgoing Mail Server Hostname',
|
331 |
$this,
|
332 |
'hostname_callback',
|
333 |
), PostmanAdminController::SMTP_OPTIONS, PostmanAdminController::SMTP_SECTION );
|
334 |
|
335 |
-
add_settings_field( PostmanOptions::PORT, __( 'Outgoing Mail Server Port',
|
336 |
$this,
|
337 |
'port_callback',
|
338 |
), PostmanAdminController::SMTP_OPTIONS, PostmanAdminController::SMTP_SECTION );
|
339 |
|
340 |
-
add_settings_field( PostmanOptions::ENVELOPE_SENDER, __( 'Envelope-From Email Address',
|
341 |
$this,
|
342 |
'sender_email_callback',
|
343 |
), PostmanAdminController::SMTP_OPTIONS, PostmanAdminController::SMTP_SECTION );
|
344 |
|
345 |
-
add_settings_field( PostmanOptions::SECURITY_TYPE, _x( 'Security', 'Configuration Input Field',
|
346 |
$this,
|
347 |
'encryption_type_callback',
|
348 |
), PostmanAdminController::SMTP_OPTIONS, PostmanAdminController::SMTP_SECTION );
|
349 |
|
350 |
-
add_settings_field( PostmanOptions::AUTHENTICATION_TYPE, __( 'Authentication',
|
351 |
$this,
|
352 |
'authentication_type_callback',
|
353 |
), PostmanAdminController::SMTP_OPTIONS, PostmanAdminController::SMTP_SECTION );
|
354 |
|
355 |
-
add_settings_section( PostmanAdminController::BASIC_AUTH_SECTION, __( 'Authentication',
|
356 |
$this,
|
357 |
'printBasicAuthSectionInfo',
|
358 |
), PostmanAdminController::BASIC_AUTH_OPTIONS );
|
359 |
|
360 |
-
add_settings_field( PostmanOptions::BASIC_AUTH_USERNAME, __( 'Username',
|
361 |
$this,
|
362 |
'basic_auth_username_callback',
|
363 |
), PostmanAdminController::BASIC_AUTH_OPTIONS, PostmanAdminController::BASIC_AUTH_SECTION );
|
364 |
|
365 |
-
add_settings_field( PostmanOptions::BASIC_AUTH_PASSWORD, __( 'Password',
|
366 |
$this,
|
367 |
'basic_auth_password_callback',
|
368 |
), PostmanAdminController::BASIC_AUTH_OPTIONS, PostmanAdminController::BASIC_AUTH_SECTION );
|
369 |
|
370 |
// the OAuth section
|
371 |
-
add_settings_section( PostmanAdminController::OAUTH_SECTION, __( 'Authentication',
|
372 |
$this,
|
373 |
'printOAuthSectionInfo',
|
374 |
), PostmanAdminController::OAUTH_AUTH_OPTIONS );
|
@@ -398,21 +398,21 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl
|
|
398 |
* Print the Section text
|
399 |
*/
|
400 |
public function printSmtpSectionInfo() {
|
401 |
-
print __( 'Configure the communication with the mail server.',
|
402 |
}
|
403 |
|
404 |
/**
|
405 |
* Get the settings option array and print one of its values
|
406 |
*/
|
407 |
public function hostname_callback() {
|
408 |
-
printf( '<input type="text" id="input_hostname" name="postman_options[hostname]" value="%s" size="40" class="required" placeholder="%s"/>', null !== $this->options->getHostname() ? esc_attr( $this->options->getHostname() ) : '', __( 'Required',
|
409 |
}
|
410 |
|
411 |
/**
|
412 |
* Get the settings option array and print one of its values
|
413 |
*/
|
414 |
public function port_callback( $args ) {
|
415 |
-
printf( '<input type="text" id="input_port" name="postman_options[port]" value="%s" %s placeholder="%s"/>', null !== $this->options->getPort() ? esc_attr( $this->options->getPort() ) : '', isset( $args ['style'] ) ? $args ['style'] : '', __( 'Required',
|
416 |
}
|
417 |
|
418 |
/**
|
@@ -421,7 +421,7 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl
|
|
421 |
public function encryption_type_callback() {
|
422 |
$encType = $this->options->getEncryptionType();
|
423 |
print '<select id="input_enc_type" class="input_encryption_type" name="postman_options[enc_type]">';
|
424 |
-
printf( '<option class="input_enc_type_none" value="%s" %s>%s</option>', PostmanOptions::SECURITY_TYPE_NONE, $encType == PostmanOptions::SECURITY_TYPE_NONE ? 'selected="selected"' : '', __( 'None',
|
425 |
printf( '<option class="input_enc_type_ssl" value="%s" %s>%s</option>', PostmanOptions::SECURITY_TYPE_SMTPS, $encType == PostmanOptions::SECURITY_TYPE_SMTPS ? 'selected="selected"' : '', 'SMTPS' );
|
426 |
printf( '<option class="input_enc_type_tls" value="%s" %s>%s</option>', PostmanOptions::SECURITY_TYPE_STARTTLS, $encType == PostmanOptions::SECURITY_TYPE_STARTTLS ? 'selected="selected"' : '', 'STARTTLS' );
|
427 |
print '</select>';
|
@@ -445,7 +445,7 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl
|
|
445 |
* Print the Section text
|
446 |
*/
|
447 |
public function printBasicAuthSectionInfo() {
|
448 |
-
print __( 'Enter the account credentials.',
|
449 |
}
|
450 |
|
451 |
/**
|
@@ -453,9 +453,9 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl
|
|
453 |
*/
|
454 |
public function basic_auth_username_callback() {
|
455 |
$inputValue = (null !== $this->options->getUsername() ? esc_attr( $this->options->getUsername() ) : '');
|
456 |
-
$inputDescription = __( 'The Username is usually the same as the Envelope-From Email Address.',
|
457 |
print ('<input tabindex="99" id="fake_user_name" name="fake_user[name]" style="position:absolute; top:-500px;" type="text" value="Safari Autofill Me">') ;
|
458 |
-
printf( '<input type="text" id="input_basic_auth_username" name="postman_options[basic_auth_username]" value="%s" size="40" class="required" placeholder="%s"/><br/><span class="postman_input_description">%s</span>', $inputValue, __( 'Required',
|
459 |
}
|
460 |
|
461 |
/**
|
@@ -463,7 +463,7 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl
|
|
463 |
*/
|
464 |
public function basic_auth_password_callback() {
|
465 |
print ('<input tabindex="99" id="fake_password" name="fake[password]" style="position:absolute; top:-500px;" type="password" value="Safari Autofill Me">') ;
|
466 |
-
printf( '<input type="password" id="input_basic_auth_password" name="postman_options[basic_auth_password]" value="%s" size="40" class="required" placeholder="%s"/>', null !== $this->options->getPassword() ? esc_attr( PostmanUtils::obfuscatePassword( $this->options->getPassword() ) ) : '', __( 'Required',
|
467 |
print ' <input type="button" id="togglePasswordField" value="Show Password" class="button button-secondary" style="visibility:hidden" />';
|
468 |
}
|
469 |
|
@@ -471,14 +471,14 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl
|
|
471 |
* Get the settings option array and print one of its values
|
472 |
*/
|
473 |
public function oauth_client_id_callback() {
|
474 |
-
printf( '<input type="text" onClick="this.setSelectionRange(0, this.value.length)" id="oauth_client_id" name="postman_options[oauth_client_id]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getClientId() ? esc_attr( $this->options->getClientId() ) : '', __( 'Required',
|
475 |
}
|
476 |
|
477 |
/**
|
478 |
* Get the settings option array and print one of its values
|
479 |
*/
|
480 |
public function oauth_client_secret_callback() {
|
481 |
-
printf( '<input type="text" onClick="this.setSelectionRange(0, this.value.length)" autocomplete="off" id="oauth_client_secret" name="postman_options[oauth_client_secret]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getClientSecret() ? esc_attr( $this->options->getClientSecret() ) : '', __( 'Required',
|
482 |
}
|
483 |
|
484 |
/**
|
@@ -507,7 +507,7 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl
|
|
507 |
$oauthScribe = $transport->getScribe();
|
508 |
return $oauthScribe->getCallbackDomain();
|
509 |
} catch ( Exception $e ) {
|
510 |
-
return __( 'Error computing your domain root - please enter it manually',
|
511 |
}
|
512 |
}
|
513 |
|
@@ -526,28 +526,28 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl
|
|
526 |
*/
|
527 |
public function sender_email_callback() {
|
528 |
$inputValue = (null !== $this->options->getEnvelopeSender() ? esc_attr( $this->options->getEnvelopeSender() ) : '');
|
529 |
-
$requiredLabel = __( 'Required',
|
530 |
-
$envelopeFromMessage = __( 'This address, like the <b>return address</b> printed on an envelope, identifies the account owner to the SMTP server.',
|
531 |
-
$spfMessage = sprintf( __( 'For reliable delivery, this domain must specify an <a target="_blank" href="%s">SPF record</a> permitting the use of the SMTP server named above.',
|
532 |
printf( '<input type="email" id="input_envelope_sender_email" name="postman_options[envelope_sender]" value="%s" size="40" class="required" placeholder="%s"/> <br/><span class="postman_input_description">%s %s</span>', $inputValue, $requiredLabel, $envelopeFromMessage, $spfMessage );
|
533 |
}
|
534 |
|
535 |
/**
|
536 |
*/
|
537 |
public function printWizardMailServerHostnameStep() {
|
538 |
-
printf( '<legend>%s</legend>', _x( 'Which host will relay the mail?', 'Wizard Step Title',
|
539 |
-
printf( '<p>%s</p>', __( 'This is the Outgoing (SMTP) Mail Server, or Mail Submission Agent (MSA), which Postman delegates mail delivery to. This server is specific to your email account, and if you don\'t know what to use, ask your email service provider.',
|
540 |
-
printf( '<p>%s</p>', __( 'Note that many WordPress hosts, such as GoDaddy, Bluehost and Dreamhost, require that you use their mail accounts with their mail servers, and prevent you from using others.',
|
541 |
-
printf( '<label for="hostname">%s</label>', __( 'Outgoing Mail Server Hostname',
|
542 |
print $this->hostname_callback();
|
543 |
printf( '<p class="ajax-loader" style="display:none"><img src="%s"/></p>', plugins_url( 'post-smtp/style/ajax-loader.gif' ) );
|
544 |
-
$warning = __( 'Warning',
|
545 |
/* Translators: Where (%s) is the name of the web host */
|
546 |
-
$nonGodaddyDomainMessage = sprintf( __( 'Your email address <b>requires</b> access to a remote SMTP server blocked by %s.',
|
547 |
-
$nonGodaddyDomainMessage .= sprintf( ' %s', __( 'If you have access to cPanel, enable the Remote Mail Exchanger.',
|
548 |
printf( '<p id="godaddy_block"><span style="background-color:yellow"><b>%s</b>: %s</span></p>', $warning, $nonGodaddyDomainMessage );
|
549 |
/* Translators: Where (%1$s) is the SPF-info URL and (%2$s) is the name of the web host */
|
550 |
-
$godaddyCustomDomainMessage = sprintf( __( 'If you own this domain, make sure it has an <a href="%1$s">SPF record authorizing %2$s</a> as a relay, or you will have delivery problems.',
|
551 |
printf( '<p id="godaddy_spf_required"><span style="background-color:yellow"><b>%s</b>: %s</span></p>', $warning, $godaddyCustomDomainMessage );
|
552 |
}
|
553 |
|
@@ -575,12 +575,12 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl
|
|
575 |
print '</section>';
|
576 |
|
577 |
print '<section class="wizard-auth-basic">';
|
578 |
-
printf( '<p class="port-explanation-ssl">%s</p>', __( 'Enter the account credentials.',
|
579 |
-
printf( '<label for="username">%s</label>', __( 'Username',
|
580 |
print '<br />';
|
581 |
print $this->basic_auth_username_callback();
|
582 |
print '<br />';
|
583 |
-
printf( '<label for="password">%s</label>', __( 'Password',
|
584 |
print '<br />';
|
585 |
print $this->basic_auth_password_callback();
|
586 |
print '</section>';
|
91 |
protected function validateTransportConfiguration() {
|
92 |
$messages = parent::validateTransportConfiguration();
|
93 |
if ( ! $this->isHostConfigured( $this->options ) ) {
|
94 |
+
array_push( $messages, __( 'Outgoing Mail Server Hostname and Port can not be empty.', 'post-smtp' ) );
|
95 |
$this->setNotConfiguredAndReady();
|
96 |
}
|
97 |
if ( ! $this->isEnvelopeFromConfigured() ) {
|
98 |
+
array_push( $messages, __( 'Envelope-From Email Address can not be empty', 'post-smtp' ) . '.' );
|
99 |
$this->setNotConfiguredAndReady();
|
100 |
}
|
101 |
if ( $this->options->isAuthTypePassword() && ! $this->isPasswordAuthenticationConfigured( $this->options ) ) {
|
102 |
+
array_push( $messages, __( 'Username and password can not be empty.', 'post-smtp' ) );
|
103 |
$this->setNotConfiguredAndReady();
|
104 |
}
|
105 |
if ( $this->getAuthenticationType() == PostmanOptions::AUTHENTICATION_TYPE_OAUTH2 ) {
|
106 |
if ( ! $this->isOAuth2SupportedHostConfigured() ) {
|
107 |
/* translators: %1$s is the Client ID label, and %2$s is the Client Secret label (e.g. Warning: OAuth 2.0 authentication requires an OAuth 2.0-capable Outgoing Mail Server, Sender Email Address, Client ID, and Client Secret.) */
|
108 |
+
array_push( $messages, sprintf( __( 'OAuth 2.0 authentication requires a supported OAuth 2.0-capable Outgoing Mail Server.', 'post-smtp' ) ) );
|
109 |
$this->setNotConfiguredAndReady();
|
110 |
}
|
111 |
}
|
113 |
$this->setReadyForOAuthGrant();
|
114 |
if ( $this->isPermissionNeeded( $this->options, $this->getOAuthToken() ) ) {
|
115 |
/* translators: %1$s is the Client ID label, and %2$s is the Client Secret label */
|
116 |
+
$message = sprintf( __( 'You have configured OAuth 2.0 authentication, but have not received permission to use it.', 'post-smtp' ), $this->getScribe()->getClientIdLabel(), $this->getScribe()->getClientSecretLabel() );
|
117 |
$message .= sprintf( ' <a href="%s">%s</a>.', PostmanUtils::getGrantOAuthPermissionUrl(), $this->getScribe()->getRequestPermissionLinkText() );
|
118 |
array_push( $messages, $message );
|
119 |
$this->setNotConfiguredAndReady();
|
160 |
/**
|
161 |
* SendGrid will never recommend it's configuration
|
162 |
*
|
163 |
+
* @param mixed $hostData
|
164 |
*/
|
165 |
public function getConfigurationBid( PostmanWizardSocket $hostData, $userAuthOverride, $originalSmtpServer ) {
|
166 |
$port = $hostData->port;
|
265 |
$authDesc = $this->getAuthenticationDescription( $recommendation ['auth'] );
|
266 |
$recommendation ['label'] = sprintf( 'SMTP - %2$s:%3$d', $transportDescription, $hostData->hostnameDomainOnly, $port );
|
267 |
/* translators: where %1$s is a description of the transport (eg. SMTPS-SSL), %2$s is a description of the authentication (eg. Password-CRAMMD5), %3$d is the TCP port (eg. 465), %4$d is the hostname */
|
268 |
+
$recommendation ['message'] = sprintf( __( 'Postman recommends %1$s with %2$s authentication to host %4$s on port %3$d.', 'post-smtp' ), $transportDescription, $authDesc, $port, $hostname );
|
269 |
}
|
270 |
|
271 |
// fill-in the rest of the recommendation
|
322 |
$oauthScribe = $transport->getScribe();
|
323 |
|
324 |
// Sanitize
|
325 |
+
add_settings_section( PostmanAdminController::SMTP_SECTION, __( 'Transport Settings', 'post-smtp' ), array(
|
326 |
$this,
|
327 |
'printSmtpSectionInfo',
|
328 |
), PostmanAdminController::SMTP_OPTIONS );
|
329 |
|
330 |
+
add_settings_field( PostmanOptions::HOSTNAME, __( 'Outgoing Mail Server Hostname', 'post-smtp' ), array(
|
331 |
$this,
|
332 |
'hostname_callback',
|
333 |
), PostmanAdminController::SMTP_OPTIONS, PostmanAdminController::SMTP_SECTION );
|
334 |
|
335 |
+
add_settings_field( PostmanOptions::PORT, __( 'Outgoing Mail Server Port', 'post-smtp' ), array(
|
336 |
$this,
|
337 |
'port_callback',
|
338 |
), PostmanAdminController::SMTP_OPTIONS, PostmanAdminController::SMTP_SECTION );
|
339 |
|
340 |
+
add_settings_field( PostmanOptions::ENVELOPE_SENDER, __( 'Envelope-From Email Address', 'post-smtp' ), array(
|
341 |
$this,
|
342 |
'sender_email_callback',
|
343 |
), PostmanAdminController::SMTP_OPTIONS, PostmanAdminController::SMTP_SECTION );
|
344 |
|
345 |
+
add_settings_field( PostmanOptions::SECURITY_TYPE, _x( 'Security', 'Configuration Input Field', 'post-smtp' ), array(
|
346 |
$this,
|
347 |
'encryption_type_callback',
|
348 |
), PostmanAdminController::SMTP_OPTIONS, PostmanAdminController::SMTP_SECTION );
|
349 |
|
350 |
+
add_settings_field( PostmanOptions::AUTHENTICATION_TYPE, __( 'Authentication', 'post-smtp' ), array(
|
351 |
$this,
|
352 |
'authentication_type_callback',
|
353 |
), PostmanAdminController::SMTP_OPTIONS, PostmanAdminController::SMTP_SECTION );
|
354 |
|
355 |
+
add_settings_section( PostmanAdminController::BASIC_AUTH_SECTION, __( 'Authentication', 'post-smtp' ), array(
|
356 |
$this,
|
357 |
'printBasicAuthSectionInfo',
|
358 |
), PostmanAdminController::BASIC_AUTH_OPTIONS );
|
359 |
|
360 |
+
add_settings_field( PostmanOptions::BASIC_AUTH_USERNAME, __( 'Username', 'post-smtp' ), array(
|
361 |
$this,
|
362 |
'basic_auth_username_callback',
|
363 |
), PostmanAdminController::BASIC_AUTH_OPTIONS, PostmanAdminController::BASIC_AUTH_SECTION );
|
364 |
|
365 |
+
add_settings_field( PostmanOptions::BASIC_AUTH_PASSWORD, __( 'Password', 'post-smtp' ), array(
|
366 |
$this,
|
367 |
'basic_auth_password_callback',
|
368 |
), PostmanAdminController::BASIC_AUTH_OPTIONS, PostmanAdminController::BASIC_AUTH_SECTION );
|
369 |
|
370 |
// the OAuth section
|
371 |
+
add_settings_section( PostmanAdminController::OAUTH_SECTION, __( 'Authentication', 'post-smtp' ), array(
|
372 |
$this,
|
373 |
'printOAuthSectionInfo',
|
374 |
), PostmanAdminController::OAUTH_AUTH_OPTIONS );
|
398 |
* Print the Section text
|
399 |
*/
|
400 |
public function printSmtpSectionInfo() {
|
401 |
+
print __( 'Configure the communication with the mail server.', 'post-smtp' );
|
402 |
}
|
403 |
|
404 |
/**
|
405 |
* Get the settings option array and print one of its values
|
406 |
*/
|
407 |
public function hostname_callback() {
|
408 |
+
printf( '<input type="text" id="input_hostname" name="postman_options[hostname]" value="%s" size="40" class="required" placeholder="%s"/>', null !== $this->options->getHostname() ? esc_attr( $this->options->getHostname() ) : '', __( 'Required', 'post-smtp' ) );
|
409 |
}
|
410 |
|
411 |
/**
|
412 |
* Get the settings option array and print one of its values
|
413 |
*/
|
414 |
public function port_callback( $args ) {
|
415 |
+
printf( '<input type="text" id="input_port" name="postman_options[port]" value="%s" %s placeholder="%s"/>', null !== $this->options->getPort() ? esc_attr( $this->options->getPort() ) : '', isset( $args ['style'] ) ? $args ['style'] : '', __( 'Required', 'post-smtp' ) );
|
416 |
}
|
417 |
|
418 |
/**
|
421 |
public function encryption_type_callback() {
|
422 |
$encType = $this->options->getEncryptionType();
|
423 |
print '<select id="input_enc_type" class="input_encryption_type" name="postman_options[enc_type]">';
|
424 |
+
printf( '<option class="input_enc_type_none" value="%s" %s>%s</option>', PostmanOptions::SECURITY_TYPE_NONE, $encType == PostmanOptions::SECURITY_TYPE_NONE ? 'selected="selected"' : '', __( 'None', 'post-smtp' ) );
|
425 |
printf( '<option class="input_enc_type_ssl" value="%s" %s>%s</option>', PostmanOptions::SECURITY_TYPE_SMTPS, $encType == PostmanOptions::SECURITY_TYPE_SMTPS ? 'selected="selected"' : '', 'SMTPS' );
|
426 |
printf( '<option class="input_enc_type_tls" value="%s" %s>%s</option>', PostmanOptions::SECURITY_TYPE_STARTTLS, $encType == PostmanOptions::SECURITY_TYPE_STARTTLS ? 'selected="selected"' : '', 'STARTTLS' );
|
427 |
print '</select>';
|
445 |
* Print the Section text
|
446 |
*/
|
447 |
public function printBasicAuthSectionInfo() {
|
448 |
+
print __( 'Enter the account credentials.', 'post-smtp' );
|
449 |
}
|
450 |
|
451 |
/**
|
453 |
*/
|
454 |
public function basic_auth_username_callback() {
|
455 |
$inputValue = (null !== $this->options->getUsername() ? esc_attr( $this->options->getUsername() ) : '');
|
456 |
+
$inputDescription = __( 'The Username is usually the same as the Envelope-From Email Address.', 'post-smtp' );
|
457 |
print ('<input tabindex="99" id="fake_user_name" name="fake_user[name]" style="position:absolute; top:-500px;" type="text" value="Safari Autofill Me">') ;
|
458 |
+
printf( '<input type="text" id="input_basic_auth_username" name="postman_options[basic_auth_username]" value="%s" size="40" class="required" placeholder="%s"/><br/><span class="postman_input_description">%s</span>', $inputValue, __( 'Required', 'post-smtp' ), $inputDescription );
|
459 |
}
|
460 |
|
461 |
/**
|
463 |
*/
|
464 |
public function basic_auth_password_callback() {
|
465 |
print ('<input tabindex="99" id="fake_password" name="fake[password]" style="position:absolute; top:-500px;" type="password" value="Safari Autofill Me">') ;
|
466 |
+
printf( '<input type="password" id="input_basic_auth_password" name="postman_options[basic_auth_password]" value="%s" size="40" class="required" placeholder="%s"/>', null !== $this->options->getPassword() ? esc_attr( PostmanUtils::obfuscatePassword( $this->options->getPassword() ) ) : '', __( 'Required', 'post-smtp' ) );
|
467 |
print ' <input type="button" id="togglePasswordField" value="Show Password" class="button button-secondary" style="visibility:hidden" />';
|
468 |
}
|
469 |
|
471 |
* Get the settings option array and print one of its values
|
472 |
*/
|
473 |
public function oauth_client_id_callback() {
|
474 |
+
printf( '<input type="text" onClick="this.setSelectionRange(0, this.value.length)" id="oauth_client_id" name="postman_options[oauth_client_id]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getClientId() ? esc_attr( $this->options->getClientId() ) : '', __( 'Required', 'post-smtp' ) );
|
475 |
}
|
476 |
|
477 |
/**
|
478 |
* Get the settings option array and print one of its values
|
479 |
*/
|
480 |
public function oauth_client_secret_callback() {
|
481 |
+
printf( '<input type="text" onClick="this.setSelectionRange(0, this.value.length)" autocomplete="off" id="oauth_client_secret" name="postman_options[oauth_client_secret]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getClientSecret() ? esc_attr( $this->options->getClientSecret() ) : '', __( 'Required', 'post-smtp' ) );
|
482 |
}
|
483 |
|
484 |
/**
|
507 |
$oauthScribe = $transport->getScribe();
|
508 |
return $oauthScribe->getCallbackDomain();
|
509 |
} catch ( Exception $e ) {
|
510 |
+
return __( 'Error computing your domain root - please enter it manually', 'post-smtp' );
|
511 |
}
|
512 |
}
|
513 |
|
526 |
*/
|
527 |
public function sender_email_callback() {
|
528 |
$inputValue = (null !== $this->options->getEnvelopeSender() ? esc_attr( $this->options->getEnvelopeSender() ) : '');
|
529 |
+
$requiredLabel = __( 'Required', 'post-smtp' );
|
530 |
+
$envelopeFromMessage = __( 'This address, like the <b>return address</b> printed on an envelope, identifies the account owner to the SMTP server.', 'post-smtp' );
|
531 |
+
$spfMessage = sprintf( __( 'For reliable delivery, this domain must specify an <a target="_blank" href="%s">SPF record</a> permitting the use of the SMTP server named above.', 'post-smtp' ), 'https://www.mail-tester.com/spf/' );
|
532 |
printf( '<input type="email" id="input_envelope_sender_email" name="postman_options[envelope_sender]" value="%s" size="40" class="required" placeholder="%s"/> <br/><span class="postman_input_description">%s %s</span>', $inputValue, $requiredLabel, $envelopeFromMessage, $spfMessage );
|
533 |
}
|
534 |
|
535 |
/**
|
536 |
*/
|
537 |
public function printWizardMailServerHostnameStep() {
|
538 |
+
printf( '<legend>%s</legend>', _x( 'Which host will relay the mail?', 'Wizard Step Title', 'post-smtp' ) );
|
539 |
+
printf( '<p>%s</p>', __( 'This is the Outgoing (SMTP) Mail Server, or Mail Submission Agent (MSA), which Postman delegates mail delivery to. This server is specific to your email account, and if you don\'t know what to use, ask your email service provider.', 'post-smtp' ) );
|
540 |
+
printf( '<p>%s</p>', __( 'Note that many WordPress hosts, such as GoDaddy, Bluehost and Dreamhost, require that you use their mail accounts with their mail servers, and prevent you from using others.', 'post-smtp' ) );
|
541 |
+
printf( '<label for="hostname">%s</label>', __( 'Outgoing Mail Server Hostname', 'post-smtp' ) );
|
542 |
print $this->hostname_callback();
|
543 |
printf( '<p class="ajax-loader" style="display:none"><img src="%s"/></p>', plugins_url( 'post-smtp/style/ajax-loader.gif' ) );
|
544 |
+
$warning = __( 'Warning', 'post-smtp' );
|
545 |
/* Translators: Where (%s) is the name of the web host */
|
546 |
+
$nonGodaddyDomainMessage = sprintf( __( 'Your email address <b>requires</b> access to a remote SMTP server blocked by %s.', 'post-smtp' ), 'GoDaddy' );
|
547 |
+
$nonGodaddyDomainMessage .= sprintf( ' %s', __( 'If you have access to cPanel, enable the Remote Mail Exchanger.', 'post-smtp' ) );
|
548 |
printf( '<p id="godaddy_block"><span style="background-color:yellow"><b>%s</b>: %s</span></p>', $warning, $nonGodaddyDomainMessage );
|
549 |
/* Translators: Where (%1$s) is the SPF-info URL and (%2$s) is the name of the web host */
|
550 |
+
$godaddyCustomDomainMessage = sprintf( __( 'If you own this domain, make sure it has an <a href="%1$s">SPF record authorizing %2$s</a> as a relay, or you will have delivery problems.', 'post-smtp' ), 'http://www.mail-tester.com/spf/godaddy', 'GoDaddy' );
|
551 |
printf( '<p id="godaddy_spf_required"><span style="background-color:yellow"><b>%s</b>: %s</span></p>', $warning, $godaddyCustomDomainMessage );
|
552 |
}
|
553 |
|
575 |
print '</section>';
|
576 |
|
577 |
print '<section class="wizard-auth-basic">';
|
578 |
+
printf( '<p class="port-explanation-ssl">%s</p>', __( 'Enter the account credentials.', 'post-smtp' ) );
|
579 |
+
printf( '<label for="username">%s</label>', __( 'Username', 'post-smtp' ) );
|
580 |
print '<br />';
|
581 |
print $this->basic_auth_username_callback();
|
582 |
print '<br />';
|
583 |
+
printf( '<label for="password">%s</label>', __( 'Password', 'post-smtp' ) );
|
584 |
print '<br />';
|
585 |
print $this->basic_auth_password_callback();
|
586 |
print '</section>';
|
Postman/Postman-Mail/PostmanTransportRegistry.php
CHANGED
@@ -39,7 +39,7 @@ class PostmanTransportRegistry {
|
|
39 |
* B) when querying what a theoretical scenario involving this transport is like
|
40 |
* (ie.for ajax in config screen)
|
41 |
*
|
42 |
-
* @param
|
43 |
*/
|
44 |
public function getTransport( $slug ) {
|
45 |
$transports = $this->getTransports();
|
@@ -61,7 +61,7 @@ class PostmanTransportRegistry {
|
|
61 |
/**
|
62 |
* Determine if a specific transport is registered in the directory.
|
63 |
*
|
64 |
-
* @param
|
65 |
*/
|
66 |
public function isRegistered( $slug ) {
|
67 |
$transports = $this->getTransports();
|
@@ -71,7 +71,7 @@ class PostmanTransportRegistry {
|
|
71 |
/**
|
72 |
* Retrieve the transport Postman is currently configured with.
|
73 |
*
|
74 |
-
* @return
|
75 |
* @deprecated
|
76 |
*/
|
77 |
public function getCurrentTransport() {
|
@@ -105,7 +105,7 @@ class PostmanTransportRegistry {
|
|
105 |
/**
|
106 |
* Retrieve the transport Postman is currently configured with.
|
107 |
*
|
108 |
-
* @return
|
109 |
*/
|
110 |
public function getSelectedTransport() {
|
111 |
$selectedTransport = PostmanOptions::getInstance()->getTransportType();
|
@@ -143,8 +143,8 @@ class PostmanTransportRegistry {
|
|
143 |
/**
|
144 |
* Polls all the installed transports to get a complete list of sockets to probe for connectivity
|
145 |
*
|
146 |
-
* @param
|
147 |
-
* @param
|
148 |
* @return multitype:
|
149 |
*/
|
150 |
public function getSocketsForSetupWizardToProbe( $hostname = 'localhost', $smtpServerGuess = null ) {
|
@@ -178,7 +178,7 @@ class PostmanTransportRegistry {
|
|
178 |
*
|
179 |
* response should include ['success'], ['message'], ['priority']
|
180 |
*
|
181 |
-
* @param
|
182 |
*/
|
183 |
public function getRecommendation( PostmanWizardSocket $hostData, $userAuthOverride, $originalSmtpServer ) {
|
184 |
$scrubbedUserAuthOverride = $this->scrubUserOverride( $hostData, $userAuthOverride );
|
@@ -193,7 +193,7 @@ class PostmanTransportRegistry {
|
|
193 |
/**
|
194 |
*
|
195 |
* @param PostmanWizardSocket $hostData
|
196 |
-
* @param
|
197 |
* @return NULL
|
198 |
*/
|
199 |
private function scrubUserOverride( PostmanWizardSocket $hostData, $userAuthOverride ) {
|
@@ -231,18 +231,18 @@ class PostmanTransportRegistry {
|
|
231 |
if ( PostmanOptions::getInstance()->getRunMode() != PostmanOptions::RUN_MODE_PRODUCTION ) {
|
232 |
return array(
|
233 |
'error' => true,
|
234 |
-
'message' => __( 'Postman is in <em>non-Production</em> mode and is dumping all emails.',
|
235 |
);
|
236 |
} else {
|
237 |
return array(
|
238 |
'error' => false,
|
239 |
-
'message' => __( 'Postman is configured.',
|
240 |
);
|
241 |
}
|
242 |
} else {
|
243 |
return array(
|
244 |
'error' => true,
|
245 |
-
'message' => __( 'Postman is <em>not</em> configured and is mimicking out-of-the-box WordPress email delivery.',
|
246 |
);
|
247 |
}
|
248 |
}
|
39 |
* B) when querying what a theoretical scenario involving this transport is like
|
40 |
* (ie.for ajax in config screen)
|
41 |
*
|
42 |
+
* @param mixed $slug
|
43 |
*/
|
44 |
public function getTransport( $slug ) {
|
45 |
$transports = $this->getTransports();
|
61 |
/**
|
62 |
* Determine if a specific transport is registered in the directory.
|
63 |
*
|
64 |
+
* @param mixed $slug
|
65 |
*/
|
66 |
public function isRegistered( $slug ) {
|
67 |
$transports = $this->getTransports();
|
71 |
/**
|
72 |
* Retrieve the transport Postman is currently configured with.
|
73 |
*
|
74 |
+
* @return PostmanModuleTransport
|
75 |
* @deprecated
|
76 |
*/
|
77 |
public function getCurrentTransport() {
|
105 |
/**
|
106 |
* Retrieve the transport Postman is currently configured with.
|
107 |
*
|
108 |
+
* @return PostmanModuleTransport
|
109 |
*/
|
110 |
public function getSelectedTransport() {
|
111 |
$selectedTransport = PostmanOptions::getInstance()->getTransportType();
|
143 |
/**
|
144 |
* Polls all the installed transports to get a complete list of sockets to probe for connectivity
|
145 |
*
|
146 |
+
* @param mixed $hostname
|
147 |
+
* @param mixed $isGmail
|
148 |
* @return multitype:
|
149 |
*/
|
150 |
public function getSocketsForSetupWizardToProbe( $hostname = 'localhost', $smtpServerGuess = null ) {
|
178 |
*
|
179 |
* response should include ['success'], ['message'], ['priority']
|
180 |
*
|
181 |
+
* @param mixed $hostData
|
182 |
*/
|
183 |
public function getRecommendation( PostmanWizardSocket $hostData, $userAuthOverride, $originalSmtpServer ) {
|
184 |
$scrubbedUserAuthOverride = $this->scrubUserOverride( $hostData, $userAuthOverride );
|
193 |
/**
|
194 |
*
|
195 |
* @param PostmanWizardSocket $hostData
|
196 |
+
* @param mixed $userAuthOverride
|
197 |
* @return NULL
|
198 |
*/
|
199 |
private function scrubUserOverride( PostmanWizardSocket $hostData, $userAuthOverride ) {
|
231 |
if ( PostmanOptions::getInstance()->getRunMode() != PostmanOptions::RUN_MODE_PRODUCTION ) {
|
232 |
return array(
|
233 |
'error' => true,
|
234 |
+
'message' => __( 'Postman is in <em>non-Production</em> mode and is dumping all emails.', 'post-smtp' ),
|
235 |
);
|
236 |
} else {
|
237 |
return array(
|
238 |
'error' => false,
|
239 |
+
'message' => __( 'Postman is configured.', 'post-smtp' ),
|
240 |
);
|
241 |
}
|
242 |
} else {
|
243 |
return array(
|
244 |
'error' => true,
|
245 |
+
'message' => __( 'Postman is <em>not</em> configured and is mimicking out-of-the-box WordPress email delivery.', 'post-smtp' ),
|
246 |
);
|
247 |
}
|
248 |
}
|
Postman/Postman-Mail/PostmanWooCommerce.php
CHANGED
@@ -28,7 +28,7 @@ if ( ! class_exists( 'PostmanWoocommerce' ) ) {
|
|
28 |
|
29 |
return array(
|
30 |
|
31 |
-
array( 'title' => __( 'Email notifications',
|
32 |
|
33 |
array( 'type' => 'email_notification' ),
|
34 |
|
@@ -36,11 +36,11 @@ if ( ! class_exists( 'PostmanWoocommerce' ) ) {
|
|
36 |
|
37 |
array( 'type' => 'sectionend', 'id' => 'email_recipient_options' ),
|
38 |
|
39 |
-
array( 'title' => __( 'Email sender options',
|
40 |
|
41 |
array(
|
42 |
-
'title' => __( '"From" name',
|
43 |
-
'desc' => __( 'How the sender name appears in outgoing WooCommerce emails.',
|
44 |
'id' => 'woocommerce_email_from_name',
|
45 |
'type' => 'text',
|
46 |
'css' => 'min-width:300px;',
|
@@ -50,8 +50,8 @@ if ( ! class_exists( 'PostmanWoocommerce' ) ) {
|
|
50 |
),
|
51 |
|
52 |
array(
|
53 |
-
'title' => __( '"From" address',
|
54 |
-
'desc' => __( 'This is overided by the account configured on Post SMTP plugin configuration.',
|
55 |
'id' => 'woocommerce_email_from_address',
|
56 |
'type' => 'email',
|
57 |
'custom_attributes' => array(
|
@@ -66,26 +66,26 @@ if ( ! class_exists( 'PostmanWoocommerce' ) ) {
|
|
66 |
|
67 |
array( 'type' => 'sectionend', 'id' => 'email_options' ),
|
68 |
|
69 |
-
array( 'title' => __( 'Email template',
|
70 |
|
71 |
array(
|
72 |
-
'title' => __( 'Header image',
|
73 |
-
'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).',
|
74 |
'id' => 'woocommerce_email_header_image',
|
75 |
'type' => 'text',
|
76 |
'css' => 'min-width:300px;',
|
77 |
-
'placeholder' => __( 'N/A',
|
78 |
'default' => '',
|
79 |
'autoload' => false,
|
80 |
'desc_tip' => true,
|
81 |
),
|
82 |
|
83 |
array(
|
84 |
-
'title' => __( 'Footer text',
|
85 |
-
'desc' => __( 'The text to appear in the footer of WooCommerce emails.',
|
86 |
'id' => 'woocommerce_email_footer_text',
|
87 |
'css' => 'width:300px; height: 75px;',
|
88 |
-
'placeholder' => __( 'N/A',
|
89 |
'type' => 'textarea',
|
90 |
/* translators: %s: site name */
|
91 |
'default' => get_bloginfo( 'name', 'display' ),
|
@@ -94,9 +94,9 @@ if ( ! class_exists( 'PostmanWoocommerce' ) ) {
|
|
94 |
),
|
95 |
|
96 |
array(
|
97 |
-
'title' => __( 'Base color',
|
98 |
/* translators: %s: default color */
|
99 |
-
'desc' => sprintf( __( 'The base color for WooCommerce email templates. Default %s.',
|
100 |
'id' => 'woocommerce_email_base_color',
|
101 |
'type' => 'color',
|
102 |
'css' => 'width:6em;',
|
@@ -106,9 +106,9 @@ if ( ! class_exists( 'PostmanWoocommerce' ) ) {
|
|
106 |
),
|
107 |
|
108 |
array(
|
109 |
-
'title' => __( 'Background color',
|
110 |
/* translators: %s: default color */
|
111 |
-
'desc' => sprintf( __( 'The background color for WooCommerce email templates. Default %s.',
|
112 |
'id' => 'woocommerce_email_background_color',
|
113 |
'type' => 'color',
|
114 |
'css' => 'width:6em;',
|
@@ -118,9 +118,9 @@ if ( ! class_exists( 'PostmanWoocommerce' ) ) {
|
|
118 |
),
|
119 |
|
120 |
array(
|
121 |
-
'title' => __( 'Body background color',
|
122 |
/* translators: %s: default color */
|
123 |
-
'desc' => sprintf( __( 'The main body background color. Default %s.',
|
124 |
'id' => 'woocommerce_email_body_background_color',
|
125 |
'type' => 'color',
|
126 |
'css' => 'width:6em;',
|
@@ -130,9 +130,9 @@ if ( ! class_exists( 'PostmanWoocommerce' ) ) {
|
|
130 |
),
|
131 |
|
132 |
array(
|
133 |
-
'title' => __( 'Body text color',
|
134 |
/* translators: %s: default color */
|
135 |
-
'desc' => sprintf( __( 'The main body text color. Default %s.',
|
136 |
'id' => 'woocommerce_email_text_color',
|
137 |
'type' => 'color',
|
138 |
'css' => 'width:6em;',
|
28 |
|
29 |
return array(
|
30 |
|
31 |
+
array( 'title' => __( 'Email notifications', 'post-smtp' ), 'desc' => __( 'Email notifications sent from WooCommerce are listed below. Click on an email to configure it.', 'post-smtp' ), 'type' => 'title', 'id' => 'email_notification_settings' ),
|
32 |
|
33 |
array( 'type' => 'email_notification' ),
|
34 |
|
36 |
|
37 |
array( 'type' => 'sectionend', 'id' => 'email_recipient_options' ),
|
38 |
|
39 |
+
array( 'title' => __( 'Email sender options', 'post-smtp' ), 'type' => 'title', 'desc' => '', 'id' => 'email_options' ),
|
40 |
|
41 |
array(
|
42 |
+
'title' => __( '"From" name', 'post-smtp' ),
|
43 |
+
'desc' => __( 'How the sender name appears in outgoing WooCommerce emails.', 'post-smtp' ),
|
44 |
'id' => 'woocommerce_email_from_name',
|
45 |
'type' => 'text',
|
46 |
'css' => 'min-width:300px;',
|
50 |
),
|
51 |
|
52 |
array(
|
53 |
+
'title' => __( '"From" address', 'post-smtp' ),
|
54 |
+
'desc' => __( 'This is overided by the account configured on Post SMTP plugin configuration.', 'post-smtp' ),
|
55 |
'id' => 'woocommerce_email_from_address',
|
56 |
'type' => 'email',
|
57 |
'custom_attributes' => array(
|
66 |
|
67 |
array( 'type' => 'sectionend', 'id' => 'email_options' ),
|
68 |
|
69 |
+
array( 'title' => __( 'Email template', 'post-smtp' ), 'type' => 'title', 'desc' => sprintf( __( 'This section lets you customize the WooCommerce emails. <a href="%s" target="_blank">Click here to preview your email template</a>.', 'post-smtp' ), wp_nonce_url( admin_url( '?preview_woocommerce_mail=true' ), 'preview-mail' ) ), 'id' => 'email_template_options' ),
|
70 |
|
71 |
array(
|
72 |
+
'title' => __( 'Header image', 'post-smtp' ),
|
73 |
+
'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'post-smtp' ),
|
74 |
'id' => 'woocommerce_email_header_image',
|
75 |
'type' => 'text',
|
76 |
'css' => 'min-width:300px;',
|
77 |
+
'placeholder' => __( 'N/A', 'post-smtp' ),
|
78 |
'default' => '',
|
79 |
'autoload' => false,
|
80 |
'desc_tip' => true,
|
81 |
),
|
82 |
|
83 |
array(
|
84 |
+
'title' => __( 'Footer text', 'post-smtp' ),
|
85 |
+
'desc' => __( 'The text to appear in the footer of WooCommerce emails.', 'post-smtp' ),
|
86 |
'id' => 'woocommerce_email_footer_text',
|
87 |
'css' => 'width:300px; height: 75px;',
|
88 |
+
'placeholder' => __( 'N/A', 'post-smtp' ),
|
89 |
'type' => 'textarea',
|
90 |
/* translators: %s: site name */
|
91 |
'default' => get_bloginfo( 'name', 'display' ),
|
94 |
),
|
95 |
|
96 |
array(
|
97 |
+
'title' => __( 'Base color', 'post-smtp' ),
|
98 |
/* translators: %s: default color */
|
99 |
+
'desc' => sprintf( __( 'The base color for WooCommerce email templates. Default %s.', 'post-smtp' ), '<code>#96588a</code>' ),
|
100 |
'id' => 'woocommerce_email_base_color',
|
101 |
'type' => 'color',
|
102 |
'css' => 'width:6em;',
|
106 |
),
|
107 |
|
108 |
array(
|
109 |
+
'title' => __( 'Background color', 'post-smtp' ),
|
110 |
/* translators: %s: default color */
|
111 |
+
'desc' => sprintf( __( 'The background color for WooCommerce email templates. Default %s.', 'post-smtp' ), '<code>#f7f7f7</code>' ),
|
112 |
'id' => 'woocommerce_email_background_color',
|
113 |
'type' => 'color',
|
114 |
'css' => 'width:6em;',
|
118 |
),
|
119 |
|
120 |
array(
|
121 |
+
'title' => __( 'Body background color', 'post-smtp' ),
|
122 |
/* translators: %s: default color */
|
123 |
+
'desc' => sprintf( __( 'The main body background color. Default %s.', 'post-smtp' ), '<code>#ffffff</code>' ),
|
124 |
'id' => 'woocommerce_email_body_background_color',
|
125 |
'type' => 'color',
|
126 |
'css' => 'width:6em;',
|
130 |
),
|
131 |
|
132 |
array(
|
133 |
+
'title' => __( 'Body text color', 'post-smtp' ),
|
134 |
/* translators: %s: default color */
|
135 |
+
'desc' => sprintf( __( 'The main body text color. Default %s.', 'post-smtp' ), '<code>#3c3c3c</code>' ),
|
136 |
'id' => 'woocommerce_email_text_color',
|
137 |
'type' => 'color',
|
138 |
'css' => 'width:6em;',
|
Postman/Postman-Mail/PostmanZendMailEngine.php
CHANGED
@@ -47,8 +47,8 @@ if ( ! class_exists( 'PostmanZendMailEngine' ) ) {
|
|
47 |
|
48 |
/**
|
49 |
*
|
50 |
-
* @param
|
51 |
-
* @param
|
52 |
*/
|
53 |
function __construct( PostmanZendModuleTransport $transport ) {
|
54 |
assert( isset( $transport ) );
|
@@ -204,7 +204,7 @@ if ( ! class_exists( 'PostmanZendMailEngine' ) ) {
|
|
204 |
$message = $e->getMessage();
|
205 |
if ( $e->getCode() == 334 ) {
|
206 |
// replace the unusable Google message with a better one in the case of code 334
|
207 |
-
$message = sprintf( __( 'Communication Error [334] - make sure the Envelope From email is the same account used to create the Client ID.',
|
208 |
}
|
209 |
// create a new exception
|
210 |
$newException = new Exception( $message, $e->getCode() );
|
47 |
|
48 |
/**
|
49 |
*
|
50 |
+
* @param mixed $senderEmail
|
51 |
+
* @param mixed $accessToken
|
52 |
*/
|
53 |
function __construct( PostmanZendModuleTransport $transport ) {
|
54 |
assert( isset( $transport ) );
|
204 |
$message = $e->getMessage();
|
205 |
if ( $e->getCode() == 334 ) {
|
206 |
// replace the unusable Google message with a better one in the case of code 334
|
207 |
+
$message = sprintf( __( 'Communication Error [334] - make sure the Envelope From email is the same account used to create the Client ID.', 'post-smtp' ) );
|
208 |
}
|
209 |
// create a new exception
|
210 |
$newException = new Exception( $message, $e->getCode() );
|
Postman/Postman-Mail/PostmanZendMailTransportConfigurationFactory.php
CHANGED
@@ -78,11 +78,11 @@ if (! class_exists ( 'PostmanOAuth2ConfigurationFactory' )) {
|
|
78 |
*
|
79 |
* Create the Configuration structure for Zend_Mail
|
80 |
*
|
81 |
-
* @param
|
82 |
-
* @param
|
83 |
-
* @param
|
84 |
-
* @param
|
85 |
-
* @param
|
86 |
* @return multitype:unknown NULL
|
87 |
*/
|
88 |
private static function createConfiguration($logger, $hostname, $port, $securityType, $authenticationType, $initClientRequestEncoded) {
|
@@ -99,7 +99,7 @@ if (! class_exists ( 'PostmanOAuth2ConfigurationFactory' )) {
|
|
99 |
/**
|
100 |
* Create the vendor string (for Yahoo servers only)
|
101 |
*
|
102 |
-
* @param
|
103 |
* @return string
|
104 |
*/
|
105 |
private static function createVendorString($hostname) {
|
@@ -116,9 +116,9 @@ if (! class_exists ( 'PostmanOAuth2ConfigurationFactory' )) {
|
|
116 |
/**
|
117 |
* Create the standard OAuth2 SMTP Authentication string
|
118 |
*
|
119 |
-
* @param
|
120 |
-
* @param
|
121 |
-
* @param
|
122 |
* @return string
|
123 |
*/
|
124 |
private static function createAuthenticationString($senderEmail, $oauth2AccessToken, $vendor) {
|
78 |
*
|
79 |
* Create the Configuration structure for Zend_Mail
|
80 |
*
|
81 |
+
* @param mixed $hostname
|
82 |
+
* @param mixed $port
|
83 |
+
* @param mixed $securityType
|
84 |
+
* @param mixed $authenticationType
|
85 |
+
* @param mixed $initClientRequestEncoded
|
86 |
* @return multitype:unknown NULL
|
87 |
*/
|
88 |
private static function createConfiguration($logger, $hostname, $port, $securityType, $authenticationType, $initClientRequestEncoded) {
|
99 |
/**
|
100 |
* Create the vendor string (for Yahoo servers only)
|
101 |
*
|
102 |
+
* @param mixed $hostname
|
103 |
* @return string
|
104 |
*/
|
105 |
private static function createVendorString($hostname) {
|
116 |
/**
|
117 |
* Create the standard OAuth2 SMTP Authentication string
|
118 |
*
|
119 |
+
* @param mixed $senderEmail
|
120 |
+
* @param mixed $oauth2AccessToken
|
121 |
+
* @param mixed $vendor
|
122 |
* @return string
|
123 |
*/
|
124 |
private static function createAuthenticationString($senderEmail, $oauth2AccessToken, $vendor) {
|
Postman/Postman-Mail/Zend-1.12.10/Mail.php
CHANGED
@@ -365,7 +365,7 @@ class Postman_Zend_Mail extends Postman_Zend_Mime_Message
|
|
365 |
}
|
366 |
|
367 |
$mp = new Postman_Zend_Mime_Part($txt);
|
368 |
-
$mp->encoding = $encoding;
|
369 |
$mp->type = Postman_Zend_Mime::TYPE_TEXT;
|
370 |
$mp->disposition = Postman_Zend_Mime::DISPOSITION_INLINE;
|
371 |
$mp->charset = $charset;
|
@@ -406,7 +406,7 @@ class Postman_Zend_Mail extends Postman_Zend_Mime_Message
|
|
406 |
}
|
407 |
|
408 |
$mp = new Postman_Zend_Mime_Part($html);
|
409 |
-
$mp->encoding = $encoding;
|
410 |
$mp->type = Postman_Zend_Mime::TYPE_HTML;
|
411 |
$mp->disposition = Postman_Zend_Mime::DISPOSITION_INLINE;
|
412 |
$mp->charset = $charset;
|
365 |
}
|
366 |
|
367 |
$mp = new Postman_Zend_Mime_Part($txt);
|
368 |
+
$mp->encoding = apply_filters( 'post_smtp_content_transfer_encoding', $encoding, Postman_Zend_Mime::TYPE_TEXT);
|
369 |
$mp->type = Postman_Zend_Mime::TYPE_TEXT;
|
370 |
$mp->disposition = Postman_Zend_Mime::DISPOSITION_INLINE;
|
371 |
$mp->charset = $charset;
|
406 |
}
|
407 |
|
408 |
$mp = new Postman_Zend_Mime_Part($html);
|
409 |
+
$mp->encoding = apply_filters( 'post_smtp_content_transfer_encoding', $encoding, Postman_Zend_Mime::TYPE_HTML );
|
410 |
$mp->type = Postman_Zend_Mime::TYPE_HTML;
|
411 |
$mp->disposition = Postman_Zend_Mime::DISPOSITION_INLINE;
|
412 |
$mp->charset = $charset;
|
Postman/Postman-Mail/Zend-1.12.10/Validate/EmailAddress.php
CHANGED
@@ -321,7 +321,7 @@ class Postman_Zend_Validate_EmailAddress extends Postman_Zend_Validate_Abstract
|
|
321 |
/**
|
322 |
* Returns the set domainCheck option
|
323 |
*
|
324 |
-
* @return
|
325 |
*/
|
326 |
public function getDomainCheck()
|
327 |
{
|
321 |
/**
|
322 |
* Returns the set domainCheck option
|
323 |
*
|
324 |
+
* @return mixed
|
325 |
*/
|
326 |
public function getDomainCheck()
|
327 |
{
|
Postman/Postman-Mail/sendgrid/composer.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
{
|
2 |
"require": {
|
3 |
-
"sendgrid/sendgrid": "~
|
4 |
}
|
5 |
-
}
|
1 |
{
|
2 |
"require": {
|
3 |
+
"sendgrid/sendgrid": "~7"
|
4 |
}
|
5 |
+
}
|
Postman/Postman-Send-Test-Email/PostmanSendTestEmailController.php
CHANGED
@@ -13,7 +13,7 @@ class PostmanSendTestEmailController {
|
|
13 |
/**
|
14 |
* Constructor
|
15 |
*
|
16 |
-
* @param
|
17 |
*/
|
18 |
public function __construct( $rootPluginFilenameAndPath ) {
|
19 |
assert( ! empty( $rootPluginFilenameAndPath ) );
|
@@ -90,7 +90,7 @@ class PostmanSendTestEmailController {
|
|
90 |
* Register the Email Test screen
|
91 |
*/
|
92 |
public function addEmailTestSubmenu() {
|
93 |
-
$page = add_submenu_page( null, sprintf( __( '%s Setup',
|
94 |
$this,
|
95 |
'outputTestEmailContent',
|
96 |
) );
|
@@ -110,11 +110,11 @@ class PostmanSendTestEmailController {
|
|
110 |
wp_enqueue_script( 'postman_test_email_wizard_script' );
|
111 |
wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_email_test', array(
|
112 |
'recipient' => '#' . self::RECIPIENT_EMAIL_FIELD_NAME,
|
113 |
-
'not_started' => _x( 'In Outbox', 'Email Test Status',
|
114 |
-
'sending' => _x( 'Sending...', 'Email Test Status',
|
115 |
-
'success' => _x( 'Success', 'Email Test Status',
|
116 |
-
'failed' => _x( 'Failed', 'Email Test Status',
|
117 |
-
'ajax_error' => __( 'Ajax Error',
|
118 |
) );
|
119 |
}
|
120 |
|
@@ -123,42 +123,42 @@ class PostmanSendTestEmailController {
|
|
123 |
public function outputTestEmailContent() {
|
124 |
print '<div class="wrap">';
|
125 |
|
126 |
-
PostmanViewController::outputChildPageHeader( __( 'Send a Test Email',
|
127 |
|
128 |
printf( '<form id="postman_test_email_wizard" method="post" action="%s">', PostmanUtils::getSettingsPageUrl() );
|
129 |
|
130 |
// Step 1
|
131 |
-
printf( '<h5>%s</h5>', __( 'Specify the Recipient',
|
132 |
print '<fieldset>';
|
133 |
-
printf( '<legend>%s</legend>', __( 'Who is this message going to?',
|
134 |
-
printf( '<p>%s', __( 'This utility allows you to send an email message for testing.',
|
135 |
print ' ';
|
136 |
/* translators: where %d is an amount of time, in seconds */
|
137 |
-
printf( '%s</p>', sprintf( _n( 'If there is a problem, Postman will give up after %d second.', 'If there is a problem, Postman will give up after %d seconds.', $this->options->getReadTimeout(),
|
138 |
-
printf( '<label for="postman_test_options[test_email]">%s</label>', _x( 'Recipient Email Address', 'Configuration Input Field',
|
139 |
print $this->test_email_callback();
|
140 |
print '</fieldset>';
|
141 |
|
142 |
// Step 2
|
143 |
-
printf( '<h5>%s</h5>', __( 'Send The Message',
|
144 |
print '<fieldset>';
|
145 |
print '<legend>';
|
146 |
-
print __( 'Sending the message:',
|
147 |
-
printf( ' <span id="postman_test_message_status">%s</span>', _x( 'In Outbox', 'Email Test Status',
|
148 |
print '</legend>';
|
149 |
print '<section>';
|
150 |
-
printf( '<p><label>%s</label></p>', __( 'Status',
|
151 |
print '<textarea id="postman_test_message_error_message" readonly="readonly" cols="65" rows="4"></textarea>';
|
152 |
print '</section>';
|
153 |
print '</fieldset>';
|
154 |
|
155 |
// Step 3
|
156 |
-
printf( '<h5>%s</h5>', __( 'Session Transcript',
|
157 |
print '<fieldset>';
|
158 |
-
printf( '<legend>%s</legend>', __( 'Examine the Session Transcript if you need to.',
|
159 |
-
printf( '<p>%s</p>', __( 'This is the conversation between Postman and the mail server. It can be useful for diagnosing problems. <b>DO NOT</b> post it on-line, it may contain your account password.',
|
160 |
print '<section>';
|
161 |
-
printf( '<p><label for="postman_test_message_transcript">%s</label></p>', __( 'Session Transcript',
|
162 |
print '<textarea readonly="readonly" id="postman_test_message_transcript" cols="65" rows="8"></textarea>';
|
163 |
print '</section>';
|
164 |
print '</fieldset>';
|
@@ -206,7 +206,7 @@ class PostmanSendTestEmailAjaxController extends PostmanAbstractAjaxHandler {
|
|
206 |
$serverName = PostmanUtils::postmanGetServerName();
|
207 |
|
208 |
/* translators: where %s is the domain name of the site */
|
209 |
-
$subject = sprintf( _x( 'Postman SMTP Test (%s)', 'Test Email Subject',
|
210 |
|
211 |
// Postman API: indicate to Postman this is just for testing
|
212 |
add_filter( 'postman_test_email', array(
|
@@ -236,7 +236,7 @@ class PostmanSendTestEmailAjaxController extends PostmanAbstractAjaxHandler {
|
|
236 |
if ( $success ) {
|
237 |
$this->logger->debug( 'Test Email delivered to server' );
|
238 |
// the message was sent successfully, generate an appropriate message for the user
|
239 |
-
$statusMessage = sprintf( __( 'Your message was delivered (%d ms) to the SMTP server! Congratulations :)',
|
240 |
|
241 |
$this->logger->debug( 'statusmessage: ' . $statusMessage );
|
242 |
|
@@ -292,9 +292,9 @@ class PostmanSendTestEmailAjaxController extends PostmanAbstractAjaxHandler {
|
|
292 |
// English - Mandarin - French - Hindi - Spanish - Portuguese - Russian - Japanese
|
293 |
// http://www.pinyin.info/tools/converter/chars2uninumbers.html
|
294 |
$greeting = 'Hello! - 你好 - Bonjour! - नमस्ते - ¡Hola! - Olá - Привет! - 今日は';
|
295 |
-
$sentBy = sprintf( _x( 'Sent by Postman %s', 'Test Email Tagline',
|
296 |
-
$imageSource = __( 'Image source',
|
297 |
-
$withPermission = __( 'Used with permission',
|
298 |
$messageArray = array(
|
299 |
'Content-Type: text/plain; charset = "UTF-8"',
|
300 |
'Content-Transfer-Encoding: 8bit',
|
13 |
/**
|
14 |
* Constructor
|
15 |
*
|
16 |
+
* @param mixed $rootPluginFilenameAndPath
|
17 |
*/
|
18 |
public function __construct( $rootPluginFilenameAndPath ) {
|
19 |
assert( ! empty( $rootPluginFilenameAndPath ) );
|
90 |
* Register the Email Test screen
|
91 |
*/
|
92 |
public function addEmailTestSubmenu() {
|
93 |
+
$page = add_submenu_page( null, sprintf( __( '%s Setup', 'post-smtp' ), __( 'Postman SMTP', 'post-smtp' ) ), __( 'Postman SMTP', 'post-smtp' ), Postman::MANAGE_POSTMAN_CAPABILITY_NAME, PostmanSendTestEmailController::EMAIL_TEST_SLUG, array(
|
94 |
$this,
|
95 |
'outputTestEmailContent',
|
96 |
) );
|
110 |
wp_enqueue_script( 'postman_test_email_wizard_script' );
|
111 |
wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_email_test', array(
|
112 |
'recipient' => '#' . self::RECIPIENT_EMAIL_FIELD_NAME,
|
113 |
+
'not_started' => _x( 'In Outbox', 'Email Test Status', 'post-smtp' ),
|
114 |
+
'sending' => _x( 'Sending...', 'Email Test Status', 'post-smtp' ),
|
115 |
+
'success' => _x( 'Success', 'Email Test Status', 'post-smtp' ),
|
116 |
+
'failed' => _x( 'Failed', 'Email Test Status', 'post-smtp' ),
|
117 |
+
'ajax_error' => __( 'Ajax Error', 'post-smtp' ),
|
118 |
) );
|
119 |
}
|
120 |
|
123 |
public function outputTestEmailContent() {
|
124 |
print '<div class="wrap">';
|
125 |
|
126 |
+
PostmanViewController::outputChildPageHeader( __( 'Send a Test Email', 'post-smtp' ) );
|
127 |
|
128 |
printf( '<form id="postman_test_email_wizard" method="post" action="%s">', PostmanUtils::getSettingsPageUrl() );
|
129 |
|
130 |
// Step 1
|
131 |
+
printf( '<h5>%s</h5>', __( 'Specify the Recipient', 'post-smtp' ) );
|
132 |
print '<fieldset>';
|
133 |
+
printf( '<legend>%s</legend>', __( 'Who is this message going to?', 'post-smtp' ) );
|
134 |
+
printf( '<p>%s', __( 'This utility allows you to send an email message for testing.', 'post-smtp' ) );
|
135 |
print ' ';
|
136 |
/* translators: where %d is an amount of time, in seconds */
|
137 |
+
printf( '%s</p>', sprintf( _n( 'If there is a problem, Postman will give up after %d second.', 'If there is a problem, Postman will give up after %d seconds.', $this->options->getReadTimeout(), 'post-smtp' ), $this->options->getReadTimeout() ) );
|
138 |
+
printf( '<label for="postman_test_options[test_email]">%s</label>', _x( 'Recipient Email Address', 'Configuration Input Field', 'post-smtp' ) );
|
139 |
print $this->test_email_callback();
|
140 |
print '</fieldset>';
|
141 |
|
142 |
// Step 2
|
143 |
+
printf( '<h5>%s</h5>', __( 'Send The Message', 'post-smtp' ) );
|
144 |
print '<fieldset>';
|
145 |
print '<legend>';
|
146 |
+
print __( 'Sending the message:', 'post-smtp' );
|
147 |
+
printf( ' <span id="postman_test_message_status">%s</span>', _x( 'In Outbox', 'Email Test Status', 'post-smtp' ) );
|
148 |
print '</legend>';
|
149 |
print '<section>';
|
150 |
+
printf( '<p><label>%s</label></p>', __( 'Status', 'post-smtp' ) );
|
151 |
print '<textarea id="postman_test_message_error_message" readonly="readonly" cols="65" rows="4"></textarea>';
|
152 |
print '</section>';
|
153 |
print '</fieldset>';
|
154 |
|
155 |
// Step 3
|
156 |
+
printf( '<h5>%s</h5>', __( 'Session Transcript', 'post-smtp' ) );
|
157 |
print '<fieldset>';
|
158 |
+
printf( '<legend>%s</legend>', __( 'Examine the Session Transcript if you need to.', 'post-smtp' ) );
|
159 |
+
printf( '<p>%s</p>', __( 'This is the conversation between Postman and the mail server. It can be useful for diagnosing problems. <b>DO NOT</b> post it on-line, it may contain your account password.', 'post-smtp' ) );
|
160 |
print '<section>';
|
161 |
+
printf( '<p><label for="postman_test_message_transcript">%s</label></p>', __( 'Session Transcript', 'post-smtp' ) );
|
162 |
print '<textarea readonly="readonly" id="postman_test_message_transcript" cols="65" rows="8"></textarea>';
|
163 |
print '</section>';
|
164 |
print '</fieldset>';
|
206 |
$serverName = PostmanUtils::postmanGetServerName();
|
207 |
|
208 |
/* translators: where %s is the domain name of the site */
|
209 |
+
$subject = sprintf( _x( 'Postman SMTP Test (%s)', 'Test Email Subject', 'post-smtp' ), $serverName );
|
210 |
|
211 |
// Postman API: indicate to Postman this is just for testing
|
212 |
add_filter( 'postman_test_email', array(
|
236 |
if ( $success ) {
|
237 |
$this->logger->debug( 'Test Email delivered to server' );
|
238 |
// the message was sent successfully, generate an appropriate message for the user
|
239 |
+
$statusMessage = sprintf( __( 'Your message was delivered (%d ms) to the SMTP server! Congratulations :)', 'post-smtp' ), $result ['time'] );
|
240 |
|
241 |
$this->logger->debug( 'statusmessage: ' . $statusMessage );
|
242 |
|
292 |
// English - Mandarin - French - Hindi - Spanish - Portuguese - Russian - Japanese
|
293 |
// http://www.pinyin.info/tools/converter/chars2uninumbers.html
|
294 |
$greeting = 'Hello! - 你好 - Bonjour! - नमस्ते - ¡Hola! - Olá - Привет! - 今日は';
|
295 |
+
$sentBy = sprintf( _x( 'Sent by Postman %s', 'Test Email Tagline', 'post-smtp' ), $pluginData ['version'] );
|
296 |
+
$imageSource = __( 'Image source', 'post-smtp' );
|
297 |
+
$withPermission = __( 'Used with permission', 'post-smtp' );
|
298 |
$messageArray = array(
|
299 |
'Content-Type: text/plain; charset = "UTF-8"',
|
300 |
'Content-Transfer-Encoding: 8bit',
|
Postman/Postman.php
CHANGED
@@ -19,6 +19,14 @@ class Postman {
|
|
19 |
const ADMINISTRATOR_ROLE_NAME = 'administrator';
|
20 |
const MANAGE_POSTMAN_CAPABILITY_NAME = 'manage_postman_smtp';
|
21 |
const MANAGE_POSTMAN_CAPABILITY_LOGS = 'manage_postman_logs';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
const TEXT_DOMAIN = 'post-smtp';
|
23 |
|
24 |
private $logger;
|
@@ -30,7 +38,7 @@ class Postman {
|
|
30 |
/**
|
31 |
* The constructor
|
32 |
*
|
33 |
-
* @param
|
34 |
* - the __FILE__ of the caller
|
35 |
*/
|
36 |
public function __construct( $rootPluginFilenameAndPath, $version ) {
|
@@ -56,11 +64,12 @@ class Postman {
|
|
56 |
require_once 'Postman-Email-Log/PostmanEmailLogPostType.php';
|
57 |
require_once 'Postman-Mail/PostmanMyMailConnector.php';
|
58 |
require_once 'Postman-Mail/PostmanContactForm7.php';
|
|
|
59 |
//require_once 'Postman-Mail/PostmanWooCommerce.php';
|
60 |
|
61 |
// get plugin metadata - alternative to get_plugin_data
|
62 |
$this->pluginData = array(
|
63 |
-
'name' => __( 'Postman SMTP',
|
64 |
'version' => $version,
|
65 |
);
|
66 |
|
@@ -83,13 +92,21 @@ class Postman {
|
|
83 |
// register the email transports
|
84 |
$this->registerTransports( $rootPluginFilenameAndPath );
|
85 |
|
86 |
-
|
87 |
-
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
// registers the custom post type for all callers
|
95 |
PostmanEmailLogPostType::automaticallyCreatePostType();
|
@@ -163,9 +180,9 @@ class Postman {
|
|
163 |
|
164 |
public function post_smtp_wpml_admin_notice() {
|
165 |
$class = 'notice notice-error';
|
166 |
-
$title = __( 'Post SMTP notice!',
|
167 |
-
$intro = __( 'WPML is installed and has a known bug with Post SMTP and few other plugins - you better upgrade, but we can try to fix it.',
|
168 |
-
$text = __( 'Click here to fix',
|
169 |
$message = '<br><a href="' . esc_url( add_query_arg( 'action', 'postman_fix_wpml', get_permalink() ) ) . '">' . $text . '</a>';
|
170 |
|
171 |
printf( '<div class="%1$s"><h2>%2$s</h2><p>%3$s</p><p>%4$s</p></div>', esc_attr( $class ), $title, $intro, $message );
|
@@ -305,7 +322,8 @@ class Postman {
|
|
305 |
// I've adopted their error message as well, for shits and giggles .... :D
|
306 |
$reflFunc = new ReflectionFunction( 'wp_mail' );
|
307 |
|
308 |
-
$message = __( 'Postman: wp_mail has been declared by another plugin or theme, so you won\'t be able to use Postman until the conflict is resolved.',
|
|
|
309 |
$plugin_full_path = $reflFunc->getFileName();
|
310 |
|
311 |
if ( strpos( $plugin_full_path, 'plugins' ) !== false ) {
|
@@ -323,6 +341,12 @@ class Postman {
|
|
323 |
}
|
324 |
|
325 |
$message .= '<br><strong>More info that may help</strong> - ' . $reflFunc->getFileName() . ':' . $reflFunc->getStartLine();
|
|
|
|
|
|
|
|
|
|
|
|
|
326 |
$this->messageHandler->addError( $message );
|
327 |
}
|
328 |
} else {
|
@@ -359,6 +383,25 @@ class Postman {
|
|
359 |
}
|
360 |
}
|
361 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
/**
|
363 |
* Returns the plugin version number and name
|
364 |
* Part of the Postman API
|
@@ -382,8 +425,8 @@ class Postman {
|
|
382 |
}
|
383 |
$msg = PostmanTransportRegistry::getInstance()->getReadyMessage();
|
384 |
$message = sprintf( $msg['message'] );
|
385 |
-
$goToSettings = sprintf( '<a href="%s">%s</a>', PostmanUtils::getSettingsPageUrl(), __( 'Settings',
|
386 |
-
$goToEmailLog = sprintf( '%s', _x( 'Email Log', 'The log of Emails that have been delivered',
|
387 |
if ( PostmanOptions::getInstance()->isMailLoggingEnabled() ) {
|
388 |
$goToEmailLog = sprintf( '<a href="%s">%s</a>', PostmanUtils::getEmailLogPageUrl(), $goToEmailLog );
|
389 |
}
|
@@ -404,15 +447,19 @@ class Postman {
|
|
404 |
* The Gmail API used to be a separate plugin which was registered when that plugin
|
405 |
* was loaded. But now both the SMTP, Gmail API and other transports are registered here.
|
406 |
*
|
407 |
-
* @param
|
408 |
*/
|
409 |
private function registerTransports( $rootPluginFilenameAndPath ) {
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
|
|
|
|
|
|
|
|
416 |
}
|
417 |
|
418 |
/**
|
@@ -433,12 +480,12 @@ class Postman {
|
|
433 |
$shortLocale = substr( get_locale(), 0, 2 );
|
434 |
if ( $shortLocale != 'en' ) {
|
435 |
$langDir = 'post-smtp/Postman/languages';
|
436 |
-
$success = load_plugin_textdomain(
|
437 |
if ( $this->logger->isDebug() ) {
|
438 |
if ( $success ) {
|
439 |
$this->logger->debug( sprintf( 'local translation file loaded for locale=%s', get_locale() ) );
|
440 |
} else {
|
441 |
-
$this->logger->debug( sprintf( 'failed to load local translation file: locale=%s file=%s/%s-%s.mo', get_locale(), $langDir,
|
442 |
}
|
443 |
}
|
444 |
}
|
@@ -460,7 +507,7 @@ if ( ! function_exists( 'str_getcsv' ) ) {
|
|
460 |
/**
|
461 |
* PHP version less than 5.3 don't have str_getcsv natively.
|
462 |
*
|
463 |
-
* @param
|
464 |
* @return multitype:
|
465 |
*/
|
466 |
function str_getcsv( $string ) {
|
19 |
const ADMINISTRATOR_ROLE_NAME = 'administrator';
|
20 |
const MANAGE_POSTMAN_CAPABILITY_NAME = 'manage_postman_smtp';
|
21 |
const MANAGE_POSTMAN_CAPABILITY_LOGS = 'manage_postman_logs';
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Use the text domain directly instead of this constant, as it
|
25 |
+
* causes issues with https://translate.wordpress.org.
|
26 |
+
*
|
27 |
+
* @deprecated
|
28 |
+
* @see https://github.com/yehudah/Post-SMTP/issues/1#issuecomment-421940923
|
29 |
+
*/
|
30 |
const TEXT_DOMAIN = 'post-smtp';
|
31 |
|
32 |
private $logger;
|
38 |
/**
|
39 |
* The constructor
|
40 |
*
|
41 |
+
* @param mixed $rootPluginFilenameAndPath
|
42 |
* - the __FILE__ of the caller
|
43 |
*/
|
44 |
public function __construct( $rootPluginFilenameAndPath, $version ) {
|
64 |
require_once 'Postman-Email-Log/PostmanEmailLogPostType.php';
|
65 |
require_once 'Postman-Mail/PostmanMyMailConnector.php';
|
66 |
require_once 'Postman-Mail/PostmanContactForm7.php';
|
67 |
+
require_once 'Phpmailer/PostsmtpMailer.php';
|
68 |
//require_once 'Postman-Mail/PostmanWooCommerce.php';
|
69 |
|
70 |
// get plugin metadata - alternative to get_plugin_data
|
71 |
$this->pluginData = array(
|
72 |
+
'name' => __( 'Postman SMTP', 'post-smtp' ),
|
73 |
'version' => $version,
|
74 |
);
|
75 |
|
92 |
// register the email transports
|
93 |
$this->registerTransports( $rootPluginFilenameAndPath );
|
94 |
|
95 |
+
// store an instance of the WpMailBinder
|
96 |
+
$this->wpMailBinder = PostmanWpMailBinder::getInstance();
|
97 |
|
98 |
+
$mailer = PostmanOptions::getInstance()->getSmtpMailer();
|
99 |
+
$this->logger->trace( 'SMTP Mailer: ' . $mailer );
|
100 |
+
|
101 |
+
if ( $mailer && $mailer !== 'phpmailer') {
|
102 |
+
|
103 |
+
// bind to wp_mail - this has to happen before the "init" action
|
104 |
+
// this design allows other plugins to register a Postman transport and call bind()
|
105 |
+
// bind may be called more than once
|
106 |
+
$this->wpMailBinder->bind();
|
107 |
+
} else {
|
108 |
+
PostmanWpMailBinder::getInstance()->bound = true;
|
109 |
+
}
|
110 |
|
111 |
// registers the custom post type for all callers
|
112 |
PostmanEmailLogPostType::automaticallyCreatePostType();
|
180 |
|
181 |
public function post_smtp_wpml_admin_notice() {
|
182 |
$class = 'notice notice-error';
|
183 |
+
$title = __( 'Post SMTP notice!', 'post-smtp' );
|
184 |
+
$intro = __( 'WPML is installed and has a known bug with Post SMTP and few other plugins - you better upgrade, but we can try to fix it.', 'post-smtp' );
|
185 |
+
$text = __( 'Click here to fix', 'post-smtp' );
|
186 |
$message = '<br><a href="' . esc_url( add_query_arg( 'action', 'postman_fix_wpml', get_permalink() ) ) . '">' . $text . '</a>';
|
187 |
|
188 |
printf( '<div class="%1$s"><h2>%2$s</h2><p>%3$s</p><p>%4$s</p></div>', esc_attr( $class ), $title, $intro, $message );
|
322 |
// I've adopted their error message as well, for shits and giggles .... :D
|
323 |
$reflFunc = new ReflectionFunction( 'wp_mail' );
|
324 |
|
325 |
+
$message = __( 'Postman: wp_mail has been declared by another plugin or theme, so you won\'t be able to use Postman until the conflict is resolved.', 'post-smtp' );
|
326 |
+
|
327 |
$plugin_full_path = $reflFunc->getFileName();
|
328 |
|
329 |
if ( strpos( $plugin_full_path, 'plugins' ) !== false ) {
|
341 |
}
|
342 |
|
343 |
$message .= '<br><strong>More info that may help</strong> - ' . $reflFunc->getFileName() . ':' . $reflFunc->getStartLine();
|
344 |
+
|
345 |
+
// PHPmailer Recommandation
|
346 |
+
ob_start();
|
347 |
+
Postman::getMailerTypeRecommend();
|
348 |
+
$message .= ob_get_clean();
|
349 |
+
|
350 |
$this->messageHandler->addError( $message );
|
351 |
}
|
352 |
} else {
|
383 |
}
|
384 |
}
|
385 |
|
386 |
+
public static function getMailerTypeRecommend() {
|
387 |
+
?>
|
388 |
+
<div>
|
389 |
+
<p style="font-size: 18px; font-weight: bold;">Please notice</p>
|
390 |
+
<p style="font-size: 14px; line-height: 1.7;">
|
391 |
+
<?php _e('Post SMTP v2 includes and new feature called: <b>Mailer Type</b>.', 'post-smtp' ); ?><br>
|
392 |
+
<?php _e('I highly recommend to change and <strong>TEST</strong> Post SMTP with the value <code>PHPMailer</code>.', 'post-smtp' ); ?><br>
|
393 |
+
<?php _e('if it will not work properly you can change back to the default value: <code>PostSMTP</code>.', 'post-smtp' ); ?><br>
|
394 |
+
<a target="_blank" href="<?php echo POST_URL; ?>/style/images/mailer-type.gif">
|
395 |
+
<figure>
|
396 |
+
<img width="180" src="<?php echo POST_URL; ?>/style/images/mailer-type.gif" alt="how to set mailer type">
|
397 |
+
<figcaption><?php _e('click to enlarge image.', 'post-smtp' ); ?></figcaption>
|
398 |
+
</figure>
|
399 |
+
</a>
|
400 |
+
</p>
|
401 |
+
</div>
|
402 |
+
<?php
|
403 |
+
}
|
404 |
+
|
405 |
/**
|
406 |
* Returns the plugin version number and name
|
407 |
* Part of the Postman API
|
425 |
}
|
426 |
$msg = PostmanTransportRegistry::getInstance()->getReadyMessage();
|
427 |
$message = sprintf( $msg['message'] );
|
428 |
+
$goToSettings = sprintf( '<a href="%s">%s</a>', PostmanUtils::getSettingsPageUrl(), __( 'Settings', 'post-smtp' ) );
|
429 |
+
$goToEmailLog = sprintf( '%s', _x( 'Email Log', 'The log of Emails that have been delivered', 'post-smtp' ) );
|
430 |
if ( PostmanOptions::getInstance()->isMailLoggingEnabled() ) {
|
431 |
$goToEmailLog = sprintf( '<a href="%s">%s</a>', PostmanUtils::getEmailLogPageUrl(), $goToEmailLog );
|
432 |
}
|
447 |
* The Gmail API used to be a separate plugin which was registered when that plugin
|
448 |
* was loaded. But now both the SMTP, Gmail API and other transports are registered here.
|
449 |
*
|
450 |
+
* @param mixed $pluginData
|
451 |
*/
|
452 |
private function registerTransports( $rootPluginFilenameAndPath ) {
|
453 |
+
$postman_transport_registry = PostmanTransportRegistry::getInstance();
|
454 |
+
|
455 |
+
$postman_transport_registry->registerTransport( new PostmanDefaultModuleTransport( $rootPluginFilenameAndPath ) );
|
456 |
+
$postman_transport_registry->registerTransport( new PostmanSmtpModuleTransport( $rootPluginFilenameAndPath ) );
|
457 |
+
$postman_transport_registry->registerTransport( new PostmanGmailApiModuleTransport( $rootPluginFilenameAndPath ) );
|
458 |
+
$postman_transport_registry->registerTransport( new PostmanMandrillTransport( $rootPluginFilenameAndPath ) );
|
459 |
+
$postman_transport_registry->registerTransport( new PostmanSendGridTransport( $rootPluginFilenameAndPath ) );
|
460 |
+
$postman_transport_registry->registerTransport( new PostmanMailgunTransport( $rootPluginFilenameAndPath ) );
|
461 |
+
|
462 |
+
do_action( 'postsmtp_register_transport', $postman_transport_registry );
|
463 |
}
|
464 |
|
465 |
/**
|
480 |
$shortLocale = substr( get_locale(), 0, 2 );
|
481 |
if ( $shortLocale != 'en' ) {
|
482 |
$langDir = 'post-smtp/Postman/languages';
|
483 |
+
$success = load_plugin_textdomain( 'post-smtp', false, $langDir );
|
484 |
if ( $this->logger->isDebug() ) {
|
485 |
if ( $success ) {
|
486 |
$this->logger->debug( sprintf( 'local translation file loaded for locale=%s', get_locale() ) );
|
487 |
} else {
|
488 |
+
$this->logger->debug( sprintf( 'failed to load local translation file: locale=%s file=%s/%s-%s.mo', get_locale(), $langDir, 'post-smtp', get_locale() ) );
|
489 |
}
|
490 |
}
|
491 |
}
|
507 |
/**
|
508 |
* PHP version less than 5.3 don't have str_getcsv natively.
|
509 |
*
|
510 |
+
* @param mixed $string
|
511 |
* @return multitype:
|
512 |
*/
|
513 |
function str_getcsv( $string ) {
|
Postman/PostmanAdminController.php
CHANGED
@@ -78,7 +78,7 @@ if ( ! class_exists( 'PostmanAdminController' ) ) {
|
|
78 |
/**
|
79 |
* Constructor
|
80 |
*
|
81 |
-
* @param
|
82 |
* @param PostmanOptions $options
|
83 |
* @param PostmanOAuthToken $authorizationToken
|
84 |
* @param PostmanMessageHandler $messageHandler
|
@@ -111,7 +111,7 @@ if ( ! class_exists( 'PostmanAdminController' ) ) {
|
|
111 |
// do a redirect on the init hook
|
112 |
$this->registerInitFunction( 'handleSuccessfulSave' );
|
113 |
// add a saved message to be shown after the redirect
|
114 |
-
$this->messageHandler->addMessage( _x( 'Settings saved.', 'The plugin successfully saved new settings.',
|
115 |
return;
|
116 |
} else {
|
117 |
// unset the action in the failed case as well
|
@@ -162,11 +162,11 @@ if ( ! class_exists( 'PostmanAdminController' ) ) {
|
|
162 |
?>
|
163 |
<input type="hidden" name="<?php echo PostmanOptions::POSTMAN_NETWORK_OPTIONS; ?>[post_smtp_global_settings]" value="null">
|
164 |
<input type="hidden" name="<?php echo PostmanOptions::POSTMAN_NETWORK_OPTIONS; ?>[post_smtp_allow_overwrite]" value="null">
|
165 |
-
<h2><?php _e( 'Post SMTP Settings',
|
166 |
<table id="menu" class="form-table">
|
167 |
<tr>
|
168 |
<th scope="row">
|
169 |
-
<?php _e( 'Enable global settings',
|
170 |
</th>
|
171 |
<td>
|
172 |
<?php $checked = checked( $options['post_smtp_global_settings'], 1, false ); ?>
|
@@ -177,14 +177,14 @@ if ( ! class_exists( 'PostmanAdminController' ) ) {
|
|
177 |
<?php echo $checked; ?>
|
178 |
>
|
179 |
<p class="description">
|
180 |
-
<?php _e('Same settings as the main site/blog (id:1)',
|
181 |
</p>
|
182 |
</label>
|
183 |
</td>
|
184 |
</tr>
|
185 |
<tr>
|
186 |
<th scope="row">
|
187 |
-
<?php _e( 'Allow user to load saved options',
|
188 |
</th>
|
189 |
<td>
|
190 |
<?php $checked = checked( $options['post_smtp_allow_overwrite'], 1, false ); ?>
|
@@ -252,7 +252,7 @@ if ( ! class_exists( 'PostmanAdminController' ) ) {
|
|
252 |
foreach ( $states as $state ) {
|
253 |
if ( ! $state ['ready'] ) {
|
254 |
/* Translators: where %1$s is the name of the library */
|
255 |
-
$message = sprintf( __( 'This PHP installation requires the <b>%1$s</b> library.',
|
256 |
if ( $state ['required'] ) {
|
257 |
$this->messageHandler->addError( $message );
|
258 |
} else {
|
@@ -264,8 +264,8 @@ if ( ! class_exists( 'PostmanAdminController' ) ) {
|
|
264 |
|
265 |
/**
|
266 |
*
|
267 |
-
* @param
|
268 |
-
* @param
|
269 |
*/
|
270 |
private function registerInitFunction( $callbackName ) {
|
271 |
$this->logger->debug( 'Registering init function ' . $callbackName );
|
@@ -278,8 +278,8 @@ if ( ! class_exists( 'PostmanAdminController' ) ) {
|
|
278 |
/**
|
279 |
* Registers actions posted by am HTML FORM with the WordPress 'action' parameter
|
280 |
*
|
281 |
-
* @param
|
282 |
-
* @param
|
283 |
*/
|
284 |
private function registerAdminPostAction( $actionName, $callbankName ) {
|
285 |
// $this->logger->debug ( 'Registering ' . $actionName . ' Action Post handler' );
|
@@ -292,15 +292,16 @@ if ( ! class_exists( 'PostmanAdminController' ) ) {
|
|
292 |
/**
|
293 |
* Add "Settings" link to the plugin action page
|
294 |
*
|
295 |
-
* @param
|
296 |
* @return multitype:
|
297 |
*/
|
298 |
public function postmanModifyLinksOnPluginsListPage( $links ) {
|
299 |
// only administrators should be able to trigger this
|
300 |
if ( PostmanUtils::isAdmin() ) {
|
301 |
$mylinks = array(
|
302 |
-
|
303 |
-
sprintf( '<a href="%s" class="postman_settings">%s</a>',
|
|
|
304 |
);
|
305 |
return array_merge( $mylinks, $links );
|
306 |
}
|
@@ -328,7 +329,7 @@ if ( ! class_exists( 'PostmanAdminController' ) ) {
|
|
328 |
$success = false;
|
329 |
}
|
330 |
if ( ! $success ) {
|
331 |
-
$this->messageHandler->addError( __( 'There was an error importing the data.',
|
332 |
$this->logger->error( 'There was an error importing the data' );
|
333 |
}
|
334 |
PostmanUtils::redirect( PostmanUtils::POSTMAN_HOME_PAGE_RELATIVE_URL );
|
@@ -345,7 +346,7 @@ if ( ! class_exists( 'PostmanAdminController' ) ) {
|
|
345 |
delete_option( PostmanAdminController::TEST_OPTIONS );
|
346 |
$logPurger = new PostmanEmailLogPurger();
|
347 |
$logPurger->removeAll();
|
348 |
-
$this->messageHandler->addMessage( __( 'Plugin data was removed.',
|
349 |
PostmanUtils::redirect( PostmanUtils::POSTMAN_HOME_PAGE_RELATIVE_URL );
|
350 |
}
|
351 |
}
|
@@ -369,16 +370,16 @@ if ( ! class_exists( 'PostmanAdminController' ) ) {
|
|
369 |
$logger->debug( 'Authorization successful' );
|
370 |
// save to database
|
371 |
$authorizationToken->save();
|
372 |
-
$this->messageHandler->addMessage( __( 'The OAuth 2.0 authorization was successful. Ready to send e-mail.',
|
373 |
} else {
|
374 |
-
$this->messageHandler->addError( __( 'Your email provider did not grant Postman permission. Try again.',
|
375 |
}
|
376 |
} catch ( PostmanStateIdMissingException $e ) {
|
377 |
-
$this->messageHandler->addError( __( 'The grant code from Google had no accompanying state and may be a forgery',
|
378 |
} catch ( Exception $e ) {
|
379 |
$logger->error( 'Error: ' . get_class( $e ) . ' code=' . $e->getCode() . ' message=' . $e->getMessage() );
|
380 |
/* translators: %s is the error message */
|
381 |
-
$this->messageHandler->addError( sprintf( __( 'Error authenticating with this Client ID. [%s]',
|
382 |
}
|
383 |
|
384 |
// clean-up
|
78 |
/**
|
79 |
* Constructor
|
80 |
*
|
81 |
+
* @param mixed $rootPluginFilenameAndPath
|
82 |
* @param PostmanOptions $options
|
83 |
* @param PostmanOAuthToken $authorizationToken
|
84 |
* @param PostmanMessageHandler $messageHandler
|
111 |
// do a redirect on the init hook
|
112 |
$this->registerInitFunction( 'handleSuccessfulSave' );
|
113 |
// add a saved message to be shown after the redirect
|
114 |
+
$this->messageHandler->addMessage( _x( 'Settings saved.', 'The plugin successfully saved new settings.', 'post-smtp' ) );
|
115 |
return;
|
116 |
} else {
|
117 |
// unset the action in the failed case as well
|
162 |
?>
|
163 |
<input type="hidden" name="<?php echo PostmanOptions::POSTMAN_NETWORK_OPTIONS; ?>[post_smtp_global_settings]" value="null">
|
164 |
<input type="hidden" name="<?php echo PostmanOptions::POSTMAN_NETWORK_OPTIONS; ?>[post_smtp_allow_overwrite]" value="null">
|
165 |
+
<h2><?php _e( 'Post SMTP Settings', 'post-smtp' ); ?></h2>
|
166 |
<table id="menu" class="form-table">
|
167 |
<tr>
|
168 |
<th scope="row">
|
169 |
+
<?php _e( 'Enable global settings', 'post-smtp' ); ?>
|
170 |
</th>
|
171 |
<td>
|
172 |
<?php $checked = checked( $options['post_smtp_global_settings'], 1, false ); ?>
|
177 |
<?php echo $checked; ?>
|
178 |
>
|
179 |
<p class="description">
|
180 |
+
<?php _e('Same settings as the main site/blog (id:1)', 'post-smtp' ); ?>
|
181 |
</p>
|
182 |
</label>
|
183 |
</td>
|
184 |
</tr>
|
185 |
<tr>
|
186 |
<th scope="row">
|
187 |
+
<?php _e( 'Allow user to load saved options', 'post-smtp' ); ?>
|
188 |
</th>
|
189 |
<td>
|
190 |
<?php $checked = checked( $options['post_smtp_allow_overwrite'], 1, false ); ?>
|
252 |
foreach ( $states as $state ) {
|
253 |
if ( ! $state ['ready'] ) {
|
254 |
/* Translators: where %1$s is the name of the library */
|
255 |
+
$message = sprintf( __( 'This PHP installation requires the <b>%1$s</b> library.', 'post-smtp' ), $state ['name'] );
|
256 |
if ( $state ['required'] ) {
|
257 |
$this->messageHandler->addError( $message );
|
258 |
} else {
|
264 |
|
265 |
/**
|
266 |
*
|
267 |
+
* @param mixed $actionName
|
268 |
+
* @param mixed $callbackName
|
269 |
*/
|
270 |
private function registerInitFunction( $callbackName ) {
|
271 |
$this->logger->debug( 'Registering init function ' . $callbackName );
|
278 |
/**
|
279 |
* Registers actions posted by am HTML FORM with the WordPress 'action' parameter
|
280 |
*
|
281 |
+
* @param mixed $actionName
|
282 |
+
* @param mixed $callbankName
|
283 |
*/
|
284 |
private function registerAdminPostAction( $actionName, $callbankName ) {
|
285 |
// $this->logger->debug ( 'Registering ' . $actionName . ' Action Post handler' );
|
292 |
/**
|
293 |
* Add "Settings" link to the plugin action page
|
294 |
*
|
295 |
+
* @param mixed $links
|
296 |
* @return multitype:
|
297 |
*/
|
298 |
public function postmanModifyLinksOnPluginsListPage( $links ) {
|
299 |
// only administrators should be able to trigger this
|
300 |
if ( PostmanUtils::isAdmin() ) {
|
301 |
$mylinks = array(
|
302 |
+
sprintf( '<a href="%s" target="_blank" class="postman_settings">%s</a>', 'https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=yehuda@myinbox.in&item_name=Donation+for+PostSMTP', __( 'Donate', 'post-smtp' ) ),
|
303 |
+
sprintf( '<a href="%s" class="postman_settings">%s</a>', PostmanUtils::getSettingsPageUrl(), __( 'Settings', 'post-smtp' ) ),
|
304 |
+
sprintf( '<a href="%s" class="postman_settings">%s</a>', 'https://postmansmtp.com', __( 'Visit us', 'post-smtp' ) ),
|
305 |
);
|
306 |
return array_merge( $mylinks, $links );
|
307 |
}
|
329 |
$success = false;
|
330 |
}
|
331 |
if ( ! $success ) {
|
332 |
+
$this->messageHandler->addError( __( 'There was an error importing the data.', 'post-smtp' ) );
|
333 |
$this->logger->error( 'There was an error importing the data' );
|
334 |
}
|
335 |
PostmanUtils::redirect( PostmanUtils::POSTMAN_HOME_PAGE_RELATIVE_URL );
|
346 |
delete_option( PostmanAdminController::TEST_OPTIONS );
|
347 |
$logPurger = new PostmanEmailLogPurger();
|
348 |
$logPurger->removeAll();
|
349 |
+
$this->messageHandler->addMessage( __( 'Plugin data was removed.', 'post-smtp' ) );
|
350 |
PostmanUtils::redirect( PostmanUtils::POSTMAN_HOME_PAGE_RELATIVE_URL );
|
351 |
}
|
352 |
}
|
370 |
$logger->debug( 'Authorization successful' );
|
371 |
// save to database
|
372 |
$authorizationToken->save();
|
373 |
+
$this->messageHandler->addMessage( __( 'The OAuth 2.0 authorization was successful. Ready to send e-mail.', 'post-smtp' ) );
|
374 |
} else {
|
375 |
+
$this->messageHandler->addError( __( 'Your email provider did not grant Postman permission. Try again.', 'post-smtp' ) );
|
376 |
}
|
377 |
} catch ( PostmanStateIdMissingException $e ) {
|
378 |
+
$this->messageHandler->addError( __( 'The grant code from Google had no accompanying state and may be a forgery', 'post-smtp' ) );
|
379 |
} catch ( Exception $e ) {
|
380 |
$logger->error( 'Error: ' . get_class( $e ) . ' code=' . $e->getCode() . ' message=' . $e->getMessage() );
|
381 |
/* translators: %s is the error message */
|
382 |
+
$this->messageHandler->addError( sprintf( __( 'Error authenticating with this Client ID. [%s]', 'post-smtp' ), '<em>' . $e->getMessage() . '</em>' ) );
|
383 |
}
|
384 |
|
385 |
// clean-up
|
Postman/PostmanAjaxController.php
CHANGED
@@ -15,8 +15,8 @@ if (! class_exists ( 'PostmanAbstractAjaxHandler' )) {
|
|
15 |
}
|
16 |
/**
|
17 |
*
|
18 |
-
* @param
|
19 |
-
* @param
|
20 |
*/
|
21 |
protected function registerAjaxHandler($actionName, $class, $callbackName) {
|
22 |
if (is_admin ()) {
|
@@ -31,7 +31,7 @@ if (! class_exists ( 'PostmanAbstractAjaxHandler' )) {
|
|
31 |
|
32 |
/**
|
33 |
*
|
34 |
-
* @param
|
35 |
* @return mixed
|
36 |
*/
|
37 |
protected function getBooleanRequestParameter($parameterName) {
|
@@ -40,8 +40,8 @@ if (! class_exists ( 'PostmanAbstractAjaxHandler' )) {
|
|
40 |
|
41 |
/**
|
42 |
*
|
43 |
-
* @param
|
44 |
-
* @return
|
45 |
*/
|
46 |
protected function getRequestParameter($parameterName) {
|
47 |
if (isset ( $_POST [$parameterName] )) {
|
15 |
}
|
16 |
/**
|
17 |
*
|
18 |
+
* @param mixed $actionName
|
19 |
+
* @param mixed $callbackName
|
20 |
*/
|
21 |
protected function registerAjaxHandler($actionName, $class, $callbackName) {
|
22 |
if (is_admin ()) {
|
31 |
|
32 |
/**
|
33 |
*
|
34 |
+
* @param mixed $parameterName
|
35 |
* @return mixed
|
36 |
*/
|
37 |
protected function getBooleanRequestParameter($parameterName) {
|
40 |
|
41 |
/**
|
42 |
*
|
43 |
+
* @param mixed $parameterName
|
44 |
+
* @return mixed
|
45 |
*/
|
46 |
protected function getRequestParameter($parameterName) {
|
47 |
if (isset ( $_POST [$parameterName] )) {
|
Postman/PostmanConfigTextHelper.php
CHANGED
@@ -28,8 +28,8 @@ if ( ! class_exists( 'PostmanAbstractConfigTextHelper' ) ) {
|
|
28 |
*/
|
29 |
abstract class PostmanAbstractConfigTextHelper implements PostmanConfigTextHelper {
|
30 |
public function getOAuthHelp() {
|
31 |
-
$attention = __( 'Attention',
|
32 |
-
$errorMessage = sprintf( __('Check this article how to configure Gmail/Gsuite OAuth:<a href="%1$s" target="_blank">Read Here</a>',
|
33 |
$text = sprintf( '<b style="color:red">%s!</b> %s', $attention, $errorMessage );
|
34 |
|
35 |
return $text;
|
@@ -48,7 +48,7 @@ if ( ! class_exists( 'PostmanAbstractConfigTextHelper' ) ) {
|
|
48 |
}
|
49 |
public function getRequestPermissionLinkText() {
|
50 |
/* translators: where %s is the Email Service Owner (e.g. Google, Microsoft or Yahoo) */
|
51 |
-
return sprintf( _x( 'Grant permission with %s', 'Command to initiate OAuth authentication',
|
52 |
}
|
53 |
}
|
54 |
}
|
@@ -74,35 +74,35 @@ if ( ! class_exists( 'PostmanGoogleOAuthScribe' ) ) {
|
|
74 |
}
|
75 |
public function getClientIdLabel() {
|
76 |
/* Translators: This description is specific to Google */
|
77 |
-
return _x( 'Client ID', 'Name of the OAuth 2.0 Client ID',
|
78 |
}
|
79 |
public function getClientSecretLabel() {
|
80 |
/* Translators: This description is specific to Google */
|
81 |
-
return _x( 'Client Secret', 'Name of the OAuth 2.0 Client Secret',
|
82 |
}
|
83 |
public function getCallbackUrlLabel() {
|
84 |
/* Translators: This description is specific to Google */
|
85 |
-
return _x( 'Authorized redirect URI', 'Name of the Application Callback URI',
|
86 |
}
|
87 |
public function getCallbackDomainLabel() {
|
88 |
/* Translators: This description is specific to Google */
|
89 |
-
return _x( 'Authorized JavaScript origins', 'Name of the Application Callback Domain',
|
90 |
}
|
91 |
public function getOwnerName() {
|
92 |
/* Translators: This description is specific to Google */
|
93 |
-
return _x( 'Google', 'Name of the email service owner',
|
94 |
}
|
95 |
public function getServiceName() {
|
96 |
/* Translators: This description is specific to Google */
|
97 |
-
return _x( 'Gmail', 'Name of the email service',
|
98 |
}
|
99 |
public function getApplicationDescription() {
|
100 |
/* Translators: This description is specific to Google */
|
101 |
-
return _x( 'a Client ID for web application', 'Description of the email service OAuth 2.0 Application',
|
102 |
}
|
103 |
public function getApplicationPortalName() {
|
104 |
/* Translators: This description is specific to Google */
|
105 |
-
return _x( 'Google Developers Console Gmail Wizard', 'Name of the email service portal',
|
106 |
}
|
107 |
public function getApplicationPortalUrl() {
|
108 |
return 'https://www.google.com/accounts/Logout?continue=https://console.developers.google.com/start/api?id=gmail';
|
@@ -136,35 +136,35 @@ if ( ! class_exists( 'PostmanMicrosoftOAuthScribe' ) ) {
|
|
136 |
}
|
137 |
public function getClientIdLabel() {
|
138 |
/* Translators: This description is specific to Microsoft */
|
139 |
-
return _x( 'Client ID', 'Name of the OAuth 2.0 Client ID',
|
140 |
}
|
141 |
public function getClientSecretLabel() {
|
142 |
/* Translators: This description is specific to Microsoft */
|
143 |
-
return _x( 'Client Secret', 'Name of the OAuth 2.0 Client Secret',
|
144 |
}
|
145 |
public function getCallbackUrlLabel() {
|
146 |
/* Translators: This description is specific to Microsoft */
|
147 |
-
return _x( 'Redirect URL', 'Name of the Application Callback URI',
|
148 |
}
|
149 |
public function getCallbackDomainLabel() {
|
150 |
/* Translators: This description is specific to Microsoft */
|
151 |
-
return _x( 'Root Domain', 'Name of the Application Callback Domain',
|
152 |
}
|
153 |
public function getOwnerName() {
|
154 |
/* Translators: This description is specific to Microsoft */
|
155 |
-
return _x( 'Microsoft', 'Name of the email service owner',
|
156 |
}
|
157 |
public function getServiceName() {
|
158 |
/* Translators: This description is specific to Microsoft */
|
159 |
-
return _x( 'Outlook.com', 'Name of the email service',
|
160 |
}
|
161 |
public function getApplicationDescription() {
|
162 |
/* Translators: This description is specific to Microsoft */
|
163 |
-
return _x( 'an Application', 'Description of the email service OAuth 2.0 Application',
|
164 |
}
|
165 |
public function getApplicationPortalName() {
|
166 |
/* Translators: This description is specific to Microsoft */
|
167 |
-
return _x( 'Microsoft Developer Center', 'Name of the email service portal',
|
168 |
}
|
169 |
public function getApplicationPortalUrl() {
|
170 |
return 'https://account.live.com/developers/applications/index';
|
@@ -198,35 +198,35 @@ if ( ! class_exists( 'PostmanYahooOAuthScribe' ) ) {
|
|
198 |
}
|
199 |
public function getClientIdLabel() {
|
200 |
/* Translators: This description is specific to Yahoo */
|
201 |
-
return _x( 'Client ID', 'Name of the OAuth 2.0 Client ID',
|
202 |
}
|
203 |
public function getClientSecretLabel() {
|
204 |
/* Translators: This description is specific to Yahoo */
|
205 |
-
return _x( 'Client Secret', 'Name of the OAuth 2.0 Client Secret',
|
206 |
}
|
207 |
public function getCallbackUrlLabel() {
|
208 |
/* Translators: This description is specific to Yahoo */
|
209 |
-
return _x( 'Home Page URL', 'Name of the Application Callback URI',
|
210 |
}
|
211 |
public function getCallbackDomainLabel() {
|
212 |
/* Translators: This description is specific to Yahoo */
|
213 |
-
return _x( 'Callback Domain', 'Name of the Application Callback Domain',
|
214 |
}
|
215 |
public function getOwnerName() {
|
216 |
/* Translators: This description is specific to Yahoo */
|
217 |
-
return _x( 'Yahoo', 'Name of the email service owner',
|
218 |
}
|
219 |
public function getServiceName() {
|
220 |
/* Translators: This description is specific to Yahoo */
|
221 |
-
return _x( 'Yahoo Mail', 'Name of the email service',
|
222 |
}
|
223 |
public function getApplicationDescription() {
|
224 |
/* Translators: This description is specific to Yahoo */
|
225 |
-
return _x( 'an Application', 'Description of the email service OAuth 2.0 Application',
|
226 |
}
|
227 |
public function getApplicationPortalName() {
|
228 |
/* Translators: This description is specific to Yahoo */
|
229 |
-
return _x( 'Yahoo Developer Network', 'Name of the email service portal',
|
230 |
}
|
231 |
public function getApplicationPortalUrl() {
|
232 |
return 'https://developer.yahoo.com/apps/';
|
@@ -255,7 +255,7 @@ if ( ! class_exists( 'PostmanNonOAuthScribe' ) ) {
|
|
255 |
return PostmanUtils::endsWith( $this->hostname, 'yahoo.com' );
|
256 |
}
|
257 |
public function getOAuthHelp() {
|
258 |
-
$text = __( 'Enter an Outgoing Mail Server with OAuth2 capabilities.',
|
259 |
return sprintf( '<span style="color:red" class="normal">%s</span>', $text );
|
260 |
}
|
261 |
public function getCallbackUrl() {
|
@@ -265,16 +265,16 @@ if ( ! class_exists( 'PostmanNonOAuthScribe' ) ) {
|
|
265 |
return '';
|
266 |
}
|
267 |
public function getClientIdLabel() {
|
268 |
-
return _x( 'Client ID', 'Name of the OAuth 2.0 Client ID',
|
269 |
}
|
270 |
public function getClientSecretLabel() {
|
271 |
-
return _x( 'Client Secret', 'Name of the OAuth 2.0 Client Secret',
|
272 |
}
|
273 |
public function getCallbackUrlLabel() {
|
274 |
-
return _x( 'Redirect URI', 'Name of the Application Callback URI',
|
275 |
}
|
276 |
public function getCallbackDomainLabel() {
|
277 |
-
return _x( 'Website Domain', 'Name of the Application Callback Domain',
|
278 |
}
|
279 |
public function getOwnerName() {
|
280 |
return '';
|
@@ -298,7 +298,7 @@ if ( ! class_exists( 'PostmanNonOAuthScribe' ) ) {
|
|
298 |
return '';
|
299 |
}
|
300 |
public function getRequestPermissionLinkText() {
|
301 |
-
return __( 'Grant OAuth 2.0 Permission',
|
302 |
}
|
303 |
}
|
304 |
}
|
28 |
*/
|
29 |
abstract class PostmanAbstractConfigTextHelper implements PostmanConfigTextHelper {
|
30 |
public function getOAuthHelp() {
|
31 |
+
$attention = __( 'Attention', 'post-smtp' );
|
32 |
+
$errorMessage = sprintf( __('Check this article how to configure Gmail/Gsuite OAuth:<a href="%1$s" target="_blank">Read Here</a>', 'post-smtp' ), 'https://postmansmtp.com/how-to-configure-post-smtp-with-gmailgsuite-using-oauth/' );
|
33 |
$text = sprintf( '<b style="color:red">%s!</b> %s', $attention, $errorMessage );
|
34 |
|
35 |
return $text;
|
48 |
}
|
49 |
public function getRequestPermissionLinkText() {
|
50 |
/* translators: where %s is the Email Service Owner (e.g. Google, Microsoft or Yahoo) */
|
51 |
+
return sprintf( _x( 'Grant permission with %s', 'Command to initiate OAuth authentication', 'post-smtp' ), $this->getOwnerName() );
|
52 |
}
|
53 |
}
|
54 |
}
|
74 |
}
|
75 |
public function getClientIdLabel() {
|
76 |
/* Translators: This description is specific to Google */
|
77 |
+
return _x( 'Client ID', 'Name of the OAuth 2.0 Client ID', 'post-smtp' );
|
78 |
}
|
79 |
public function getClientSecretLabel() {
|
80 |
/* Translators: This description is specific to Google */
|
81 |
+
return _x( 'Client Secret', 'Name of the OAuth 2.0 Client Secret', 'post-smtp' );
|
82 |
}
|
83 |
public function getCallbackUrlLabel() {
|
84 |
/* Translators: This description is specific to Google */
|
85 |
+
return _x( 'Authorized redirect URI', 'Name of the Application Callback URI', 'post-smtp' );
|
86 |
}
|
87 |
public function getCallbackDomainLabel() {
|
88 |
/* Translators: This description is specific to Google */
|
89 |
+
return _x( 'Authorized JavaScript origins', 'Name of the Application Callback Domain', 'post-smtp' );
|
90 |
}
|
91 |
public function getOwnerName() {
|
92 |
/* Translators: This description is specific to Google */
|
93 |
+
return _x( 'Google', 'Name of the email service owner', 'post-smtp' );
|
94 |
}
|
95 |
public function getServiceName() {
|
96 |
/* Translators: This description is specific to Google */
|
97 |
+
return _x( 'Gmail', 'Name of the email service', 'post-smtp' );
|
98 |
}
|
99 |
public function getApplicationDescription() {
|
100 |
/* Translators: This description is specific to Google */
|
101 |
+
return _x( 'a Client ID for web application', 'Description of the email service OAuth 2.0 Application', 'post-smtp' );
|
102 |
}
|
103 |
public function getApplicationPortalName() {
|
104 |
/* Translators: This description is specific to Google */
|
105 |
+
return _x( 'Google Developers Console Gmail Wizard', 'Name of the email service portal', 'post-smtp' );
|
106 |
}
|
107 |
public function getApplicationPortalUrl() {
|
108 |
return 'https://www.google.com/accounts/Logout?continue=https://console.developers.google.com/start/api?id=gmail';
|
136 |
}
|
137 |
public function getClientIdLabel() {
|
138 |
/* Translators: This description is specific to Microsoft */
|
139 |
+
return _x( 'Client ID', 'Name of the OAuth 2.0 Client ID', 'post-smtp' );
|
140 |
}
|
141 |
public function getClientSecretLabel() {
|
142 |
/* Translators: This description is specific to Microsoft */
|
143 |
+
return _x( 'Client Secret', 'Name of the OAuth 2.0 Client Secret', 'post-smtp' );
|
144 |
}
|
145 |
public function getCallbackUrlLabel() {
|
146 |
/* Translators: This description is specific to Microsoft */
|
147 |
+
return _x( 'Redirect URL', 'Name of the Application Callback URI', 'post-smtp' );
|
148 |
}
|
149 |
public function getCallbackDomainLabel() {
|
150 |
/* Translators: This description is specific to Microsoft */
|
151 |
+
return _x( 'Root Domain', 'Name of the Application Callback Domain', 'post-smtp' );
|
152 |
}
|
153 |
public function getOwnerName() {
|
154 |
/* Translators: This description is specific to Microsoft */
|
155 |
+
return _x( 'Microsoft', 'Name of the email service owner', 'post-smtp' );
|
156 |
}
|
157 |
public function getServiceName() {
|
158 |
/* Translators: This description is specific to Microsoft */
|
159 |
+
return _x( 'Outlook.com', 'Name of the email service', 'post-smtp' );
|
160 |
}
|
161 |
public function getApplicationDescription() {
|
162 |
/* Translators: This description is specific to Microsoft */
|
163 |
+
return _x( 'an Application', 'Description of the email service OAuth 2.0 Application', 'post-smtp' );
|
164 |
}
|
165 |
public function getApplicationPortalName() {
|
166 |
/* Translators: This description is specific to Microsoft */
|
167 |
+
return _x( 'Microsoft Developer Center', 'Name of the email service portal', 'post-smtp' );
|
168 |
}
|
169 |
public function getApplicationPortalUrl() {
|
170 |
return 'https://account.live.com/developers/applications/index';
|
198 |
}
|
199 |
public function getClientIdLabel() {
|
200 |
/* Translators: This description is specific to Yahoo */
|
201 |
+
return _x( 'Client ID', 'Name of the OAuth 2.0 Client ID', 'post-smtp' );
|
202 |
}
|
203 |
public function getClientSecretLabel() {
|
204 |
/* Translators: This description is specific to Yahoo */
|
205 |
+
return _x( 'Client Secret', 'Name of the OAuth 2.0 Client Secret', 'post-smtp' );
|
206 |
}
|
207 |
public function getCallbackUrlLabel() {
|
208 |
/* Translators: This description is specific to Yahoo */
|
209 |
+
return _x( 'Home Page URL', 'Name of the Application Callback URI', 'post-smtp' );
|
210 |
}
|
211 |
public function getCallbackDomainLabel() {
|
212 |
/* Translators: This description is specific to Yahoo */
|
213 |
+
return _x( 'Callback Domain', 'Name of the Application Callback Domain', 'post-smtp' );
|
214 |
}
|
215 |
public function getOwnerName() {
|
216 |
/* Translators: This description is specific to Yahoo */
|
217 |
+
return _x( 'Yahoo', 'Name of the email service owner', 'post-smtp' );
|
218 |
}
|
219 |
public function getServiceName() {
|
220 |
/* Translators: This description is specific to Yahoo */
|
221 |
+
return _x( 'Yahoo Mail', 'Name of the email service', 'post-smtp' );
|
222 |
}
|
223 |
public function getApplicationDescription() {
|
224 |
/* Translators: This description is specific to Yahoo */
|
225 |
+
return _x( 'an Application', 'Description of the email service OAuth 2.0 Application', 'post-smtp' );
|
226 |
}
|
227 |
public function getApplicationPortalName() {
|
228 |
/* Translators: This description is specific to Yahoo */
|
229 |
+
return _x( 'Yahoo Developer Network', 'Name of the email service portal', 'post-smtp' );
|
230 |
}
|
231 |
public function getApplicationPortalUrl() {
|
232 |
return 'https://developer.yahoo.com/apps/';
|
255 |
return PostmanUtils::endsWith( $this->hostname, 'yahoo.com' );
|
256 |
}
|
257 |
public function getOAuthHelp() {
|
258 |
+
$text = __( 'Enter an Outgoing Mail Server with OAuth2 capabilities.', 'post-smtp' );
|
259 |
return sprintf( '<span style="color:red" class="normal">%s</span>', $text );
|
260 |
}
|
261 |
public function getCallbackUrl() {
|
265 |
return '';
|
266 |
}
|
267 |
public function getClientIdLabel() {
|
268 |
+
return _x( 'Client ID', 'Name of the OAuth 2.0 Client ID', 'post-smtp' );
|
269 |
}
|
270 |
public function getClientSecretLabel() {
|
271 |
+
return _x( 'Client Secret', 'Name of the OAuth 2.0 Client Secret', 'post-smtp' );
|
272 |
}
|
273 |
public function getCallbackUrlLabel() {
|
274 |
+
return _x( 'Redirect URI', 'Name of the Application Callback URI', 'post-smtp' );
|
275 |
}
|
276 |
public function getCallbackDomainLabel() {
|
277 |
+
return _x( 'Website Domain', 'Name of the Application Callback Domain', 'post-smtp' );
|
278 |
}
|
279 |
public function getOwnerName() {
|
280 |
return '';
|
298 |
return '';
|
299 |
}
|
300 |
public function getRequestPermissionLinkText() {
|
301 |
+
return __( 'Grant OAuth 2.0 Permission', 'post-smtp' );
|
302 |
}
|
303 |
}
|
304 |
}
|
Postman/PostmanEmailLogs.php
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class PostmanEmailLogs {
|
4 |
+
|
5 |
+
private $db;
|
6 |
+
|
7 |
+
public $db_name = 'post_smtp_logs';
|
8 |
+
|
9 |
+
private static $fields = array(
|
10 |
+
'success',
|
11 |
+
'from_header',
|
12 |
+
'to_header',
|
13 |
+
'cc_header',
|
14 |
+
'bcc_header',
|
15 |
+
'reply_to_header',
|
16 |
+
'transport_uri',
|
17 |
+
'original_to',
|
18 |
+
'original_subject',
|
19 |
+
'original_message',
|
20 |
+
'original_headers',
|
21 |
+
'session_transcript'
|
22 |
+
);
|
23 |
+
|
24 |
+
private static $instance;
|
25 |
+
|
26 |
+
public static function get_instance() {
|
27 |
+
if ( ! self::$instance ) {
|
28 |
+
self::$instanc = new static();
|
29 |
+
}
|
30 |
+
|
31 |
+
return self::$instance;
|
32 |
+
}
|
33 |
+
|
34 |
+
private function __construct() {
|
35 |
+
global $wpdb;
|
36 |
+
|
37 |
+
$this->db = $wpdb;
|
38 |
+
}
|
39 |
+
|
40 |
+
function install_table() {
|
41 |
+
|
42 |
+
global $wpdb;
|
43 |
+
|
44 |
+
$sql = "CREATE TABLE `{$wpdb->prefix}_{$this->db_name}` (
|
45 |
+
`id` bigint(20) NOT NULL AUTO_INCREMENT,
";
|
46 |
+
|
47 |
+
foreach ($this->fields as $field ) {
|
48 |
+
if ( $field == 'original_message' || $field == 'session_transcript' ) {
|
49 |
+
$sql .= "`" . $field . "` longtext DEFAULT NULL,";
|
50 |
+
continue;
|
51 |
+
}
|
52 |
+
$sql .= "`" . $field . "` varchar(255) DEFAULT NULL,";
|
53 |
+
}
|
54 |
+
$sql .= "PRIMARY KEY (`id`)) ENGINE=InnoDB CHARSET={$wpdb->charset} COLLATE={$wpdb->collate};
";
|
55 |
+
|
56 |
+
dbDelta( $sql );
|
57 |
+
}
|
58 |
+
|
59 |
+
public static function get_data( $post_id ) {
|
60 |
+
$fields = array();
|
61 |
+
foreach ( self::$fields as $field ) {
|
62 |
+
$fields[$field][0] = get_post_meta( $post_id, $field, true );
|
63 |
+
}
|
64 |
+
|
65 |
+
return $fields;
|
66 |
+
}
|
67 |
+
|
68 |
+
public static function get_fields() {
|
69 |
+
return self::$fields;
|
70 |
+
}
|
71 |
+
|
72 |
+
function migrate_data() {
|
73 |
+
$args = array(
|
74 |
+
'post_type' => 'postman_sent_mail',
|
75 |
+
'posts_per_page' => -1,
|
76 |
+
);
|
77 |
+
|
78 |
+
$logs = new WP_Query($args);
|
79 |
+
|
80 |
+
$failed_records = 0;
|
81 |
+
foreach ( $logs->posts as $log ) {
|
82 |
+
|
83 |
+
foreach ($this->fields as $key ) {
|
84 |
+
$value = $this->get_meta( $log->ID, $key, true );
|
85 |
+
|
86 |
+
if ( $this->add_meta( $log->ID, $key, $value ) ) {
|
87 |
+
delete_post_meta( $log->ID, $key );
|
88 |
+
} else {
|
89 |
+
$failed_records++;
|
90 |
+
}
|
91 |
+
}
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
+
function load() {
|
96 |
+
$this->db->select();
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* @param array $data
|
101 |
+
*/
|
102 |
+
function save( $data ) {
|
103 |
+
$this->db->query( $this->db->prepare(
|
104 |
+
"
|
105 |
+
INSERT INTO $this->db_name
|
106 |
+
( " . implode( ',', array_keys( $data ) ) . " )
|
107 |
+
VALUES ( " . str_repeat( '%s', count( $data ) ) . " )", array_values( $data )
|
108 |
+
) );
|
109 |
+
}
|
110 |
+
|
111 |
+
}
|
Postman/PostmanInputSanitizer.php
CHANGED
@@ -40,6 +40,7 @@ if ( ! class_exists( 'PostmanInputSanitizer' ) ) {
|
|
40 |
$new_input [ PostmanOptions::ENVELOPE_SENDER ] = $new_input [ PostmanOptions::MESSAGE_SENDER_EMAIL ];
|
41 |
$this->sanitizeString( 'Sender Email', PostmanOptions::ENVELOPE_SENDER, $input, $new_input );
|
42 |
$this->sanitizeString( 'Transport Type', PostmanOptions::TRANSPORT_TYPE, $input, $new_input );
|
|
|
43 |
$this->sanitizeString( 'Authorization Type', PostmanOptions::AUTHENTICATION_TYPE, $input, $new_input );
|
44 |
$this->sanitizeString( 'From Name', PostmanOptions::MESSAGE_SENDER_NAME, $input, $new_input );
|
45 |
$this->sanitizeString( 'Client ID', PostmanOptions::CLIENT_ID, $input, $new_input );
|
@@ -121,10 +122,10 @@ if ( ! class_exists( 'PostmanInputSanitizer' ) ) {
|
|
121 |
/**
|
122 |
* Sanitize a Basic Auth password, and base64-encode it
|
123 |
*
|
124 |
-
* @param
|
125 |
-
* @param
|
126 |
-
* @param
|
127 |
-
* @param
|
128 |
*/
|
129 |
private function sanitizePassword( $desc, $key, $input, &$new_input, $existingPassword ) {
|
130 |
// WordPress calling Sanitize twice is a known issue
|
@@ -157,7 +158,7 @@ if ( ! class_exists( 'PostmanInputSanitizer' ) ) {
|
|
157 |
if ( $value <= 0 ) {
|
158 |
$new_input [ $key ] = PostmanOptions::getInstance()->getMailLoggingMaxEntries();
|
159 |
$h = new PostmanMessageHandler();
|
160 |
-
$h->addError( sprintf( '%s %s', __( 'Maximum Log Entries',
|
161 |
} else {
|
162 |
$this->logSanitize( $desc, $input [ $key ] );
|
163 |
$new_input [ $key ] = $value;
|
40 |
$new_input [ PostmanOptions::ENVELOPE_SENDER ] = $new_input [ PostmanOptions::MESSAGE_SENDER_EMAIL ];
|
41 |
$this->sanitizeString( 'Sender Email', PostmanOptions::ENVELOPE_SENDER, $input, $new_input );
|
42 |
$this->sanitizeString( 'Transport Type', PostmanOptions::TRANSPORT_TYPE, $input, $new_input );
|
43 |
+
$this->sanitizeString( 'SMTP Mailers', 'smtp_mailers', $input, $new_input );
|
44 |
$this->sanitizeString( 'Authorization Type', PostmanOptions::AUTHENTICATION_TYPE, $input, $new_input );
|
45 |
$this->sanitizeString( 'From Name', PostmanOptions::MESSAGE_SENDER_NAME, $input, $new_input );
|
46 |
$this->sanitizeString( 'Client ID', PostmanOptions::CLIENT_ID, $input, $new_input );
|
122 |
/**
|
123 |
* Sanitize a Basic Auth password, and base64-encode it
|
124 |
*
|
125 |
+
* @param mixed $desc
|
126 |
+
* @param mixed $key
|
127 |
+
* @param mixed $input
|
128 |
+
* @param mixed $new_input
|
129 |
*/
|
130 |
private function sanitizePassword( $desc, $key, $input, &$new_input, $existingPassword ) {
|
131 |
// WordPress calling Sanitize twice is a known issue
|
158 |
if ( $value <= 0 ) {
|
159 |
$new_input [ $key ] = PostmanOptions::getInstance()->getMailLoggingMaxEntries();
|
160 |
$h = new PostmanMessageHandler();
|
161 |
+
$h->addError( sprintf( '%s %s', __( 'Maximum Log Entries', 'post-smtp' ), __( 'must be greater than 0', 'post-smtp' ) ) );
|
162 |
} else {
|
163 |
$this->logSanitize( $desc, $input [ $key ] );
|
164 |
$new_input [ $key ] = $value;
|
Postman/PostmanInstaller.php
CHANGED
@@ -24,6 +24,9 @@ class PostmanInstaller {
|
|
24 |
* Handle activation of the plugin
|
25 |
*/
|
26 |
public function activatePostman() {
|
|
|
|
|
|
|
27 |
$options = get_option( PostmanOptions::POSTMAN_OPTIONS );
|
28 |
$args = array(
|
29 |
'fallback_smtp_enabled' => 'no',
|
@@ -41,10 +44,6 @@ class PostmanInstaller {
|
|
41 |
|
42 |
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
|
43 |
|
44 |
-
/* $role = get_role( Postman::ADMINISTRATOR_ROLE_NAME );
|
45 |
-
$role->add_cap( Postman::MANAGE_POSTMAN_CAPABILITY_NAME );
|
46 |
-
$role->add_cap( Postman::MANAGE_POSTMAN_CAPABILITY_LOGS );*/
|
47 |
-
|
48 |
$options['post_smtp_allow_overwrite'] = '1';
|
49 |
update_site_option( PostmanOptions::POSTMAN_NETWORK_OPTIONS, $options );
|
50 |
|
24 |
* Handle activation of the plugin
|
25 |
*/
|
26 |
public function activatePostman() {
|
27 |
+
delete_option( 'postman_release_version' );
|
28 |
+
delete_option( 'postman_dismiss_donation' );
|
29 |
+
|
30 |
$options = get_option( PostmanOptions::POSTMAN_OPTIONS );
|
31 |
$args = array(
|
32 |
'fallback_smtp_enabled' => 'no',
|
44 |
|
45 |
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
|
46 |
|
|
|
|
|
|
|
|
|
47 |
$options['post_smtp_allow_overwrite'] = '1';
|
48 |
update_site_option( PostmanOptions::POSTMAN_NETWORK_OPTIONS, $options );
|
49 |
|
Postman/PostmanLogger.php
CHANGED
@@ -44,8 +44,8 @@ if (! class_exists ( "PostmanLogger" )) {
|
|
44 |
/**
|
45 |
* better logging thanks to http://www.smashingmagazine.com/2011/03/08/ten-things-every-wordpress-plugin-developer-should-know/
|
46 |
*
|
47 |
-
* @param
|
48 |
-
* @param
|
49 |
*/
|
50 |
private function printLog($text, $intLogLevel, $logLevelName) {
|
51 |
if ($this->wpDebug && $intLogLevel >= $this->logLevel) {
|
44 |
/**
|
45 |
* better logging thanks to http://www.smashingmagazine.com/2011/03/08/ten-things-every-wordpress-plugin-developer-should-know/
|
46 |
*
|
47 |
+
* @param mixed $intLogLevel
|
48 |
+
* @param mixed $logLevelName
|
49 |
*/
|
50 |
private function printLog($text, $intLogLevel, $logLevelName) {
|
51 |
if ($this->wpDebug && $intLogLevel >= $this->logLevel) {
|
Postman/PostmanMessageHandler.php
CHANGED
@@ -12,7 +12,7 @@ if (! class_exists ( 'PostmanMessageHandler' )) {
|
|
12 |
|
13 |
/**
|
14 |
*
|
15 |
-
* @param
|
16 |
*/
|
17 |
function __construct() {
|
18 |
$this->logger = new PostmanLogger ( get_class ( $this ) );
|
@@ -26,21 +26,21 @@ if (! class_exists ( 'PostmanMessageHandler' )) {
|
|
26 |
|
27 |
/**
|
28 |
*
|
29 |
-
* @param
|
30 |
*/
|
31 |
public function addError($message) {
|
32 |
$this->storeMessage ( $message, 'error' );
|
33 |
}
|
34 |
/**
|
35 |
*
|
36 |
-
* @param
|
37 |
*/
|
38 |
public function addWarning($message) {
|
39 |
$this->storeMessage ( $message, 'warning' );
|
40 |
}
|
41 |
/**
|
42 |
*
|
43 |
-
* @param
|
44 |
*/
|
45 |
public function addMessage($message) {
|
46 |
$this->storeMessage ( $message, 'notify' );
|
@@ -49,8 +49,8 @@ if (! class_exists ( 'PostmanMessageHandler' )) {
|
|
49 |
/**
|
50 |
* store messages for display later
|
51 |
*
|
52 |
-
* @param
|
53 |
-
* @param
|
54 |
*/
|
55 |
private function storeMessage($message, $type) {
|
56 |
$messageArray = array ();
|
@@ -102,8 +102,8 @@ if (! class_exists ( 'PostmanMessageHandler' )) {
|
|
102 |
/**
|
103 |
* putput message
|
104 |
*
|
105 |
-
* @param
|
106 |
-
* @param
|
107 |
*/
|
108 |
public function printMessage($message, $className) {
|
109 |
printf ( '<div class="%s"><p>%s</p></div>', $className, $message );
|
12 |
|
13 |
/**
|
14 |
*
|
15 |
+
* @param mixed $options
|
16 |
*/
|
17 |
function __construct() {
|
18 |
$this->logger = new PostmanLogger ( get_class ( $this ) );
|
26 |
|
27 |
/**
|
28 |
*
|
29 |
+
* @param mixed $message
|
30 |
*/
|
31 |
public function addError($message) {
|
32 |
$this->storeMessage ( $message, 'error' );
|
33 |
}
|
34 |
/**
|
35 |
*
|
36 |
+
* @param mixed $message
|
37 |
*/
|
38 |
public function addWarning($message) {
|
39 |
$this->storeMessage ( $message, 'warning' );
|
40 |
}
|
41 |
/**
|
42 |
*
|
43 |
+
* @param mixed $message
|
44 |
*/
|
45 |
public function addMessage($message) {
|
46 |
$this->storeMessage ( $message, 'notify' );
|
49 |
/**
|
50 |
* store messages for display later
|
51 |
*
|
52 |
+
* @param mixed $message
|
53 |
+
* @param mixed $type
|
54 |
*/
|
55 |
private function storeMessage($message, $type) {
|
56 |
$messageArray = array ();
|
102 |
/**
|
103 |
* putput message
|
104 |
*
|
105 |
+
* @param mixed $message
|
106 |
+
* @param mixed $className
|
107 |
*/
|
108 |
public function printMessage($message, $className) {
|
109 |
printf ( '<div class="%s"><p>%s</p></div>', $className, $message );
|
Postman/PostmanOptions.php
CHANGED
@@ -138,6 +138,11 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
|
|
138 |
const DEFAULT_PLUGIN_MESSAGE_SENDER_EMAIL_ENFORCED = false;
|
139 |
const DEFAULT_TEMP_DIRECTORY = '/tmp';
|
140 |
|
|
|
|
|
|
|
|
|
|
|
141 |
public $is_fallback = false;
|
142 |
|
143 |
// options data
|
@@ -174,10 +179,9 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
|
|
174 |
if ( is_multisite() ) {
|
175 |
$network_options = get_site_option( self::POSTMAN_NETWORK_OPTIONS );
|
176 |
|
|
|
177 |
if ( isset( $network_options['post_smtp_global_settings'] ) ) {
|
178 |
$blog_id = apply_filters( 'post_smtp_default_site_option', 1 );
|
179 |
-
} elseif ( $options && isset( $network_options['post_smtp_allow_overwrite'] ) ) {
|
180 |
-
$blog_id = get_current_blog_id();
|
181 |
}
|
182 |
|
183 |
switch_to_blog($blog_id);
|
@@ -570,6 +574,15 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
|
|
570 |
$this->setSenderName( $senderName );
|
571 |
}
|
572 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
573 |
public function isAuthTypePassword() {
|
574 |
return $this->isAuthTypeLogin() || $this->isAuthTypeCrammd5() || $this->isAuthTypePlain();
|
575 |
}
|
@@ -604,7 +617,7 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
|
|
604 |
* @see PostmanOptionsInterface::getSenderEmail()
|
605 |
*/
|
606 |
public function getSenderName() {
|
607 |
-
return $this->
|
608 |
}
|
609 |
|
610 |
/**
|
@@ -625,7 +638,7 @@ if ( ! class_exists( 'PostmanOptions' ) ) {
|
|
625 |
|
626 |
/**
|
627 |
*
|
628 |
-
* @param
|
629 |
*/
|
630 |
public function import( $data ) {
|
631 |
if ( PostmanPreRequisitesCheck::checkZlibEncode() ) {
|
138 |
const DEFAULT_PLUGIN_MESSAGE_SENDER_EMAIL_ENFORCED = false;
|
139 |
const DEFAULT_TEMP_DIRECTORY = '/tmp';
|
140 |
|
141 |
+
const SMTP_MAILERS = [
|
142 |
+
'phpmailer' => 'PHPMailer',
|
143 |
+
'postsmtp' => 'PostSMTP'
|
144 |
+
];
|
145 |
+
|
146 |
public $is_fallback = false;
|
147 |
|
148 |
// options data
|
179 |
if ( is_multisite() ) {
|
180 |
$network_options = get_site_option( self::POSTMAN_NETWORK_OPTIONS );
|
181 |
|
182 |
+
$blog_id = get_current_blog_id();
|
183 |
if ( isset( $network_options['post_smtp_global_settings'] ) ) {
|
184 |
$blog_id = apply_filters( 'post_smtp_default_site_option', 1 );
|
|
|
|
|
185 |
}
|
186 |
|
187 |
switch_to_blog($blog_id);
|
574 |
$this->setSenderName( $senderName );
|
575 |
}
|
576 |
}
|
577 |
+
|
578 |
+
public function getSmtpMailer() {
|
579 |
+
if ( empty($this->options [ 'smtp_mailers' ]) ) {
|
580 |
+
return 'postsmtp';
|
581 |
+
}
|
582 |
+
|
583 |
+
return $this->options [ 'smtp_mailers' ];
|
584 |
+
}
|
585 |
+
|
586 |
public function isAuthTypePassword() {
|
587 |
return $this->isAuthTypeLogin() || $this->isAuthTypeCrammd5() || $this->isAuthTypePlain();
|
588 |
}
|
617 |
* @see PostmanOptionsInterface::getSenderEmail()
|
618 |
*/
|
619 |
public function getSenderName() {
|
620 |
+
return $this->getMessageSenderName();
|
621 |
}
|
622 |
|
623 |
/**
|
638 |
|
639 |
/**
|
640 |
*
|
641 |
+
* @param mixed $data
|
642 |
*/
|
643 |
public function import( $data ) {
|
644 |
if ( PostmanPreRequisitesCheck::checkZlibEncode() ) {
|
Postman/PostmanSession.php
CHANGED
@@ -37,7 +37,7 @@ if (! class_exists ( 'PostmanSession' )) {
|
|
37 |
* OAuth is in progress $state is the randomly generated
|
38 |
* transaction ID
|
39 |
*
|
40 |
-
* @param
|
41 |
*/
|
42 |
public function isSetOauthInProgress() {
|
43 |
return get_transient ( self::OAUTH_IN_PROGRESS ) != false;
|
@@ -55,7 +55,7 @@ if (! class_exists ( 'PostmanSession' )) {
|
|
55 |
/**
|
56 |
* Sometimes I need to keep track of what I'm doing between requests
|
57 |
*
|
58 |
-
* @param
|
59 |
*/
|
60 |
public function isSetAction() {
|
61 |
return get_transient ( self::ACTION ) != false;
|
@@ -73,7 +73,7 @@ if (! class_exists ( 'PostmanSession' )) {
|
|
73 |
/**
|
74 |
* Sometimes I need to keep track of what I'm doing between requests
|
75 |
*
|
76 |
-
* @param
|
77 |
*/
|
78 |
public function isSetErrorMessage() {
|
79 |
return get_transient ( self::ERROR_MESSAGE ) != false;
|
37 |
* OAuth is in progress $state is the randomly generated
|
38 |
* transaction ID
|
39 |
*
|
40 |
+
* @param mixed $state
|
41 |
*/
|
42 |
public function isSetOauthInProgress() {
|
43 |
return get_transient ( self::OAUTH_IN_PROGRESS ) != false;
|
55 |
/**
|
56 |
* Sometimes I need to keep track of what I'm doing between requests
|
57 |
*
|
58 |
+
* @param mixed $action
|
59 |
*/
|
60 |
public function isSetAction() {
|
61 |
return get_transient ( self::ACTION ) != false;
|
73 |
/**
|
74 |
* Sometimes I need to keep track of what I'm doing between requests
|
75 |
*
|
76 |
+
* @param mixed $message
|
77 |
*/
|
78 |
public function isSetErrorMessage() {
|
79 |
return get_transient ( self::ERROR_MESSAGE ) != false;
|
Postman/PostmanUtils.php
CHANGED
@@ -32,7 +32,7 @@ class PostmanUtils {
|
|
32 |
|
33 |
/**
|
34 |
*
|
35 |
-
* @param
|
36 |
* @return string
|
37 |
*/
|
38 |
public static function getPageUrl( $slug ) {
|
@@ -71,8 +71,8 @@ class PostmanUtils {
|
|
71 |
/**
|
72 |
* from http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php
|
73 |
*
|
74 |
-
* @param
|
75 |
-
* @param
|
76 |
* @return boolean
|
77 |
*/
|
78 |
public static function startsWith( $haystack, $needle ) {
|
@@ -82,8 +82,8 @@ class PostmanUtils {
|
|
82 |
/**
|
83 |
* from http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php
|
84 |
*
|
85 |
-
* @param
|
86 |
-
* @param
|
87 |
* @return boolean
|
88 |
*/
|
89 |
public static function endsWith( $haystack, $needle ) {
|
@@ -99,8 +99,8 @@ class PostmanUtils {
|
|
99 |
/**
|
100 |
* Detect if the host is NOT a domain name
|
101 |
*
|
102 |
-
* @param
|
103 |
-
* @return
|
104 |
*/
|
105 |
public static function isHostAddressNotADomainName( $host ) {
|
106 |
// IPv4 / IPv6 test from http://stackoverflow.com/a/17871737/4368109
|
@@ -115,9 +115,9 @@ class PostmanUtils {
|
|
115 |
* Inside WordPress we can use wp_remote_post().
|
116 |
* Outside WordPress, not so much.
|
117 |
*
|
118 |
-
* @param
|
119 |
-
* @param
|
120 |
-
* @return the HTML body
|
121 |
*/
|
122 |
static function remotePostGetBodyOnly( $url, $parameters, array $headers = array() ) {
|
123 |
$response = PostmanUtils::remotePost( $url, $parameters, $headers );
|
@@ -130,9 +130,9 @@ class PostmanUtils {
|
|
130 |
* Inside WordPress we can use wp_remote_post().
|
131 |
* Outside WordPress, not so much.
|
132 |
*
|
133 |
-
* @param
|
134 |
-
* @param
|
135 |
-
* @return the HTTP response
|
136 |
*/
|
137 |
static function remotePost( $url, $parameters = array(), array $headers = array() ) {
|
138 |
$args = array(
|
@@ -161,7 +161,7 @@ class PostmanUtils {
|
|
161 |
* A facade function that handles redirects.
|
162 |
* Inside WordPress we can use wp_redirect(). Outside WordPress, not so much. **Load it before postman-core.php**
|
163 |
*
|
164 |
-
* @param
|
165 |
*/
|
166 |
static function redirect( $url ) {
|
167 |
// redirections back to THIS SITE should always be relative because of IIS bug
|
@@ -182,7 +182,7 @@ class PostmanUtils {
|
|
182 |
* Rounds the bytes returned from memory_get_usage to smaller amounts used IEC binary prefixes
|
183 |
* See http://en.wikipedia.org/wiki/Binary_prefix
|
184 |
*
|
185 |
-
* @param
|
186 |
* @return string
|
187 |
*/
|
188 |
static function roundBytes( $size ) {
|
@@ -261,7 +261,7 @@ class PostmanUtils {
|
|
261 |
/**
|
262 |
* Creates the pathname of the lockfile
|
263 |
*
|
264 |
-
* @param
|
265 |
* @return string
|
266 |
*/
|
267 |
private static function calculateTemporaryLockPath( $tempDirectory ) {
|
@@ -290,7 +290,7 @@ class PostmanUtils {
|
|
290 |
/**
|
291 |
* From http://stackoverflow.com/a/381275/4368109
|
292 |
*
|
293 |
-
* @param
|
294 |
* @return boolean
|
295 |
*/
|
296 |
public static function isEmpty( $text ) {
|
@@ -324,8 +324,8 @@ class PostmanUtils {
|
|
324 |
/**
|
325 |
* Validate an e-mail address
|
326 |
*
|
327 |
-
* @param
|
328 |
-
* @return
|
329 |
*/
|
330 |
static function validateEmail( $email ) {
|
331 |
if ( PostmanOptions::getInstance()->isEmailValidationDisabled() ) {
|
@@ -348,7 +348,7 @@ class PostmanUtils {
|
|
348 |
/**
|
349 |
* From http://stackoverflow.com/questions/13430120/str-getcsv-alternative-for-older-php-version-gives-me-an-empty-array-at-the-e
|
350 |
*
|
351 |
-
* @param
|
352 |
* @return multitype:
|
353 |
*/
|
354 |
static function postman_strgetcsv_impl( $string ) {
|
@@ -364,7 +364,7 @@ class PostmanUtils {
|
|
364 |
|
365 |
/**
|
366 |
*
|
367 |
-
* @return
|
368 |
*/
|
369 |
static function postmanGetServerName() {
|
370 |
if ( ! empty( $_SERVER ['SERVER_NAME'] ) ) {
|
@@ -380,7 +380,7 @@ class PostmanUtils {
|
|
380 |
/**
|
381 |
* Does this hostname belong to Google?
|
382 |
*
|
383 |
-
* @param
|
384 |
* @return boolean
|
385 |
*/
|
386 |
static function isGoogle( $hostname ) {
|
@@ -389,8 +389,8 @@ class PostmanUtils {
|
|
389 |
|
390 |
/**
|
391 |
*
|
392 |
-
* @param
|
393 |
-
* @param
|
394 |
*/
|
395 |
public static function registerAdminMenu( $viewController, $callbackName ) {
|
396 |
$logger = PostmanUtils::$logger;
|
@@ -406,8 +406,8 @@ class PostmanUtils {
|
|
406 |
|
407 |
/**
|
408 |
*
|
409 |
-
* @param
|
410 |
-
* @param
|
411 |
*/
|
412 |
public static function registerAjaxHandler( $actionName, $class, $callbackName ) {
|
413 |
if ( is_admin() ) {
|
@@ -422,7 +422,7 @@ class PostmanUtils {
|
|
422 |
|
423 |
/**
|
424 |
*
|
425 |
-
* @param
|
426 |
* @return mixed
|
427 |
*/
|
428 |
public static function getBooleanRequestParameter( $parameterName ) {
|
@@ -431,8 +431,8 @@ class PostmanUtils {
|
|
431 |
|
432 |
/**
|
433 |
*
|
434 |
-
* @param
|
435 |
-
* @return
|
436 |
*/
|
437 |
public static function getRequestParameter( $parameterName ) {
|
438 |
$logger = PostmanUtils::$logger;
|
@@ -447,7 +447,7 @@ class PostmanUtils {
|
|
447 |
}
|
448 |
|
449 |
public static function getServerName() {
|
450 |
-
$
|
451 |
|
452 |
if (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER)) {
|
453 |
$host = $_SERVER['SERVER_NAME'];
|
@@ -457,13 +457,6 @@ class PostmanUtils {
|
|
457 |
$host = php_uname('n');
|
458 |
}
|
459 |
|
460 |
-
// as final option - if ip returned or hostname without extension (not valid dns name)
|
461 |
-
$extension = pathinfo( $host, PATHINFO_EXTENSION );
|
462 |
-
if ( filter_var( $result, FILTER_VALIDATE_IP ) || empty( $extension ) ) {
|
463 |
-
$siteurl = get_bloginfo('url');
|
464 |
-
$host = parse_url($siteurl, PHP_URL_HOST);
|
465 |
-
}
|
466 |
-
|
467 |
return str_replace('www.', '', $host );
|
468 |
}
|
469 |
|
32 |
|
33 |
/**
|
34 |
*
|
35 |
+
* @param mixed $slug
|
36 |
* @return string
|
37 |
*/
|
38 |
public static function getPageUrl( $slug ) {
|
71 |
/**
|
72 |
* from http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php
|
73 |
*
|
74 |
+
* @param mixed $haystack
|
75 |
+
* @param mixed $needle
|
76 |
* @return boolean
|
77 |
*/
|
78 |
public static function startsWith( $haystack, $needle ) {
|
82 |
/**
|
83 |
* from http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php
|
84 |
*
|
85 |
+
* @param mixed $haystack
|
86 |
+
* @param mixed $needle
|
87 |
* @return boolean
|
88 |
*/
|
89 |
public static function endsWith( $haystack, $needle ) {
|
99 |
/**
|
100 |
* Detect if the host is NOT a domain name
|
101 |
*
|
102 |
+
* @param mixed $ipAddress
|
103 |
+
* @return bool
|
104 |
*/
|
105 |
public static function isHostAddressNotADomainName( $host ) {
|
106 |
// IPv4 / IPv6 test from http://stackoverflow.com/a/17871737/4368109
|
115 |
* Inside WordPress we can use wp_remote_post().
|
116 |
* Outside WordPress, not so much.
|
117 |
*
|
118 |
+
* @param mixed $url
|
119 |
+
* @param mixed $args
|
120 |
+
* @return string the HTML body
|
121 |
*/
|
122 |
static function remotePostGetBodyOnly( $url, $parameters, array $headers = array() ) {
|
123 |
$response = PostmanUtils::remotePost( $url, $parameters, $headers );
|
130 |
* Inside WordPress we can use wp_remote_post().
|
131 |
* Outside WordPress, not so much.
|
132 |
*
|
133 |
+
* @param mixed $url
|
134 |
+
* @param mixed $args
|
135 |
+
* @return array|WP_Error the HTTP response
|
136 |
*/
|
137 |
static function remotePost( $url, $parameters = array(), array $headers = array() ) {
|
138 |
$args = array(
|
161 |
* A facade function that handles redirects.
|
162 |
* Inside WordPress we can use wp_redirect(). Outside WordPress, not so much. **Load it before postman-core.php**
|
163 |
*
|
164 |
+
* @param mixed $url
|
165 |
*/
|
166 |
static function redirect( $url ) {
|
167 |
// redirections back to THIS SITE should always be relative because of IIS bug
|
182 |
* Rounds the bytes returned from memory_get_usage to smaller amounts used IEC binary prefixes
|
183 |
* See http://en.wikipedia.org/wiki/Binary_prefix
|
184 |
*
|
185 |
+
* @param mixed $size
|
186 |
* @return string
|
187 |
*/
|
188 |
static function roundBytes( $size ) {
|
261 |
/**
|
262 |
* Creates the pathname of the lockfile
|
263 |
*
|
264 |
+
* @param mixed $tempDirectory
|
265 |
* @return string
|
266 |
*/
|
267 |
private static function calculateTemporaryLockPath( $tempDirectory ) {
|
290 |
/**
|
291 |
* From http://stackoverflow.com/a/381275/4368109
|
292 |
*
|
293 |
+
* @param mixed $text
|
294 |
* @return boolean
|
295 |
*/
|
296 |
public static function isEmpty( $text ) {
|
324 |
/**
|
325 |
* Validate an e-mail address
|
326 |
*
|
327 |
+
* @param mixed $email
|
328 |
+
* @return string|bool
|
329 |
*/
|
330 |
static function validateEmail( $email ) {
|
331 |
if ( PostmanOptions::getInstance()->isEmailValidationDisabled() ) {
|
348 |
/**
|
349 |
* From http://stackoverflow.com/questions/13430120/str-getcsv-alternative-for-older-php-version-gives-me-an-empty-array-at-the-e
|
350 |
*
|
351 |
+
* @param mixed $string
|
352 |
* @return multitype:
|
353 |
*/
|
354 |
static function postman_strgetcsv_impl( $string ) {
|
364 |
|
365 |
/**
|
366 |
*
|
367 |
+
* @return string|mixed
|
368 |
*/
|
369 |
static function postmanGetServerName() {
|
370 |
if ( ! empty( $_SERVER ['SERVER_NAME'] ) ) {
|
380 |
/**
|
381 |
* Does this hostname belong to Google?
|
382 |
*
|
383 |
+
* @param mixed $hostname
|
384 |
* @return boolean
|
385 |
*/
|
386 |
static function isGoogle( $hostname ) {
|
389 |
|
390 |
/**
|
391 |
*
|
392 |
+
* @param mixed $actionName
|
393 |
+
* @param mixed $callbackName
|
394 |
*/
|
395 |
public static function registerAdminMenu( $viewController, $callbackName ) {
|
396 |
$logger = PostmanUtils::$logger;
|
406 |
|
407 |
/**
|
408 |
*
|
409 |
+
* @param mixed $actionName
|
410 |
+
* @param mixed $callbackName
|
411 |
*/
|
412 |
public static function registerAjaxHandler( $actionName, $class, $callbackName ) {
|
413 |
if ( is_admin() ) {
|
422 |
|
423 |
/**
|
424 |
*
|
425 |
+
* @param mixed $parameterName
|
426 |
* @return mixed
|
427 |
*/
|
428 |
public static function getBooleanRequestParameter( $parameterName ) {
|
431 |
|
432 |
/**
|
433 |
*
|
434 |
+
* @param mixed $parameterName
|
435 |
+
* @return mixed
|
436 |
*/
|
437 |
public static function getRequestParameter( $parameterName ) {
|
438 |
$logger = PostmanUtils::$logger;
|
447 |
}
|
448 |
|
449 |
public static function getServerName() {
|
450 |
+
$host = 'localhost';
|
451 |
|
452 |
if (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER)) {
|
453 |
$host = $_SERVER['SERVER_NAME'];
|
457 |
$host = php_uname('n');
|
458 |
}
|
459 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
460 |
return str_replace('www.', '', $host );
|
461 |
}
|
462 |
|
Postman/PostmanViewController.php
CHANGED
@@ -38,6 +38,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
|
|
38 |
add_action( 'admin_init', array( $this, 'registerStylesAndScripts' ), 0 );
|
39 |
add_action( 'wp_ajax_delete_lock_file', array( $this, 'delete_lock_file' ) );
|
40 |
add_action( 'wp_ajax_dismiss_version_notify', array( $this, 'dismiss_version_notify' ) );
|
|
|
41 |
|
42 |
//add_action( 'admin_init', array( $this, 'do_activation_redirect' ) );
|
43 |
|
@@ -47,19 +48,24 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
|
|
47 |
function dismiss_version_notify() {
|
48 |
check_ajax_referer( 'postsmtp', 'security' );
|
49 |
|
50 |
-
$
|
51 |
-
$result = update_option('postman_release_version_'. $version, true );
|
52 |
}
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
function delete_lock_file() {
|
55 |
check_ajax_referer( 'postman', 'security' );
|
56 |
|
57 |
if ( ! PostmanUtils::lockFileExists() ) {
|
58 |
-
echo __('No lock file found.',
|
59 |
die();
|
60 |
}
|
61 |
|
62 |
-
echo PostmanUtils::deleteLockFile() == true ? __('Success, try to send test email.',
|
63 |
die();
|
64 |
}
|
65 |
|
@@ -96,8 +102,8 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
|
|
96 |
*/
|
97 |
public function generateDefaultContent() {
|
98 |
// This page will be under "Settings"
|
99 |
-
$pageTitle = sprintf( __( '%s Setup',
|
100 |
-
$pluginName = __( 'Post SMTP',
|
101 |
$uniqueId = self::POSTMAN_MENU_SLUG;
|
102 |
$pageOptions = array(
|
103 |
$this,
|
@@ -119,7 +125,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
|
|
119 |
* Register the Email Test screen
|
120 |
*/
|
121 |
public function addPurgeDataSubmenu() {
|
122 |
-
$page = add_submenu_page( null, sprintf( __( '%s Setup',
|
123 |
$this,
|
124 |
'outputPurgeDataContent',
|
125 |
) );
|
@@ -157,15 +163,15 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
|
|
157 |
), '1.13.1' );
|
158 |
|
159 |
wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_ajax_msg', array(
|
160 |
-
'bad_response' => __( 'An unexpected error occurred',
|
161 |
-
'corrupt_response' => __( 'Unexpected PHP messages corrupted the Ajax response',
|
162 |
) );
|
163 |
|
164 |
wp_localize_script( 'jquery_steps_script', 'steps_current_step', 'steps_current_step' );
|
165 |
wp_localize_script( 'jquery_steps_script', 'steps_pagination', 'steps_pagination' );
|
166 |
-
wp_localize_script( 'jquery_steps_script', 'steps_finish', _x( 'Finish', 'Press this button to Finish this task',
|
167 |
-
wp_localize_script( 'jquery_steps_script', 'steps_next', _x( 'Next', 'Press this button to go to the next step',
|
168 |
-
wp_localize_script( 'jquery_steps_script', 'steps_previous', _x( 'Previous', 'Press this button to go to the previous step',
|
169 |
wp_localize_script( 'jquery_steps_script', 'steps_loading', 'steps_loading' );
|
170 |
}
|
171 |
|
@@ -177,7 +183,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
|
|
177 |
print '<div class="wrap">';
|
178 |
$this->displayTopNavigation();
|
179 |
if ( ! PostmanPreRequisitesCheck::isReady() ) {
|
180 |
-
printf( '<p><span style="color:red; padding:2px 0; font-size:1.1em">%s</span></p>', __( 'Postman is unable to run. Email delivery is being handled by WordPress (or another plugin).',
|
181 |
} else {
|
182 |
$ready_messsage = PostmanTransportRegistry::getInstance()->getReadyMessage();
|
183 |
$statusMessage = $ready_messsage['message'];
|
@@ -193,27 +199,32 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
|
|
193 |
$this->printDeliveryDetails();
|
194 |
/* translators: where %d is the number of emails delivered */
|
195 |
print '<p style="margin:10px 10px"><span>';
|
196 |
-
printf( _n( 'Postman has delivered <span style="color:green">%d</span> email.', 'Postman has delivered <span style="color:green">%d</span> emails.', PostmanState::getInstance()->getSuccessfulDeliveries(),
|
197 |
if ( $this->options->isMailLoggingEnabled() ) {
|
198 |
print ' ';
|
199 |
-
printf( __( 'The last %d email attempts are recorded <a href="%s">in the log</a>.',
|
200 |
}
|
201 |
print '</span></p>';
|
202 |
}
|
203 |
if ( $this->options->isNew() ) {
|
204 |
-
printf( '<h3 style="padding-top:10px">%s</h3>', __( 'Thank-you for choosing Postman!',
|
205 |
/* translators: where %s is the URL of the Setup Wizard */
|
206 |
-
printf( '<p><span>%s</span></p>', sprintf( __( 'Let\'s get started! All users are strongly encouraged to <a href="%s">run the Setup Wizard</a>.',
|
207 |
-
printf( '<p><span>%s</span></p>', sprintf( __( 'Alternately, <a href="%s">manually configure</a> your own settings and/or modify advanced options.',
|
208 |
} else {
|
209 |
if ( PostmanState::getInstance()->isTimeToReviewPostman() && ! PostmanOptions::getInstance()->isNew() ) {
|
210 |
print '</br><hr width="70%"></br>';
|
211 |
/* translators: where %s is the URL to the WordPress.org review and ratings page */
|
212 |
-
printf( '%s</span></p>', sprintf( __( 'Please consider <a href="%s">leaving a review</a> to help spread the word! :D',
|
213 |
}
|
214 |
-
printf( '<p><span>%s :-)</span></p>', sprintf( __( 'Postman needs translators! Please take a moment to <a href="%s">translate a few sentences on-line</a>',
|
215 |
}
|
216 |
-
printf(
|
|
|
|
|
|
|
|
|
|
|
217 |
}
|
218 |
|
219 |
/**
|
@@ -226,33 +237,33 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
|
|
226 |
|
227 |
/**
|
228 |
*
|
229 |
-
* @param
|
230 |
* @param string $slug
|
231 |
*/
|
232 |
public static function outputChildPageHeader( $title, $slug = '' ) {
|
233 |
-
printf( '<h2>%s</h2>', sprintf( __( '%s Setup',
|
234 |
printf( '<div id="postman-main-menu" class="welcome-panel %s">', $slug );
|
235 |
print '<div class="welcome-panel-content">';
|
236 |
print '<div class="welcome-panel-column-container">';
|
237 |
print '<div class="welcome-panel-column welcome-panel-last">';
|
238 |
printf( '<h4>%s</h4>', $title );
|
239 |
print '</div>';
|
240 |
-
printf( '<p id="back_to_main_menu">%s <a id="back_to_menu_link" href="%s">%s</a></p>', self::BACK_ARROW_SYMBOL, PostmanUtils::getSettingsPageUrl(), _x( 'Back To Main Menu', 'Return to main menu link',
|
241 |
print '</div></div></div>';
|
242 |
}
|
243 |
|
244 |
/**
|
245 |
*/
|
246 |
public function outputPurgeDataContent() {
|
247 |
-
$importTitle = __( 'Import',
|
248 |
-
$exportTile = __( 'Export',
|
249 |
-
$resetTitle = __( 'Reset Plugin',
|
250 |
$options = $this->options;
|
251 |
print '<div class="wrap">';
|
252 |
PostmanViewController::outputChildPageHeader( sprintf( '%s/%s/%s', $importTitle, $exportTile, $resetTitle ) );
|
253 |
print '<section id="export_settings">';
|
254 |
printf( '<h3><span>%s<span></h3>', $exportTile );
|
255 |
-
printf( '<p><span>%s</span></p>', __( 'Copy this data into another instance of Postman to duplicate the configuration.',
|
256 |
$data = '';
|
257 |
if ( ! PostmanPreRequisitesCheck::checkZlibEncode() ) {
|
258 |
$extraDeleteButtonAttributes = sprintf( 'disabled="true"' );
|
@@ -271,15 +282,15 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
|
|
271 |
wp_nonce_field( PostmanAdminController::IMPORT_SETTINGS_SLUG );
|
272 |
printf( '<input type="hidden" name="action" value="%s" />', PostmanAdminController::IMPORT_SETTINGS_SLUG );
|
273 |
print '<p>';
|
274 |
-
printf( '<span>%s</span>', __( 'Paste data from another instance of Postman here to duplicate the configuration.',
|
275 |
if ( PostmanTransportRegistry::getInstance()->getSelectedTransport()->isOAuthUsed( PostmanOptions::getInstance()->getAuthenticationType() ) ) {
|
276 |
-
$warning = __( 'Warning',
|
277 |
-
$errorMessage = __( 'Using the same OAuth 2.0 Client ID and Client Secret from this site at the same time as another site will cause failures.',
|
278 |
printf( ' <span><b>%s</b>: %s</span>', $warning, $errorMessage );
|
279 |
}
|
280 |
print '</p>';
|
281 |
printf( '<textarea cols="80" rows="5" name="settings" %s></textarea>', $extraDeleteButtonAttributes );
|
282 |
-
submit_button( __( 'Import',
|
283 |
print '</form>';
|
284 |
print '</section>';
|
285 |
print '<section id="delete_settings">';
|
@@ -287,7 +298,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
|
|
287 |
print '<form method="POST" action="' . get_admin_url() . 'admin-post.php">';
|
288 |
wp_nonce_field( PostmanAdminController::PURGE_DATA_SLUG );
|
289 |
printf( '<input type="hidden" name="action" value="%s" />', PostmanAdminController::PURGE_DATA_SLUG );
|
290 |
-
printf( '<p><span>%s</span></p><p><span>%s</span></p>', __( 'This will purge all of Postman\'s settings, including account credentials and the email log.',
|
291 |
$extraDeleteButtonAttributes = 'style="background-color:red;color:white"';
|
292 |
if ( $this->options->isNew() ) {
|
293 |
$extraDeleteButtonAttributes .= ' disabled="true"';
|
@@ -302,14 +313,14 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
|
|
302 |
*/
|
303 |
private function displayTopNavigation() {
|
304 |
$version = PostmanState::getInstance()->getVersion();
|
305 |
-
$show = get_option('
|
306 |
-
printf( '<h2>%s</h2>', sprintf( __( '%s Setup',
|
307 |
|
308 |
if ( ! $show ) {
|
309 |
echo '
|
310 |
<div class="updated settings-error notice is-dismissible">
|
311 |
<p>
|
312 |
-
<strong>Version ' . $version . '
|
313 |
</p>
|
314 |
<button style="z-index: 100;" data-version="'. $version . '" data-security="' . wp_create_nonce('postsmtp') .'" type="button" class="notice-dismiss postman-release-message">
|
315 |
<span class="screen-reader-text">Dismiss this notice.</span>
|
@@ -317,49 +328,58 @@ if ( ! class_exists( 'PostmanViewController' ) ) {
|
|
317 |
</div>';
|
318 |
}
|
319 |
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
363 |
}
|
364 |
}
|
365 |
}
|
38 |
add_action( 'admin_init', array( $this, 'registerStylesAndScripts' ), 0 );
|
39 |
add_action( 'wp_ajax_delete_lock_file', array( $this, 'delete_lock_file' ) );
|
40 |
add_action( 'wp_ajax_dismiss_version_notify', array( $this, 'dismiss_version_notify' ) );
|
41 |
+
add_action( 'wp_ajax_dismiss_donation_notify', array( $this, 'dismiss_donation_notify' ) );
|
42 |
|
43 |
//add_action( 'admin_init', array( $this, 'do_activation_redirect' ) );
|
44 |
|
48 |
function dismiss_version_notify() {
|
49 |
check_ajax_referer( 'postsmtp', 'security' );
|
50 |
|
51 |
+
$result = update_option('postman_release_version', true );
|
|
|
52 |
}
|
53 |
|
54 |
+
function dismiss_donation_notify() {
|
55 |
+
check_ajax_referer( 'postsmtp', 'security' );
|
56 |
+
|
57 |
+
$result = update_option('postman_dismiss_donation', true );
|
58 |
+
}
|
59 |
+
|
60 |
function delete_lock_file() {
|
61 |
check_ajax_referer( 'postman', 'security' );
|
62 |
|
63 |
if ( ! PostmanUtils::lockFileExists() ) {
|
64 |
+
echo __('No lock file found.', 'post-smtp' );
|
65 |
die();
|
66 |
}
|
67 |
|
68 |
+
echo PostmanUtils::deleteLockFile() == true ? __('Success, try to send test email.', 'post-smtp' ) : __('Failed, try again.', 'post-smtp' );
|
69 |
die();
|
70 |
}
|
71 |
|
102 |
*/
|
103 |
public function generateDefaultContent() {
|
104 |
// This page will be under "Settings"
|
105 |
+
$pageTitle = sprintf( __( '%s Setup', 'post-smtp' ), __( 'Post SMTP', 'post-smtp' ) );
|
106 |
+
$pluginName = __( 'Post SMTP', 'post-smtp' );
|
107 |
$uniqueId = self::POSTMAN_MENU_SLUG;
|
108 |
$pageOptions = array(
|
109 |
$this,
|
125 |
* Register the Email Test screen
|
126 |
*/
|
127 |
public function addPurgeDataSubmenu() {
|
128 |
+
$page = add_submenu_page( null, sprintf( __( '%s Setup', 'post-smtp' ), __( 'Post SMTP', 'post-smtp' ) ), __( 'Post SMTP', 'post-smtp' ), Postman::MANAGE_POSTMAN_CAPABILITY_NAME, PostmanAdminController::MANAGE_OPTIONS_PAGE_SLUG, array(
|
129 |
$this,
|
130 |
'outputPurgeDataContent',
|
131 |
) );
|
163 |
), '1.13.1' );
|
164 |
|
165 |
wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_ajax_msg', array(
|
166 |
+
'bad_response' => __( 'An unexpected error occurred', 'post-smtp' ),
|
167 |
+
'corrupt_response' => __( 'Unexpected PHP messages corrupted the Ajax response', 'post-smtp' ),
|
168 |
) );
|
169 |
|
170 |
wp_localize_script( 'jquery_steps_script', 'steps_current_step', 'steps_current_step' );
|
171 |
wp_localize_script( 'jquery_steps_script', 'steps_pagination', 'steps_pagination' );
|
172 |
+
wp_localize_script( 'jquery_steps_script', 'steps_finish', _x( 'Finish', 'Press this button to Finish this task', 'post-smtp' ) );
|
173 |
+
wp_localize_script( 'jquery_steps_script', 'steps_next', _x( 'Next', 'Press this button to go to the next step', 'post-smtp' ) );
|
174 |
+
wp_localize_script( 'jquery_steps_script', 'steps_previous', _x( 'Previous', 'Press this button to go to the previous step', 'post-smtp' ) );
|
175 |
wp_localize_script( 'jquery_steps_script', 'steps_loading', 'steps_loading' );
|
176 |
}
|
177 |
|
183 |
print '<div class="wrap">';
|
184 |
$this->displayTopNavigation();
|
185 |
if ( ! PostmanPreRequisitesCheck::isReady() ) {
|
186 |
+
printf( '<p><span style="color:red; padding:2px 0; font-size:1.1em">%s</span></p>', __( 'Postman is unable to run. Email delivery is being handled by WordPress (or another plugin).', 'post-smtp' ) );
|
187 |
} else {
|
188 |
$ready_messsage = PostmanTransportRegistry::getInstance()->getReadyMessage();
|
189 |
$statusMessage = $ready_messsage['message'];
|
199 |
$this->printDeliveryDetails();
|
200 |
/* translators: where %d is the number of emails delivered */
|
201 |
print '<p style="margin:10px 10px"><span>';
|
202 |
+
printf( _n( 'Postman has delivered <span style="color:green">%d</span> email.', 'Postman has delivered <span style="color:green">%d</span> emails.', PostmanState::getInstance()->getSuccessfulDeliveries(), 'post-smtp' ), PostmanState::getInstance()->getSuccessfulDeliveries() );
|
203 |
if ( $this->options->isMailLoggingEnabled() ) {
|
204 |
print ' ';
|
205 |
+
printf( __( 'The last %d email attempts are recorded <a href="%s">in the log</a>.', 'post-smtp' ), PostmanOptions::getInstance()->getMailLoggingMaxEntries(), PostmanUtils::getEmailLogPageUrl() );
|
206 |
}
|
207 |
print '</span></p>';
|
208 |
}
|
209 |
if ( $this->options->isNew() ) {
|
210 |
+
printf( '<h3 style="padding-top:10px">%s</h3>', __( 'Thank-you for choosing Postman!', 'post-smtp' ) );
|
211 |
/* translators: where %s is the URL of the Setup Wizard */
|
212 |
+
printf( '<p><span>%s</span></p>', sprintf( __( 'Let\'s get started! All users are strongly encouraged to <a href="%s">run the Setup Wizard</a>.', 'post-smtp' ), $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_WIZARD_SLUG ) ) );
|
213 |
+
printf( '<p><span>%s</span></p>', sprintf( __( 'Alternately, <a href="%s">manually configure</a> your own settings and/or modify advanced options.', 'post-smtp' ), $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_SLUG ) ) );
|
214 |
} else {
|
215 |
if ( PostmanState::getInstance()->isTimeToReviewPostman() && ! PostmanOptions::getInstance()->isNew() ) {
|
216 |
print '</br><hr width="70%"></br>';
|
217 |
/* translators: where %s is the URL to the WordPress.org review and ratings page */
|
218 |
+
printf( '%s</span></p>', sprintf( __( 'Please consider <a href="%s">leaving a review</a> to help spread the word! :D', 'post-smtp' ), 'https://wordpress.org/support/view/plugin-reviews/post-smtp?filter=5' ) );
|
219 |
}
|
220 |
+
printf( '<p><span>%s :-)</span></p>', sprintf( __( 'Postman needs translators! Please take a moment to <a href="%s">translate a few sentences on-line</a>', 'post-smtp' ), 'https://translate.wordpress.org/projects/wp-plugins/post-smtp/stable' ) );
|
221 |
}
|
222 |
+
printf(
|
223 |
+
'<p><span>%s</span> <a target="_blank" href="%s">%s</a></p>',
|
224 |
+
__( '<b style="background-color:yellow">New for v1.9.8!</b> Fallback - setup a second delivery method when the first one is failing', 'post-smtp' ),
|
225 |
+
'https://postmansmtp.com/post-smtp-1-9-7-the-smtp-fallback/',
|
226 |
+
__( 'Check the detailes here', 'post-smtp')
|
227 |
+
);
|
228 |
}
|
229 |
|
230 |
/**
|
237 |
|
238 |
/**
|
239 |
*
|
240 |
+
* @param mixed $title
|
241 |
* @param string $slug
|
242 |
*/
|
243 |
public static function outputChildPageHeader( $title, $slug = '' ) {
|
244 |
+
printf( '<h2>%s</h2>', sprintf( __( '%s Setup', 'post-smtp' ), __( 'Post SMTP', 'post-smtp' ) ) );
|
245 |
printf( '<div id="postman-main-menu" class="welcome-panel %s">', $slug );
|
246 |
print '<div class="welcome-panel-content">';
|
247 |
print '<div class="welcome-panel-column-container">';
|
248 |
print '<div class="welcome-panel-column welcome-panel-last">';
|
249 |
printf( '<h4>%s</h4>', $title );
|
250 |
print '</div>';
|
251 |
+
printf( '<p id="back_to_main_menu">%s <a id="back_to_menu_link" href="%s">%s</a></p>', self::BACK_ARROW_SYMBOL, PostmanUtils::getSettingsPageUrl(), _x( 'Back To Main Menu', 'Return to main menu link', 'post-smtp' ) );
|
252 |
print '</div></div></div>';
|
253 |
}
|
254 |
|
255 |
/**
|
256 |
*/
|
257 |
public function outputPurgeDataContent() {
|
258 |
+
$importTitle = __( 'Import', 'post-smtp' );
|
259 |
+
$exportTile = __( 'Export', 'post-smtp' );
|
260 |
+
$resetTitle = __( 'Reset Plugin', 'post-smtp' );
|
261 |
$options = $this->options;
|
262 |
print '<div class="wrap">';
|
263 |
PostmanViewController::outputChildPageHeader( sprintf( '%s/%s/%s', $importTitle, $exportTile, $resetTitle ) );
|
264 |
print '<section id="export_settings">';
|
265 |
printf( '<h3><span>%s<span></h3>', $exportTile );
|
266 |
+
printf( '<p><span>%s</span></p>', __( 'Copy this data into another instance of Postman to duplicate the configuration.', 'post-smtp' ) );
|
267 |
$data = '';
|
268 |
if ( ! PostmanPreRequisitesCheck::checkZlibEncode() ) {
|
269 |
$extraDeleteButtonAttributes = sprintf( 'disabled="true"' );
|
282 |
wp_nonce_field( PostmanAdminController::IMPORT_SETTINGS_SLUG );
|
283 |
printf( '<input type="hidden" name="action" value="%s" />', PostmanAdminController::IMPORT_SETTINGS_SLUG );
|
284 |
print '<p>';
|
285 |
+
printf( '<span>%s</span>', __( 'Paste data from another instance of Postman here to duplicate the configuration.', 'post-smtp' ) );
|
286 |
if ( PostmanTransportRegistry::getInstance()->getSelectedTransport()->isOAuthUsed( PostmanOptions::getInstance()->getAuthenticationType() ) ) {
|
287 |
+
$warning = __( 'Warning', 'post-smtp' );
|
288 |
+
$errorMessage = __( 'Using the same OAuth 2.0 Client ID and Client Secret from this site at the same time as another site will cause failures.', 'post-smtp' );
|
289 |
printf( ' <span><b>%s</b>: %s</span>', $warning, $errorMessage );
|
290 |
}
|
291 |
print '</p>';
|
292 |
printf( '<textarea cols="80" rows="5" name="settings" %s></textarea>', $extraDeleteButtonAttributes );
|
293 |
+
submit_button( __( 'Import', 'post-smtp' ), 'primary', 'import', true, $extraDeleteButtonAttributes );
|
294 |
print '</form>';
|
295 |
print '</section>';
|
296 |
print '<section id="delete_settings">';
|
298 |
print '<form method="POST" action="' . get_admin_url() . 'admin-post.php">';
|
299 |
wp_nonce_field( PostmanAdminController::PURGE_DATA_SLUG );
|
300 |
printf( '<input type="hidden" name="action" value="%s" />', PostmanAdminController::PURGE_DATA_SLUG );
|
301 |
+
printf( '<p><span>%s</span></p><p><span>%s</span></p>', __( 'This will purge all of Postman\'s settings, including account credentials and the email log.', 'post-smtp' ), __( 'Are you sure?', 'post-smtp' ) );
|
302 |
$extraDeleteButtonAttributes = 'style="background-color:red;color:white"';
|
303 |
if ( $this->options->isNew() ) {
|
304 |
$extraDeleteButtonAttributes .= ' disabled="true"';
|
313 |
*/
|
314 |
private function displayTopNavigation() {
|
315 |
$version = PostmanState::getInstance()->getVersion();
|
316 |
+
$show = get_option('postman_release_version' );
|
317 |
+
printf( '<h2>%s</h2>', sprintf( __( '%s Setup', 'post-smtp' ), __( 'Post SMTP', 'post-smtp' ) ) );
|
318 |
|
319 |
if ( ! $show ) {
|
320 |
echo '
|
321 |
<div class="updated settings-error notice is-dismissible">
|
322 |
<p>
|
323 |
+
<strong>Version ' . $version . ' Mailer Type:</strong> <a target="_blank" href="https://postmansmtp.com/post-smtp-2-0-mailer-type-and-much-more/">Read Here</a>
|
324 |
</p>
|
325 |
<button style="z-index: 100;" data-version="'. $version . '" data-security="' . wp_create_nonce('postsmtp') .'" type="button" class="notice-dismiss postman-release-message">
|
326 |
<span class="screen-reader-text">Dismiss this notice.</span>
|
328 |
</div>';
|
329 |
}
|
330 |
|
331 |
+
include_once POST_PATH . '/Postman/extra/donation.php';
|
332 |
+
|
333 |
+
echo '<div class="twitter-wrap">';
|
334 |
+
print '<div id="postman-main-menu" class="welcome-panel">';
|
335 |
+
print '<div class="welcome-panel-content">';
|
336 |
+
print '<div class="welcome-panel-column-container">';
|
337 |
+
print '<div class="welcome-panel-column">';
|
338 |
+
printf( '<h4>%s</h4>', __( 'Configuration', 'post-smtp' ) );
|
339 |
+
printf( '<a class="button button-primary button-hero" href="%s">%s</a>', $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_WIZARD_SLUG ), __( 'Start the Wizard', 'post-smtp' ) );
|
340 |
+
printf( '<p class="">%s <a href="%s" class="configure_manually">%s</a></p>', __( 'or', 'post-smtp' ), $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_SLUG ), __( 'Show All Settings', 'post-smtp' ) );
|
341 |
+
print '</div>';
|
342 |
+
print '<div class="welcome-panel-column">';
|
343 |
+
printf( '<h4>%s</h4>', _x( 'Actions', 'Main Menu', 'post-smtp' ) );
|
344 |
+
print '<ul>';
|
345 |
+
|
346 |
+
// Grant permission with Google
|
347 |
+
PostmanTransportRegistry::getInstance()->getSelectedTransport()->printActionMenuItem();
|
348 |
+
|
349 |
+
if ( PostmanWpMailBinder::getInstance()->isBound() ) {
|
350 |
+
printf( '<li><a href="%s" class="welcome-icon send_test_email">%s</a></li>', $this->getPageUrl( PostmanSendTestEmailController::EMAIL_TEST_SLUG ), __( 'Send a Test Email', 'post-smtp' ) );
|
351 |
+
} else {
|
352 |
+
printf( '<li><div class="welcome-icon send_test_email">%s</div></li>', __( 'Send a Test Email', 'post-smtp' ) );
|
353 |
+
}
|
354 |
+
|
355 |
+
// import-export-reset menu item
|
356 |
+
if ( ! $this->options->isNew() || true ) {
|
357 |
+
$purgeLinkPattern = '<li><a href="%1$s" class="welcome-icon oauth-authorize">%2$s</a></li>';
|
358 |
+
} else {
|
359 |
+
$purgeLinkPattern = '<li>%2$s</li>';
|
360 |
+
}
|
361 |
+
$importTitle = __( 'Import', 'post-smtp' );
|
362 |
+
$exportTile = __( 'Export', 'post-smtp' );
|
363 |
+
$resetTitle = __( 'Reset Plugin', 'post-smtp' );
|
364 |
+
$importExportReset = sprintf( '%s/%s/%s', $importTitle, $exportTile, $resetTitle );
|
365 |
+
printf( $purgeLinkPattern, $this->getPageUrl( PostmanAdminController::MANAGE_OPTIONS_PAGE_SLUG ), sprintf( '%s', $importExportReset ) );
|
366 |
+
print '</ul>';
|
367 |
+
print '</div>';
|
368 |
+
print '<div class="welcome-panel-column welcome-panel-last">';
|
369 |
+
printf( '<h4>%s</h4>', _x( 'Troubleshooting', 'Main Menu', 'post-smtp' ) );
|
370 |
+
print '<ul>';
|
371 |
+
printf( '<li><a href="%s" class="welcome-icon run-port-test">%s</a></li>', $this->getPageUrl( PostmanConnectivityTestController::PORT_TEST_SLUG ), __( 'Connectivity Test', 'post-smtp' ) );
|
372 |
+
printf( '<li><a href="%s" class="welcome-icon run-port-test">%s</a></li>', $this->getPageUrl( PostmanDiagnosticTestController::DIAGNOSTICS_SLUG ), __( 'Diagnostic Test', 'post-smtp' ) );
|
373 |
+
printf( '<li><a href="%s" data-security="%s" class="welcome-icon release-lock-file">%s</a></li>', '#', wp_create_nonce( "postman" ), __( 'Release Lock File Error', 'post-smtp' ) );
|
374 |
+
printf( '<li><a href="https://postmansmtp.com/forums/" class="welcome-icon postman_support">%s</a></li>', __( 'Online Support', 'post-smtp' ) );
|
375 |
+
printf( '<li><img class="align-middle" src="' . plugins_url( 'style/images/new.gif', dirname( __DIR__ ) . '/postman-smtp.php' ) . '"><a target="blank" class="align-middle" href="https://postmansmtp.com/category/guides/" class="welcome-icon postman_guides">%s</a></li>', __( 'Guides', 'post-smtp' ) );
|
376 |
+
print '</ul></div></div></div></div>';
|
377 |
+
?>
|
378 |
+
<div class="twitter-iframe-wrap" style="min-width: 300px;">
|
379 |
+
<a class="twitter-timeline" data-height="304" href="https://twitter.com/PostSMTP?ref_src=twsrc%5Etfw">Tweets by PostSMTP</a> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
|
380 |
+
</div>
|
381 |
+
</div>
|
382 |
+
<?php
|
383 |
}
|
384 |
}
|
385 |
}
|
Postman/PostmanWpMail.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
if ( ! class_exists( 'PostmanWpMail' ) ) {
|
3 |
|
4 |
/**
|
@@ -29,11 +30,11 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
|
|
29 |
* Exceptions are held for later inspection.
|
30 |
* An instance of PostmanState updates the success/fail tally.
|
31 |
*
|
32 |
-
* @param
|
33 |
-
* @param
|
34 |
-
* @param
|
35 |
-
* @param
|
36 |
-
* @param
|
37 |
* @return boolean
|
38 |
*/
|
39 |
public function send( $to, $subject, $message, $headers = '', $attachments = array() ) {
|
@@ -55,14 +56,41 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
|
|
55 |
return $this->sendMessage( $postmanMessage, $log );
|
56 |
}
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
/**
|
59 |
* Builds a PostmanMessage based on the WordPress wp_mail parameters
|
60 |
*
|
61 |
-
* @param
|
62 |
-
* @param
|
63 |
-
* @param
|
64 |
-
* @param
|
65 |
-
* @param
|
66 |
*/
|
67 |
private function processWpMailCall( $to, $subject, $message, $headers, $attachments ) {
|
68 |
$this->logger->trace( 'wp_mail parameters before applying WordPress wp_mail filter:' );
|
@@ -147,6 +175,8 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
|
|
147 |
*/
|
148 |
public function sendMessage( PostmanMessage $message, PostmanEmailLog $log ) {
|
149 |
|
|
|
|
|
150 |
// get the Options and AuthToken
|
151 |
$options = PostmanOptions::getInstance();
|
152 |
$authorizationToken = PostmanOAuthToken::getInstance();
|
@@ -254,6 +284,9 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
|
|
254 |
do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_error_data ) );
|
255 |
|
256 |
// return failure
|
|
|
|
|
|
|
257 |
return false;
|
258 |
|
259 |
}
|
@@ -282,7 +315,7 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
|
|
282 |
* Clean up after sending the mail
|
283 |
*
|
284 |
* @param PostmanZendMailEngine $engine
|
285 |
-
* @param
|
286 |
*/
|
287 |
private function postSend( PostmanMailEngine $engine, $startTime, PostmanOptions $options, PostmanModuleTransport $transport ) {
|
288 |
// save the transcript
|
@@ -338,11 +371,11 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
|
|
338 |
/**
|
339 |
* Aggregates all the content into a Message to be sent to the MailEngine
|
340 |
*
|
341 |
-
* @param
|
342 |
-
* @param
|
343 |
-
* @param
|
344 |
-
* @param
|
345 |
-
* @param
|
346 |
*/
|
347 |
private function populateMessageFromWpMailParams( PostmanMessage $message, $to, $subject, $body, $headers, $attachments ) {
|
348 |
$message->addHeaders( $headers );
|
@@ -356,11 +389,11 @@ if ( ! class_exists( 'PostmanWpMail' ) ) {
|
|
356 |
/**
|
357 |
* Trace the parameters to aid in debugging
|
358 |
*
|
359 |
-
* @param
|
360 |
-
* @param
|
361 |
-
* @param
|
362 |
-
* @param
|
363 |
-
* @param
|
364 |
*/
|
365 |
private function traceParameters( $to, $subject, $message, $headers, $attachments ) {
|
366 |
$this->logger->trace( 'to:' );
|
1 |
<?php
|
2 |
+
|
3 |
if ( ! class_exists( 'PostmanWpMail' ) ) {
|
4 |
|
5 |
/**
|
30 |
* Exceptions are held for later inspection.
|
31 |
* An instance of PostmanState updates the success/fail tally.
|
32 |
*
|
33 |
+
* @param mixed $to
|
34 |
+
* @param mixed $subject
|
35 |
+
* @param mixed $body
|
36 |
+
* @param mixed $headers
|
37 |
+
* @param mixed $attachments
|
38 |
* @return boolean
|
39 |
*/
|
40 |
public function send( $to, $subject, $message, $headers = '', $attachments = array() ) {
|
56 |
return $this->sendMessage( $postmanMessage, $log );
|
57 |
}
|
58 |
|
59 |
+
/**
|
60 |
+
* @param PostmanMessage $message
|
61 |
+
* @return PostmanMessage
|
62 |
+
*/
|
63 |
+
private function apply_default_headers( $message ) {
|
64 |
+
$headers[] = 'Message-ID: ' . $this->createMessageId();
|
65 |
+
$message->addHeaders($headers);
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Creates the Message-ID
|
70 |
+
*
|
71 |
+
* @return string
|
72 |
+
*/
|
73 |
+
public function createMessageId() {
|
74 |
+
|
75 |
+
$id = md5(uniqid(time()));
|
76 |
+
|
77 |
+
if (isset($_SERVER["SERVER_NAME"])) {
|
78 |
+
$hostName = $_SERVER["SERVER_NAME"];
|
79 |
+
} else {
|
80 |
+
$hostName = php_uname('n');
|
81 |
+
}
|
82 |
+
|
83 |
+
return $id . '@' . $hostName;
|
84 |
+
}
|
85 |
+
|
86 |
/**
|
87 |
* Builds a PostmanMessage based on the WordPress wp_mail parameters
|
88 |
*
|
89 |
+
* @param mixed $to
|
90 |
+
* @param mixed $subject
|
91 |
+
* @param mixed $message
|
92 |
+
* @param mixed $headers
|
93 |
+
* @param mixed $attachments
|
94 |
*/
|
95 |
private function processWpMailCall( $to, $subject, $message, $headers, $attachments ) {
|
96 |
$this->logger->trace( 'wp_mail parameters before applying WordPress wp_mail filter:' );
|
175 |
*/
|
176 |
public function sendMessage( PostmanMessage $message, PostmanEmailLog $log ) {
|
177 |
|
178 |
+
$this->apply_default_headers( $message );
|
179 |
+
|
180 |
// get the Options and AuthToken
|
181 |
$options = PostmanOptions::getInstance();
|
182 |
$authorizationToken = PostmanOAuthToken::getInstance();
|
284 |
do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_error_data ) );
|
285 |
|
286 |
// return failure
|
287 |
+
if ( PostmanOptions::getInstance()->getSmtpMailer() == 'phpmailer' ) {
|
288 |
+
throw new phpmailerException($e->getMessage(), $e->getCode());
|
289 |
+
}
|
290 |
return false;
|
291 |
|
292 |
}
|
315 |
* Clean up after sending the mail
|
316 |
*
|
317 |
* @param PostmanZendMailEngine $engine
|
318 |
+
* @param mixed $startTime
|
319 |
*/
|
320 |
private function postSend( PostmanMailEngine $engine, $startTime, PostmanOptions $options, PostmanModuleTransport $transport ) {
|
321 |
// save the transcript
|
371 |
/**
|
372 |
* Aggregates all the content into a Message to be sent to the MailEngine
|
373 |
*
|
374 |
+
* @param mixed $to
|
375 |
+
* @param mixed $subject
|
376 |
+
* @param mixed $body
|
377 |
+
* @param mixed $headers
|
378 |
+
* @param mixed $attachments
|
379 |
*/
|
380 |
private function populateMessageFromWpMailParams( PostmanMessage $message, $to, $subject, $body, $headers, $attachments ) {
|
381 |
$message->addHeaders( $headers );
|
389 |
/**
|
390 |
* Trace the parameters to aid in debugging
|
391 |
*
|
392 |
+
* @param mixed $to
|
393 |
+
* @param mixed $subject
|
394 |
+
* @param mixed $body
|
395 |
+
* @param mixed $headers
|
396 |
+
* @param mixed $attachments
|
397 |
*/
|
398 |
private function traceParameters( $to, $subject, $message, $headers, $attachments ) {
|
399 |
$this->logger->trace( 'to:' );
|
Postman/PostmanWpMailBinder.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
if (! class_exists ( 'PostmanWpMailBinder' )) {
|
3 |
class PostmanWpMailBinder {
|
4 |
private $logger;
|
5 |
-
|
6 |
private $bindError;
|
7 |
|
8 |
/**
|
@@ -26,7 +26,7 @@ if (! class_exists ( 'PostmanWpMailBinder' )) {
|
|
26 |
/**
|
27 |
* Return the Singleton instance
|
28 |
*
|
29 |
-
* @return
|
30 |
*/
|
31 |
public static function getInstance() {
|
32 |
static $inst = null;
|
@@ -90,8 +90,6 @@ if (! class_exists ( 'PostmanWpMailBinder' )) {
|
|
90 |
*
|
91 |
* If the function does not exist, then the replacement was successful
|
92 |
* and we set a success flag.
|
93 |
-
*
|
94 |
-
* @return boolean
|
95 |
*/
|
96 |
private function replacePluggableFunctionWpMail() {
|
97 |
/**
|
2 |
if (! class_exists ( 'PostmanWpMailBinder' )) {
|
3 |
class PostmanWpMailBinder {
|
4 |
private $logger;
|
5 |
+
public $bound;
|
6 |
private $bindError;
|
7 |
|
8 |
/**
|
26 |
/**
|
27 |
* Return the Singleton instance
|
28 |
*
|
29 |
+
* @return PostmanWpMailBinder
|
30 |
*/
|
31 |
public static function getInstance() {
|
32 |
static $inst = null;
|
90 |
*
|
91 |
* If the function does not exist, then the replacement was successful
|
92 |
* and we set a success flag.
|
|
|
|
|
93 |
*/
|
94 |
private function replacePluggableFunctionWpMail() {
|
95 |
/**
|
Postman/extra/donation.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$postman_dismiss_donation = get_option('postman_dismiss_donation');
|
3 |
+
|
4 |
+
if ( empty( $postman_dismiss_donation ) || isset( $in_wizard ) ) : ?>
|
5 |
+
<div class="updated settings-error notice is-dismissible post-smtp-donation">
|
6 |
+
<p style="font-size: 1.1em;">It is hard to continue development and support for this free plugin without contributions from users like you.<br>
|
7 |
+
If you enjoy using <strong>Post SMTP</strong> and find it useful, please consider making a donation.<br>
|
8 |
+
Your donation will help encourage and support the plugin's continued development and better user support.</p>
|
9 |
+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
|
10 |
+
<input type="hidden" name="cmd" value="_s-xclick" />
|
11 |
+
<input type="hidden" name="hosted_button_id" value="4B3PJANHBA7MG" />
|
12 |
+
<input type="image" src="https://www.paypalobjects.com/en_US/IL/i/btn/btn_donateCC_LG.gif" border="0" name="submit" title="PayPal - The safer, easier way to pay online!" alt="Donate with PayPal button" />
|
13 |
+
<img alt="" border="0" src="https://www.paypal.com/en_IL/i/scr/pixel.gif" width="1" height="1" />
|
14 |
+
</form>
|
15 |
+
<button style="z-index: 100;" data-security="<?php echo wp_create_nonce('postsmtp'); ?>" type="button" class="notice-dismiss donation-dismiss">
|
16 |
+
<span class="screen-reader-text">Dismiss this notice.</span>
|
17 |
+
</button>
|
18 |
+
</div>
|
19 |
+
<?php endif; ?>
|
Postman/notifications/PostmanMailNotify.php
CHANGED
@@ -7,6 +7,6 @@ class PostmanMailNotify implements Postman_Notify {
|
|
7 |
$to_email = apply_filters( 'post_smtp_notify_email',get_bloginfo( 'admin_email' ) );
|
8 |
$domain = get_bloginfo( 'url' );
|
9 |
|
10 |
-
mail( $to_email, "{$domain}: " . __( 'Post SMTP email error',
|
11 |
}
|
12 |
}
|
7 |
$to_email = apply_filters( 'post_smtp_notify_email',get_bloginfo( 'admin_email' ) );
|
8 |
$domain = get_bloginfo( 'url' );
|
9 |
|
10 |
+
mail( $to_email, "{$domain}: " . __( 'Post SMTP email error', 'post-smtp' ), $message , '', "-f{$to_email}" );
|
11 |
}
|
12 |
}
|
README.md
CHANGED
@@ -1,131 +1,244 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
Contact Form 7
|
58 |
-
Gravity Forms
|
59 |
-
Fast Secure Contact Form
|
60 |
-
Visual Forms Builder
|
61 |
-
Contact Form Builder
|
62 |
-
PlanSo Forms
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
Reliable
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
Please note that the Client ID and Client Secret fields are NOT for your username and password. They are for OAuth Credentials only.
|
79 |
|
80 |
-
|
81 |
|
82 |
Your WordPress site is configured with WP_HTTP_BLOCK_EXTERNAL to prevent outbound connections. Add a whitelist rule to wp-config.php:
|
|
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
ERROR AUTHENTICATING WITH THIS CLIENT ID. [ERROR EXECUTING WP_REMOTE_POST: FAILED TO CONNECT TO XXXX]
|
87 |
|
88 |
There is a firewall on port 443 between you and the OAuth2 server. Open up the port for outbound connections.
|
89 |
|
90 |
-
|
|
|
|
|
|
|
91 |
|
92 |
-
|
93 |
-
You used an IP address instead of a domain name (not allowed)
|
94 |
-
ERROR: INVALID_CLIENT … NO SUPPORT EMAIL
|
95 |
|
96 |
-
You've forgotten to choose an email address in the consent screen.
|
97 |
|
98 |
-
SMTP ERROR MESSAGES
|
99 |
|
100 |
-
|
101 |
|
102 |
-
|
103 |
-
Login to Webmail and see if there is an "Unusual Activity" warning waiting for your attention
|
104 |
-
COULD NOT OPEN SOCKET
|
105 |
|
106 |
-
|
107 |
-
|
108 |
-
OPERATION TIMED OUT
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
Your may have
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
Your host has likely installed a firewall (REJECT packets) between you and the server. Ask them to open the ports.
|
116 |
|
117 |
-
503
|
118 |
|
119 |
You configured TLS security when you should have selected no security.
|
120 |
|
121 |
-
XOAUTH2
|
|
|
|
|
122 |
|
123 |
-
You may be on a Virtual Private Server that is playing havoc with your communications. Jump ship.
|
124 |
|
125 |
-
|
126 |
|
127 |
To avoid being flagged as spam, you need to prove your email isn't forged. On a custom domain, its up to YOU to set that up:
|
128 |
|
129 |
-
Ensure you are using the correct SMTP server with authentication
|
130 |
-
If you use a custom domain name for email, add an SPF record to your DNS zone file. The SPF is specific to your email provider, for example Google
|
131 |
-
If you use a custom domain name for email, add a DKIM record to your DNS zone file and upload your Domain Key (a digital signature) to, for example Google
|
1 |
+
|
2 |
+
## Version 1.9.8 released - The SMTP Fallback
|
3 |
+
A fallback is a unique solution only exist on Post SMTP.
|
4 |
+
You can configure a backup SMTP, so if your emails are failing your site will keep sending emails !!! [Read the detailes here](https://postmansmtp.com/post-smtp-1-9-7-the-smtp-fallback/)
|
5 |
+
|
6 |
+
## The Only SMTP plugin with chrome Notifications
|
7 |
+
Get notified if your emails are failing inside your Chrome browser. [Download here](https://chrome.google.com/webstore/detail/post-smtp-notifications/npklmbkpbknkmbohdbpikeidiaekjoch?hl=en-US)
|
8 |
+
|
9 |
+
## WordPress Mail SMTP Plugin
|
10 |
+
|
11 |
+
Post SMTP is a next-generation WP Mail SMTP plugin, that assists in the delivery of email generated by your WordPress site. Post SMTP is the first and only plugin to support the [latest security standards](http://googleonlinesecurity.blogspot.ca/2014/04/new-security-measures-will-affect-older.html). With OAuth 2.0, there is **no need** to [store your email passsword](http://blog.codinghorror.com/youre-probably-storing-passwords-incorrectly/) in the WordPress database where it might be found.
|
12 |
+
|
13 |
+
The **Connectivity Test** and intelligent **Setup Wizard** scan your SMTP server to detect firewall blocks and eliminate configuration mistakes. The built-in **Email Log** is an invaluable resource for [diagnosing problems](https://wordpress.org/support/topic/ugly-e-mails-no-html-and-no-special-characters?replies=15) with emails. Even hosts that block the standard SMTP ports, like GoDaddy or Bluehost, can't stop your email as **Post SMTP can deliver via HTTPS** if it can't use SMTP.
|
14 |
+
|
15 |
+
Post SMTP is *not* another WP Mail SMTP clone like WP Bank or Easy SMTP. It replaces the default WordPress SMTP library, PHPMailer, with the heavy-duty Zend_Mail. Never [lose an email to PHP mail()](http://www.jvfconsulting.com/blog/php-mail-function-vs-smtp-guaranteed-delivery/) again.
|
16 |
+
|
17 |
+
### The Most Fast And Easy
|
18 |
+
See how fast and easy to setup Post SMTP with Google/Gsuite or any SMTP service.
|
19 |
+
|
20 |
+
https://www.youtube.com/watch?v=z-x1DhcAN0o
|
21 |
+
|
22 |
+
### Standard Features
|
23 |
+
* Easy-to-use, powerful Setup Wizard for perfect configuration
|
24 |
+
* Commercial-grade Connectivity Tester to diagnose server issues
|
25 |
+
* Log and resend all emails; see the exact cause of failed emails
|
26 |
+
* Supports [International alphabets](https://tools.ietf.org/html/rfc6530), [HTML Mail](https://en.wikipedia.org/wiki/HTML_email) and [MultiPart/Alternative](https://en.wikipedia.org/wiki/MIME#Alternative)
|
27 |
+
* Supports forced recipients (cc, bcc, to) and custom email headers
|
28 |
+
* [SASL](https://en.wikipedia.org/wiki/Simple_Authentication_and_Security_Layer) Support: Plain/Login/CRAM-MD5/[XOAUTH2](https://en.wikipedia.org/wiki/OAuth#OAuth_2.0) authentication
|
29 |
+
* Security Support: [SMTPS](https://en.wikipedia.org/wiki/SMTPS) and [STARTTLS](https://en.wikipedia.org/wiki/STARTTLS) ([SSL/TLS](https://en.wikipedia.org/wiki/Transport_Layer_Security))
|
30 |
+
* Copy configuration to other instances of Post
|
31 |
+
|
32 |
+
## OAuth 2.0 Features
|
33 |
+
* Supports the proprietary OAuth 2.0 implementations of Gmail, Hotmail and Yahoo
|
34 |
+
* Fire-and-forget delivery continues even if your password changes
|
35 |
+
* Gmail: By combining OAuth2 and the Gmail API, Post can deliver where other plugins can not
|
36 |
+
|
37 |
+
## API (HTTPS) Email Support
|
38 |
+
* Gmail API for sending Gmail and Google Apps email (requires a [Google](https://accounts.google.com/signup) account)
|
39 |
+
Often bloggers and small business owners don't want to use third-party SMTP services. Well you can use your Gmail or G Suite account for SMTP emails.
|
40 |
+
<a href="https://www.cloudways.com/blog/post-smtp-mailer-fork-of-wordpress-postman-smtp-plugin/" rel="friend">Check the guide I wrote</a>
|
41 |
+
|
42 |
+
* Mandrill API for sending any email (requires a [Mandrill](http://www.mandrillapp.com) account)
|
43 |
+
Mandrill is an email infrastructure service offered as an add-on for MailChimp that you can use to send personalized, one-to-one e-commerce emails, or automated transactional emails.
|
44 |
+
|
45 |
+
* Mailgun API for sending any email (requires a [Mailgun](http://www.mailgun.com) account)
|
46 |
+
Mailgun SMTP is a popular SMTP service provider that allows you to send large quantities of emails. They allow you to send your first 10,000 emails for free every month.
|
47 |
+
|
48 |
+
* SendGrid API for sending any email (requires a [SendGrid](https://sendgrid.com) account and PHP 5.3)
|
49 |
+
SendGrid has a free SMTP plan that you can use to send up to 100 emails per day. With our native SendGrid SMTP integration, you can easily and securely set up SendGrid SMTP on your WordPress site.
|
50 |
+
|
51 |
+
> Post SMTP needs [translators](https://translate.wordpress.org/projects/wp-plugins/post-smtp/stable)! If you are a non-English speaker, please get involved!
|
52 |
+
|
53 |
+
## Compatibile With..
|
54 |
+
* [Woocommerce](https://wordpress.org/plugins/woocommerce/)
|
55 |
+
* [WPForms](https://wordpress.org/plugins/wpforms-lite/)
|
56 |
+
* [Elementor Forms](https://elementor.com/features/form-widget/)
|
57 |
+
* [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
|
58 |
+
* [Gravity Forms](http://www.gravityforms.com)
|
59 |
+
* [Fast Secure Contact Form](https://wordpress.org/plugins/si-contact-form/)
|
60 |
+
* [Visual Forms Builder](https://wordpress.org/plugins/visual-form-builder/)
|
61 |
+
* [Contact Form Builder](https://wordpress.org/plugins/contact-form-builder/)
|
62 |
+
* [PlanSo Forms](https://wordpress.org/plugins/planso-forms/)
|
63 |
+
* [Quform](https://www.quform.com/)
|
64 |
+
* [MyMail Newsletter](http://revaxarts-themes.com/?t=mymail) by revaxarts
|
65 |
+
* [SendPress Newsletters](https://wordpress.org/plugins/sendpress/)
|
66 |
+
* [WP HTML Mail](https://wordpress.org/plugins/wp-html-mail/)
|
67 |
+
* [Email Templates](https://wordpress.org/plugins/email-templates/)
|
68 |
+
* [WordPress Leads](https://wordpress.org/plugins/leads/)
|
69 |
+
* .. and every other plugin that uses the WordPress API [wp_mail](https://codex.wordpress.org/Function_Reference/wp_mail) to send mail!
|
70 |
+
|
71 |
+
## Requirements
|
72 |
+
* WordPress 3.9 and PHP 5.6 with SPL and iconv
|
73 |
+
* Memory: 750KiB per process at idle
|
74 |
+
* Reliable mail delivery with custom email domains requires an SPF record
|
75 |
+
* Reliable SMTP delivery requires credentials with an email service provider
|
76 |
+
* OAuth 2.0 features require a Gmail, Hotmail or Yahoo mail OAuth 2.0 credentials
|
77 |
+
|
78 |
+
## CREDITS
|
79 |
+
|
80 |
+
Post SMTP (aka Postman SMTP) plugin was originally created by Jason Hendriks.
|
81 |
+
|
82 |
+
## Installation
|
83 |
+
|
84 |
+
> To send email reliably, you must use the SMTP server assigned to that email. If Post is unable to connect to the right SMTP server, you may have to ask your host to open the ports, or create a new email account managed by your host, or switch hosts!
|
85 |
+
>
|
86 |
+
> The Connectivity Test utility will tell you which ports are open and the actions available to you.
|
87 |
+
|
88 |
+
= Easy install and setup! (Recommended for all users) =
|
89 |
+
1. Install and activate the plugin through the 'Plugins' menu in WordPress.
|
90 |
+
1. In the WordPress 'Settings' menu select 'Post SMTP'.
|
91 |
+
1. Choose 'Start the Wizard' and follow the instructions.
|
92 |
+
|
93 |
+
## To manually configure Password Authentication (Intermediate users only)
|
94 |
+
|
95 |
+
1. Choose configure manually
|
96 |
+
1. In 'Transport', choose 'SMTP'
|
97 |
+
1. In 'Outgoing Mail Server Hostname', enter the SMTP Server's hostname
|
98 |
+
1. In 'Outgoing Mail Server Port', enter the SMTP Server's port
|
99 |
+
1. In 'Security' choose the appropriate type (a good guess is SMTPS for port 465, STARTTLS otherwise)
|
100 |
+
1. In 'Authentication', choose the authentication type (a good guess is 'Plain')
|
101 |
+
1. If your Authentication method is not 'None', enter your username (probably your email address) and password.
|
102 |
+
1. Choose the 'Message' tab.
|
103 |
+
1. In 'Envelope From Address' enter your email address. This MUST be the same address you login to webmail with.
|
104 |
+
1. In 'Message From Address' enter your email address. Or this can be an alias, mailing list, or group email if you wish.
|
105 |
+
1. Choose the Save Changes button.
|
106 |
+
1. Send yourself a test email.
|
107 |
+
|
108 |
+
## To manually configure OAuth 2.0 Authentication (Advanced users only)
|
109 |
+
|
110 |
+
1. Choose configure manually
|
111 |
+
1. In 'Transport', choose 'SMTP'
|
112 |
+
1. In 'Outgoing Mail Server Hostname', enter the SMTP Server's hostname
|
113 |
+
1. In 'Outgoing Mail Server Port', enter the SMTP Server's port
|
114 |
+
1. In 'Security' choose the appropriate type (a good guess is SMTPS for port 465, StartTLS otherwise)
|
115 |
+
1. In 'Authentication' choose 'OAuth 2.0'
|
116 |
+
1. Post will give you a link to the Client ID maintenance page of your email service provider. Create a Client ID for your WordPress site.. [instructions for this are detailed in the FAQ](https://wordpress.org/plugins/post-smtp/faq/)
|
117 |
+
1. Copy your generated Client ID and Client secret into the plugin's Settings page.
|
118 |
+
1. Choose the 'Message' tab.
|
119 |
+
1. In 'Envelope From Address' enter your email address. This MUST be the same address you login to webmail with.
|
120 |
+
1. In 'Message From Address' enter your email address. Or this can be an alias, mailing list, or group email if you wish.
|
121 |
+
1. Choose the Save Changes button.
|
122 |
+
1. Choose the 'Request OAuth2 Permission' link and follow the instructions.
|
123 |
+
1. Send yourself a test email.
|
124 |
+
|
125 |
+
> Post is developed on OS X with PHP 5.5.14 and Apache 2.4.9. Post is tested in a [Red Hat OpenShift](http://www.openshift.com/) environment with PHP 5.3.3 and Apache 2.2.15 with Gmail, Hotmail and Yahoo Mail (US). Post is tested with [mailtrap.io](http://mailtrap.io).
|
126 |
+
|
127 |
+
|
128 |
+
|
129 |
+
## Frequently Asked Questions
|
130 |
+
|
131 |
+
### What is OAuth 2.0?
|
132 |
+
|
133 |
+
A modern replacement for traditional password-based authentication. Post supports the OAuth 2.0 implementations of all three major e-mail providers: Gmail, Hotmail and Yahoo Mail.
|
134 |
+
|
135 |
+
### How does OAuth 2.0 work?
|
136 |
+
|
137 |
+
Post requests a limited access OAuth 2.0 token (valet key) to access the APIs (enter the house) and perform a specific service (handle Gmail, stay out of Google Docs) with no need for you to surrender your username and password credentials (master house key).
|
138 |
+
|
139 |
+
Once access is granted, Post commandeers the WordPress wp_mail() function to provide an incredibly stable mail sub-system.
|
140 |
+
|
141 |
+
### Can't I just tell Google to allow less secure apps and keep using my old password?
|
142 |
+
|
143 |
+
Google does have a setting to [allow less secure apps](https://support.google.com/accounts/answer/6010255) but this option is [not available](http://plugins.svn.wordpress.org/Post-smtp/assets/Screen%20Shot%202015-02-21%20at%208.52.13%20PM.png) if you're using *Google Apps* to manage a domain.
|
144 |
+
|
145 |
+
There are many reasons why OAuth 2.0 is better than any password-based mechanism:
|
146 |
+
|
147 |
+
* Post will never ask for your password, so your password can't be stolen
|
148 |
+
* If you change your password regularly, you will never have to update Post's configuration
|
149 |
+
* You have tighter control over the data Post has access to. For Google users it can never access your Calendar or Docs or YouTube; for Yahoo users it can never access your Flickr
|
150 |
+
* If your WordPress site gets hacked, you can revoke Post's email access without impacting any other application or website that has access to your account
|
151 |
+
|
152 |
+
> **[NEVER give out your Gmail, Microsoft or Yahoo password](http://blog.varonis.com/giving-away-your-passwords/)** to a 3rd-party or 3rd-party program that you don't fully trust.
|
153 |
+
|
154 |
+
### What is a Client ID?
|
155 |
+
To use OAuth, your website needs it's own Client ID. The Client ID is used to control authentication and authorization and is tied to the specific URL of your website. If you manage several websites, you will need a different Client ID for each one.
|
156 |
+
|
157 |
+
### How do I get a Google Client ID? (For Gmail users only!)
|
158 |
+
Go to [Configure Post SMTP with Gmail\Gsuite OAuth](https://postmansmtp.com/how-to-configure-post-smtp-with-gmailgsuite-using-oauth/)
|
159 |
+
|
160 |
+
### How do I get a Microsoft Client ID? (For Hotmail/Live/Outlook.com users only!)
|
161 |
+
1. Go to [Microsoft account Developer Center](https://account.live.com/developers/applications/index) and select 'Create application'.
|
162 |
+
1. In the 'Application name' field enter 'Post SMTP'. Select 'I accept.'
|
163 |
+
1. Select 'API Settings' from under 'Settings'.
|
164 |
+
1. In 'Redirect URL', enter the redirect URI given by Post (either from the wizard, or from the manual configuration page). Select Save.
|
165 |
+
1. Select 'App Settings' from under 'Settings'.
|
166 |
+
1. Enter the Client ID and Client Secret displayed here into Post's settings page.
|
167 |
+
|
168 |
+
### How do I get a Yahoo Client ID? (For Yahoo Mail users only!) =
|
169 |
+
1. Go to [Yahoo Developer Network](https://developer.yahoo.com/apps/) and select 'Create an App'.
|
170 |
+
1. In the 'Application Name' field enter 'Post SMTP'. For 'Application Type' choose 'Web Application'.
|
171 |
+
1. In 'Home Page URL', enter the 'Home Page URL' given by Post.
|
172 |
+
1. In 'Callback Domain', enter the 'Callback Domain' given by Post.
|
173 |
+
1. Under 'API Permissions' choose 'Mail'. Under 'Mail' choose 'Read/Write'
|
174 |
+
1. Click 'Create App'
|
175 |
+
1. Enter the Client ID and Client Secret displayed here into Post's settings page.
|
176 |
+
|
177 |
+
### How can I revoke Post's OAuth 2.0 access?
|
178 |
+
* If you have a Google Account, from the [Google Developer's Console](https://www.google.com/accounts/Logout?continue=https://console.developers.google.com) use the Delete button under the Client ID.
|
179 |
+
* If you have a Microsoft Live account, from the [Microsoft account Developer Center](https://account.live.com/developers/applications/index), select the Application and choose Delete Application.
|
180 |
+
* If you have a Yahoo Account, from the [Yahoo Developer Network My Apps](https://developer.yahoo.com/apps/), select the Application and choose Delete App.
|
181 |
+
|
182 |
+
|
183 |
+
|
184 |
+
## Grant OAuth permission error messages
|
185 |
|
186 |
Please note that the Client ID and Client Secret fields are NOT for your username and password. They are for OAuth Credentials only.
|
187 |
|
188 |
+
### Error authenticating with this Client ID. [Error executing wp_remote_post: The user has blocked requests via HTTP.]
|
189 |
|
190 |
Your WordPress site is configured with WP_HTTP_BLOCK_EXTERNAL to prevent outbound connections. Add a whitelist rule to wp-config.php:
|
191 |
+
> define('WP_ACCESSIBLE_HOSTS', 'www.googleapis.com, login.live.com, api.login.yahoo.com');
|
192 |
|
193 |
+
### Error authenticating with this Client ID. [Error executing wp_remote_post: Failed to connect to xxxx] =
|
|
|
|
|
194 |
|
195 |
There is a firewall on port 443 between you and the OAuth2 server. Open up the port for outbound connections.
|
196 |
|
197 |
+
### Error: redirect_uri_mismatch
|
198 |
+
|
199 |
+
* You did not enter the Redirect URI correctly, watch the [instructional video](https://vimeo.com/128589255)
|
200 |
+
* You used an IP address instead of a domain name (not allowed)
|
201 |
|
202 |
+
### Error: invalid_client ... no support email
|
|
|
|
|
203 |
|
204 |
+
You've [forgotten to choose an email address in the consent screen](https://wordpress.org/support/topic/status-Post-is-not-sending-mail-1?replies=7).
|
205 |
|
|
|
206 |
|
207 |
+
## SMTP Error Messages
|
208 |
|
209 |
+
### Communication Error [334] – make sure the Envelope From Email is the same account used to create the Client ID.
|
|
|
|
|
210 |
|
211 |
+
* This is almost always caused by being logged in to Google/Microsoft/Yahoo with a different user than the one Post is configured to send mail with. Logout and try again with the correct user
|
212 |
+
* Login to [Webmail](http://www.gmail.com) and see if there is an "Unusual Activity" warning waiting for your attention
|
|
|
213 |
|
214 |
+
### Could not open socket
|
215 |
+
|
216 |
+
* Your host may have installed a firewall between you and the server. Ask them to open the ports.
|
217 |
+
* Your may have tried to (incorrectly) use SSL over port 587. Check your encryption and port settings.
|
218 |
+
|
219 |
+
### Operation Timed out
|
220 |
+
|
221 |
+
* Your host may have poor connectivity to the mail server. Try doubling the Read Timeout.
|
222 |
+
* Your host may have installed a firewall (DROP packets) between you and the server. Ask them to open the ports.
|
223 |
+
* Your may have tried to (incorrectly) use TLS over port 465. Check your encryption and port settings.
|
224 |
+
|
225 |
+
### Connection refused
|
226 |
|
227 |
Your host has likely installed a firewall (REJECT packets) between you and the server. Ask them to open the ports.
|
228 |
|
229 |
+
### 503 Bad sequence of commands
|
230 |
|
231 |
You configured TLS security when you should have selected no security.
|
232 |
|
233 |
+
### XOAUTH2 authentication mechanism not supported
|
234 |
+
|
235 |
+
You may be on a Virtual Private Server that is [playing havoc with your communications](https://wordpress.org/support/topic/oh-bother-xoauth2-authentication-mechanism-not-supported?replies=9). Jump ship.
|
236 |
|
|
|
237 |
|
238 |
+
### Mail ends up in the Spam folder =
|
239 |
|
240 |
To avoid being flagged as spam, you need to prove your email isn't forged. On a custom domain, its up to YOU to set that up:
|
241 |
|
242 |
+
* Ensure you are using the correct SMTP server with authentication - the correct SMTP server is the one defined by your email service's SPF record
|
243 |
+
* If you use a custom domain name for email, add an [SPF record](http://www.openspf.org/Introduction) to your DNS zone file. The SPF is specific to your email provider, for example [Google](https://support.google.com/a/answer/33786)
|
244 |
+
* If you use a custom domain name for email, add a DKIM record to your DNS zone file and upload your Domain Key (a digital signature) to, for example [Google]((https://support.google.com/a/answer/174124?hl=en))
|
postman-smtp.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Post SMTP
|
4 |
* Plugin URI: https://wordpress.org/plugins/post-smtp/
|
5 |
* Description: Email not reliable? Post SMTP is the first and only WordPress SMTP plugin to implement OAuth 2.0 for Gmail, Hotmail and Yahoo Mail. Setup is a breeze with the Configuration Wizard and integrated Port Tester. Enjoy worry-free delivery even if your password changes!
|
6 |
-
* Version:
|
7 |
* Author: Yehuda Hassine
|
8 |
* Text Domain: post-smtp
|
9 |
* Author URI: https://postmansmtp.com
|
@@ -40,6 +40,8 @@
|
|
40 |
|
41 |
define( 'POST_BASE', __FILE__ );
|
42 |
define( 'POST_PATH', __DIR__ );
|
|
|
|
|
43 |
|
44 |
$postman_smtp_exist = in_array( 'postman-smtp/postman-smtp.php', (array) get_option( 'active_plugins', array() ) );
|
45 |
$required_php_version = version_compare( PHP_VERSION, '5.6.0', '<' );
|
@@ -114,7 +116,7 @@ add_action( 'admin_footer', 'post_dismiss_not_configured' );
|
|
114 |
/**
|
115 |
* Create the main Postman class to start Postman
|
116 |
*
|
117 |
-
* @param
|
118 |
*/
|
119 |
function post_start( $startingMemory ) {
|
120 |
post_setupPostman();
|
@@ -126,5 +128,5 @@ function post_start( $startingMemory ) {
|
|
126 |
*/
|
127 |
function post_setupPostman() {
|
128 |
require_once 'Postman/Postman.php';
|
129 |
-
$kevinCostner = new Postman( __FILE__,
|
130 |
}
|
3 |
* Plugin Name: Post SMTP
|
4 |
* Plugin URI: https://wordpress.org/plugins/post-smtp/
|
5 |
* Description: Email not reliable? Post SMTP is the first and only WordPress SMTP plugin to implement OAuth 2.0 for Gmail, Hotmail and Yahoo Mail. Setup is a breeze with the Configuration Wizard and integrated Port Tester. Enjoy worry-free delivery even if your password changes!
|
6 |
+
* Version: 2.0
|
7 |
* Author: Yehuda Hassine
|
8 |
* Text Domain: post-smtp
|
9 |
* Author URI: https://postmansmtp.com
|
40 |
|
41 |
define( 'POST_BASE', __FILE__ );
|
42 |
define( 'POST_PATH', __DIR__ );
|
43 |
+
define( 'POST_URL', plugins_url('', POST_BASE ) );
|
44 |
+
define( 'POST_SMTP_VER', '2.0' );
|
45 |
|
46 |
$postman_smtp_exist = in_array( 'postman-smtp/postman-smtp.php', (array) get_option( 'active_plugins', array() ) );
|
47 |
$required_php_version = version_compare( PHP_VERSION, '5.6.0', '<' );
|
116 |
/**
|
117 |
* Create the main Postman class to start Postman
|
118 |
*
|
119 |
+
* @param mixed $startingMemory
|
120 |
*/
|
121 |
function post_start( $startingMemory ) {
|
122 |
post_setupPostman();
|
128 |
*/
|
129 |
function post_setupPostman() {
|
130 |
require_once 'Postman/Postman.php';
|
131 |
+
$kevinCostner = new Postman( __FILE__, POST_SMTP_VER );
|
132 |
}
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: yehudah
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=yehuda@myinbox.in&item_name=Donation+for+PostSMTP
|
4 |
Tags: postman smtp, postman, smtp, email, mail, mailer, email log, oauth2, gmail, google apps, hotmail, yahoo, mandrill api, sendgrid api, elastic email, office365, mailgun
|
5 |
Requires at least: 3.9
|
6 |
-
Tested up to: 5.
|
7 |
-
Stable tag:
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -12,9 +12,8 @@ Send, log and troubleshoot your Outgoing Email easily. Supports everything: SMTP
|
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
= Version
|
16 |
-
|
17 |
-
You can configure a backup SMTP, so if your emails are failing your site will keep sending emails !!! [Read the detailes here](https://postmansmtp.com/post-smtp-1-9-7-the-smtp-fallback/)
|
18 |
|
19 |
= The Only SMTP plugin with chrome Notifications =
|
20 |
Get notified if your emails are failing inside your Chrome browser. [Download here](https://chrome.google.com/webstore/detail/post-smtp-notifications/npklmbkpbknkmbohdbpikeidiaekjoch?hl=en-US)
|
@@ -290,6 +289,14 @@ To avoid being flagged as spam, you need to prove your email isn't forged. On a
|
|
290 |
|
291 |
== Changelog ==
|
292 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
= 1.9.8 - 2019-02-18
|
294 |
* New: a new from field to the fallback - Can't trust the username as "from" value (email address).
|
295 |
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=yehuda@myinbox.in&item_name=Donation+for+PostSMTP
|
4 |
Tags: postman smtp, postman, smtp, email, mail, mailer, email log, oauth2, gmail, google apps, hotmail, yahoo, mandrill api, sendgrid api, elastic email, office365, mailgun
|
5 |
Requires at least: 3.9
|
6 |
+
Tested up to: 5.2
|
7 |
+
Stable tag: 2.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
= Version 2.0 released - Mailer Type =
|
16 |
+
[Read the detailes here](https://postmansmtp.com/post-smtp-2-0-mailer-type-and-much-more/)
|
|
|
17 |
|
18 |
= The Only SMTP plugin with chrome Notifications =
|
19 |
Get notified if your emails are failing inside your Chrome browser. [Download here](https://chrome.google.com/webstore/detail/post-smtp-notifications/npklmbkpbknkmbohdbpikeidiaekjoch?hl=en-US)
|
289 |
|
290 |
== Changelog ==
|
291 |
|
292 |
+
= 2.0 - 2019-05-15
|
293 |
+
* New: Mailer Type - Added an option to send without overwrite the 'wp_mail' function, better compability to WordPress delivery. hopefully will be the default in the future.
|
294 |
+
* Updated: Sendgrid API was upgraded and rewritten to the new version.
|
295 |
+
* Fixed: Message-Id header was missing on SMTP
|
296 |
+
* Fixed: Email logger optimization - better query for large amount of records.
|
297 |
+
* Fixed: The localization was fixed to match translate.wordpress.org translation system ( Thanks to Niels de Blaauw from Level-Level ).
|
298 |
+
* Fixed: Code and optimization ( Thanks to Niels de Blaauw from Level-Level ).
|
299 |
+
|
300 |
= 1.9.8 - 2019-02-18
|
301 |
* New: a new from field to the fallback - Can't trust the username as "from" value (email address).
|
302 |
|
script/postman.js
CHANGED
@@ -14,6 +14,18 @@ jQuery(document).ready(function($) {
|
|
14 |
});
|
15 |
});
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
$('#postman_trash_all').on('click',function(e) {
|
18 |
if (confirm("Are You Sure?") == false) {
|
19 |
e.preventDefault();
|
14 |
});
|
15 |
});
|
16 |
|
17 |
+
$('.post-smtp-donation .donation-dismiss').on('click', function() {
|
18 |
+
var $this = $(this);
|
19 |
+
var args = {
|
20 |
+
action: 'dismiss_donation_notify',
|
21 |
+
security: $this.data('security'),
|
22 |
+
};
|
23 |
+
|
24 |
+
$.post(ajaxurl, args, function() {
|
25 |
+
$this.parent().slideUp();
|
26 |
+
});
|
27 |
+
});
|
28 |
+
|
29 |
$('#postman_trash_all').on('click',function(e) {
|
30 |
if (confirm("Are You Sure?") == false) {
|
31 |
e.preventDefault();
|
style/images/mailer-type.gif
ADDED
Binary file
|
style/jquery-steps/jquery.steps.css
CHANGED
@@ -163,7 +163,6 @@
|
|
163 |
.wizard > .content > .body
|
164 |
{
|
165 |
float: left;
|
166 |
-
position: absolute;
|
167 |
width: 95%;
|
168 |
height: 95%;
|
169 |
padding: 2.5%;
|
163 |
.wizard > .content > .body
|
164 |
{
|
165 |
float: left;
|
|
|
166 |
width: 95%;
|
167 |
height: 95%;
|
168 |
padding: 2.5%;
|
style/postman.css
CHANGED
@@ -1,7 +1,25 @@
|
|
1 |
@CHARSET "UTF-8";
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
#postman-main-menu.welcome-panel {
|
4 |
padding: 0px 10px 5px;
|
|
|
5 |
}
|
6 |
|
7 |
#postman-main-menu.advanced_config {
|
@@ -76,7 +94,8 @@ dt em {
|
|
76 |
|
77 |
p#back_to_main_menu {
|
78 |
text-align: right;
|
79 |
-
margin-top: 10px
|
|
|
80 |
}
|
81 |
|
82 |
.welcome-panel-column welcome-panel-last {
|
1 |
@CHARSET "UTF-8";
|
2 |
|
3 |
+
.twitter-wrap {
|
4 |
+
display: flex;
|
5 |
+
}
|
6 |
+
|
7 |
+
.twitter-wrap #postman-main-menu {
|
8 |
+
flex: 1;
|
9 |
+
margin: 0;
|
10 |
+
margin-right: 10px;
|
11 |
+
overflow: hidden;
|
12 |
+
max-height: 300px;
|
13 |
+
border-radius: 5px;
|
14 |
+
}
|
15 |
+
|
16 |
+
.welcome-panel-content {
|
17 |
+
width: 100%;
|
18 |
+
}
|
19 |
+
|
20 |
#postman-main-menu.welcome-panel {
|
21 |
padding: 0px 10px 5px;
|
22 |
+
overflow: hidden;
|
23 |
}
|
24 |
|
25 |
#postman-main-menu.advanced_config {
|
94 |
|
95 |
p#back_to_main_menu {
|
96 |
text-align: right;
|
97 |
+
margin-top: 10px;
|
98 |
+
padding-right: 10px;
|
99 |
}
|
100 |
|
101 |
.welcome-panel-column welcome-panel-last {
|