Version Description
(2017-01-18): =
* Fix an odd Undefined property: MailgunAdmin::$defaults when saving config
* Fix strict mode notice for using $mailgun['override-from'] without checking isset
Download this release
Release Info
| Developer | Mailgun |
| Plugin | |
| Version | 1.5.7.1 |
| Comparing to | |
| See all releases | |
Code changes from version 1.5.6 to 1.5.7.1
- CHANGELOG.md +12 -0
- includes/admin.php +24 -3
- includes/options-page.php +1 -1
- includes/wp-mail.php +58 -10
- languages/mailgun-template.po +17 -17
- mailgun.php +152 -2
- readme.txt +22 -8
CHANGELOG.md
CHANGED
|
@@ -1,6 +1,18 @@
|
|
| 1 |
Changelog
|
| 2 |
=========
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
1.5.6 (2016-12-30):
|
| 5 |
* Fix a very subtle bug causing fatal errors with older PHP versions < 5.5
|
| 6 |
* Respect `wp_mail_content_type` (#37 - @FPCSJames)
|
| 1 |
Changelog
|
| 2 |
=========
|
| 3 |
|
| 4 |
+
1.5.7.1 (2017-01-18):
|
| 5 |
+
* Fix an odd `Undefined property: MailgunAdmin::$defaults` when saving config
|
| 6 |
+
* Fix strict mode notice for using `$mailgun['override-from']` without checking `isset`
|
| 7 |
+
|
| 8 |
+
1.5.7 (2017-01-04):
|
| 9 |
+
* Add better support for using recipient variables for batch mailing.
|
| 10 |
+
* Clarify wording on `From Address` note
|
| 11 |
+
* Detect from name and address for `phpmailer_init` / SMTP now will honour Mailgun "From Name / From Addr" settings
|
| 12 |
+
* SMTP configuration test will now provide the error message, if the send fails
|
| 13 |
+
* Fix `undefined variable: content_type` error in `wp-mail.php` (https://wordpress.org/support/topic/minor-bug-on-version-version-1-5-6/#post-8634762)
|
| 14 |
+
* Fix `undefined index: override-from` error in `wp-mail.php` (https://wordpress.org/support/topic/php-notice-undefined-index-override-from/)
|
| 15 |
+
|
| 16 |
1.5.6 (2016-12-30):
|
| 17 |
* Fix a very subtle bug causing fatal errors with older PHP versions < 5.5
|
| 18 |
* Respect `wp_mail_content_type` (#37 - @FPCSJames)
|
includes/admin.php
CHANGED
|
@@ -21,6 +21,11 @@
|
|
| 21 |
|
| 22 |
class MailgunAdmin extends Mailgun
|
| 23 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
/**
|
| 25 |
* Setup backend functionality in WordPress.
|
| 26 |
*
|
|
@@ -64,7 +69,7 @@ class MailgunAdmin extends Mailgun
|
|
| 64 |
$sitename = substr($sitename, 4);
|
| 65 |
}
|
| 66 |
|
| 67 |
-
$defaults = array(
|
| 68 |
'useAPI' => '1',
|
| 69 |
'apiKey' => '',
|
| 70 |
'domain' => '',
|
|
@@ -78,7 +83,7 @@ class MailgunAdmin extends Mailgun
|
|
| 78 |
'tag' => $sitename,
|
| 79 |
);
|
| 80 |
if (!$this->options) {
|
| 81 |
-
$this->options = $defaults;
|
| 82 |
add_option('mailgun', $this->options);
|
| 83 |
}
|
| 84 |
}
|
|
@@ -275,6 +280,16 @@ class MailgunAdmin extends Mailgun
|
|
| 275 |
$options[$key] = trim($value);
|
| 276 |
}
|
| 277 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
$this->options = $options;
|
| 279 |
|
| 280 |
return $options;
|
|
@@ -368,6 +383,12 @@ class MailgunAdmin extends Mailgun
|
|
| 368 |
array('Content-Type: text/plain')
|
| 369 |
);
|
| 370 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 371 |
if ($result) {
|
| 372 |
die(
|
| 373 |
json_encode(
|
|
@@ -384,7 +405,7 @@ class MailgunAdmin extends Mailgun
|
|
| 384 |
array(
|
| 385 |
'message' => __('Failure', 'mailgun'),
|
| 386 |
'method' => $method,
|
| 387 |
-
'error' =>
|
| 388 |
)
|
| 389 |
)
|
| 390 |
);
|
| 21 |
|
| 22 |
class MailgunAdmin extends Mailgun
|
| 23 |
{
|
| 24 |
+
/**
|
| 25 |
+
* @var array $defaults Array of "safe" option defaults.
|
| 26 |
+
*/
|
| 27 |
+
private $defaults;
|
| 28 |
+
|
| 29 |
/**
|
| 30 |
* Setup backend functionality in WordPress.
|
| 31 |
*
|
| 69 |
$sitename = substr($sitename, 4);
|
| 70 |
}
|
| 71 |
|
| 72 |
+
$this->defaults = array(
|
| 73 |
'useAPI' => '1',
|
| 74 |
'apiKey' => '',
|
| 75 |
'domain' => '',
|
| 83 |
'tag' => $sitename,
|
| 84 |
);
|
| 85 |
if (!$this->options) {
|
| 86 |
+
$this->options = $this->defaults;
|
| 87 |
add_option('mailgun', $this->options);
|
| 88 |
}
|
| 89 |
}
|
| 280 |
$options[$key] = trim($value);
|
| 281 |
}
|
| 282 |
|
| 283 |
+
if (empty($options['override-from'])) {
|
| 284 |
+
$options['override-from'] = $this->defaults['override-from'];
|
| 285 |
+
}
|
| 286 |
+
// alternatively:
|
| 287 |
+
// foreach ($defaults as $key => $value) {
|
| 288 |
+
// if (empty($options[$key])) {
|
| 289 |
+
// $options[$key] = $value;
|
| 290 |
+
// }
|
| 291 |
+
// }
|
| 292 |
+
|
| 293 |
$this->options = $options;
|
| 294 |
|
| 295 |
return $options;
|
| 383 |
array('Content-Type: text/plain')
|
| 384 |
);
|
| 385 |
|
| 386 |
+
if ((bool) $useAPI) {
|
| 387 |
+
$error_msg = mg_api_last_error();
|
| 388 |
+
} else {
|
| 389 |
+
$error_msg = mg_smtp_last_error();
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
if ($result) {
|
| 393 |
die(
|
| 394 |
json_encode(
|
| 405 |
array(
|
| 406 |
'message' => __('Failure', 'mailgun'),
|
| 407 |
'method' => $method,
|
| 408 |
+
'error' => $error_msg,
|
| 409 |
)
|
| 410 |
)
|
| 411 |
);
|
includes/options-page.php
CHANGED
|
@@ -121,7 +121,7 @@
|
|
| 121 |
</th>
|
| 122 |
<td>
|
| 123 |
<input type="text" class="regular-text" name="mailgun[from-address]" value="<?php esc_attr_e($this->get_option('from-address')); ?>" placeholder="wordpress@mydomain.com" />
|
| 124 |
-
<p class="description"><?php _e('The <address@mydomain.com> part of the sender information (<code>"Excited User <user@samples.mailgun.org>"</code>). This address will appear as the `From` address on sent mail. It is recommended that the @mydomain portion matches your
|
| 125 |
</td>
|
| 126 |
</tr>
|
| 127 |
<tr valign="top">
|
| 121 |
</th>
|
| 122 |
<td>
|
| 123 |
<input type="text" class="regular-text" name="mailgun[from-address]" value="<?php esc_attr_e($this->get_option('from-address')); ?>" placeholder="wordpress@mydomain.com" />
|
| 124 |
+
<p class="description"><?php _e('The <address@mydomain.com> part of the sender information (<code>"Excited User <user@samples.mailgun.org>"</code>). This address will appear as the `From` address on sent mail. <strong>It is recommended that the @mydomain portion matches your Mailgun sending domain.</strong>', 'mailgun'); ?></p>
|
| 125 |
</td>
|
| 126 |
</tr>
|
| 127 |
<tr valign="top">
|
includes/wp-mail.php
CHANGED
|
@@ -68,6 +68,49 @@ function get_mime_content_type($filepath, $default_type = 'text/plain')
|
|
| 68 |
}
|
| 69 |
}
|
| 70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
/**
|
| 72 |
* wp_mail function to be loaded in to override the core wp_mail function
|
| 73 |
* from wp-includes/pluggable.php.
|
|
@@ -180,8 +223,8 @@ function wp_mail($to, $subject, $message, $headers = '', $attachments = array())
|
|
| 180 |
}
|
| 181 |
}
|
| 182 |
|
| 183 |
-
if ($mailgun['override-from'] &&
|
| 184 |
-
&& !empty($mailgun['from-address'])
|
| 185 |
) {
|
| 186 |
$from_name = $mailgun['from-name'];
|
| 187 |
$from_email = $mailgun['from-address'];
|
|
@@ -246,6 +289,11 @@ function wp_mail($to, $subject, $message, $headers = '', $attachments = array())
|
|
| 246 |
'text' => $message,
|
| 247 |
);
|
| 248 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
$body['o:tag'] = '';
|
| 250 |
$body['o:tracking-clicks'] = !empty($mailgun['track-clicks']) ? $mailgun['track-clicks'] : 'no';
|
| 251 |
$body['o:tracking-opens'] = empty($mailgun['track-opens']) ? 'no' : 'yes';
|
|
@@ -276,14 +324,6 @@ function wp_mail($to, $subject, $message, $headers = '', $attachments = array())
|
|
| 276 |
$body['bcc'] = implode(', ', $bcc);
|
| 277 |
}
|
| 278 |
|
| 279 |
-
// Allow external content type filter to function normally
|
| 280 |
-
if (has_filter('wp_mail_content_type')) {
|
| 281 |
-
$content_type = apply_filters(
|
| 282 |
-
'wp_mail_content_type',
|
| 283 |
-
$content_type
|
| 284 |
-
);
|
| 285 |
-
}
|
| 286 |
-
|
| 287 |
// If we are not given a Content-Type from the supplied headers, use
|
| 288 |
// text/html and *attempt* to strip tags and provide a text/plain
|
| 289 |
// version.
|
|
@@ -302,6 +342,14 @@ function wp_mail($to, $subject, $message, $headers = '', $attachments = array())
|
|
| 302 |
unlink($tmppath);
|
| 303 |
}
|
| 304 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
if ('text/plain' === $content_type) {
|
| 306 |
$body['text'] = $message;
|
| 307 |
} else {
|
| 68 |
}
|
| 69 |
}
|
| 70 |
|
| 71 |
+
/**
|
| 72 |
+
* Wordpress filter to mutate a `To` header to use recipient variables.
|
| 73 |
+
* Uses the `mg_use_recipient_vars_syntax` filter to apply the actual
|
| 74 |
+
* change. Otherwise, just a list of `To` addresses will be returned.
|
| 75 |
+
*
|
| 76 |
+
* @param string|array $to_addrs Array or comma-separated list of email addresses to mutate.
|
| 77 |
+
*
|
| 78 |
+
* @return array Array containing list of `To` addresses and recipient vars array
|
| 79 |
+
*
|
| 80 |
+
* @since 1.5.7
|
| 81 |
+
*/
|
| 82 |
+
add_filter('mg_mutate_to_rcpt_vars', 'mg_mutate_to_rcpt_vars_cb');
|
| 83 |
+
function mg_mutate_to_rcpt_vars_cb($to_addrs)
|
| 84 |
+
{
|
| 85 |
+
if (is_string($to_addrs)) {
|
| 86 |
+
$to_addrs = explode(',', $to_addrs);
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
if (has_filter('mg_use_recipient_vars_syntax')) {
|
| 90 |
+
$use_rcpt_vars = apply_filters('mg_use_recipient_vars_syntax', null);
|
| 91 |
+
if ($use_rcpt_vars) {
|
| 92 |
+
$vars = array();
|
| 93 |
+
|
| 94 |
+
$idx = 0;
|
| 95 |
+
foreach ($to_addrs as $addr) {
|
| 96 |
+
$rcpt_vars[$addr] = array("batch_msg_id" => $idx);
|
| 97 |
+
$idx++;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
// TODO: Also add folding to prevent hitting the 998 char limit on headers.
|
| 101 |
+
return array(
|
| 102 |
+
'to' => '%recipient%',
|
| 103 |
+
'rcpt_vars' => json_encode($rcpt_vars),
|
| 104 |
+
);
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
return array(
|
| 109 |
+
'to' => $to_addrs,
|
| 110 |
+
'rcpt_vars' => null,
|
| 111 |
+
);
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
/**
|
| 115 |
* wp_mail function to be loaded in to override the core wp_mail function
|
| 116 |
* from wp-includes/pluggable.php.
|
| 223 |
}
|
| 224 |
}
|
| 225 |
|
| 226 |
+
if ((isset($mailgun['override-from']) && $mailgun['override-from'])
|
| 227 |
+
&& !empty($mailgun['from-name']) && !empty($mailgun['from-address'])
|
| 228 |
) {
|
| 229 |
$from_name = $mailgun['from-name'];
|
| 230 |
$from_email = $mailgun['from-address'];
|
| 289 |
'text' => $message,
|
| 290 |
);
|
| 291 |
|
| 292 |
+
$rcpt_data = apply_filters('mg_mutate_to_rcpt_vars', $to);
|
| 293 |
+
if (!is_null($rcpt_data['rcpt_vars'])) {
|
| 294 |
+
$body['recipient-variables'] = $rcpt_data['rcpt_vars'];
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
$body['o:tag'] = '';
|
| 298 |
$body['o:tracking-clicks'] = !empty($mailgun['track-clicks']) ? $mailgun['track-clicks'] : 'no';
|
| 299 |
$body['o:tracking-opens'] = empty($mailgun['track-opens']) ? 'no' : 'yes';
|
| 324 |
$body['bcc'] = implode(', ', $bcc);
|
| 325 |
}
|
| 326 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
// If we are not given a Content-Type from the supplied headers, use
|
| 328 |
// text/html and *attempt* to strip tags and provide a text/plain
|
| 329 |
// version.
|
| 342 |
unlink($tmppath);
|
| 343 |
}
|
| 344 |
|
| 345 |
+
// Allow external content type filter to function normally
|
| 346 |
+
if (has_filter('wp_mail_content_type')) {
|
| 347 |
+
$content_type = apply_filters(
|
| 348 |
+
'wp_mail_content_type',
|
| 349 |
+
$content_type
|
| 350 |
+
);
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
if ('text/plain' === $content_type) {
|
| 354 |
$body['text'] = $message;
|
| 355 |
} else {
|
languages/mailgun-template.po
CHANGED
|
@@ -1,20 +1,20 @@
|
|
| 1 |
-
# Copyright (C)
|
| 2 |
# This file is distributed under the same license as the Mailgun package.
|
| 3 |
msgid ""
|
| 4 |
msgstr ""
|
| 5 |
-
"Project-Id-Version: Mailgun 1.5.
|
| 6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mailgun\n"
|
| 7 |
"POT-Creation-Date: 2016-12-27 21:02:24+00:00\n"
|
| 8 |
"MIME-Version: 1.0\n"
|
| 9 |
"Content-Type: text/plain; charset=UTF-8\n"
|
| 10 |
"Content-Transfer-Encoding: 8bit\n"
|
| 11 |
-
"PO-Revision-Date:
|
| 12 |
"Last-Translator: Sean Johnson <sean@mailgun.com>\n"
|
| 13 |
"Language-Team: Mailgun <support@mailgun.com>\n"
|
| 14 |
|
| 15 |
-
#. #-#-#-#-# plugin.pot (Mailgun 1.5.
|
| 16 |
#. Plugin Name of the plugin/theme
|
| 17 |
-
#. #-#-#-#-# plugin.pot (Mailgun 1.5.
|
| 18 |
#. Author of the plugin/theme
|
| 19 |
#: includes/admin.php:96 includes/options-page.php:26
|
| 20 |
msgid "Mailgun"
|
|
@@ -39,7 +39,7 @@ msgstr ""
|
|
| 39 |
msgid "Test Configuration"
|
| 40 |
msgstr ""
|
| 41 |
|
| 42 |
-
#: includes/admin.php:169 includes/admin.php:
|
| 43 |
msgid "Failure"
|
| 44 |
msgstr ""
|
| 45 |
|
|
@@ -71,31 +71,31 @@ msgid ""
|
|
| 71 |
"set to work properly! <a href=\"%1$s\">Configure Mailgun now</a>."
|
| 72 |
msgstr ""
|
| 73 |
|
| 74 |
-
#: includes/admin.php:
|
| 75 |
msgid "Settings"
|
| 76 |
msgstr ""
|
| 77 |
|
| 78 |
-
#: includes/admin.php:
|
| 79 |
msgid "Unauthorized"
|
| 80 |
msgstr ""
|
| 81 |
|
| 82 |
-
#: includes/admin.php:
|
| 83 |
msgid "HTTP API"
|
| 84 |
msgstr ""
|
| 85 |
|
| 86 |
-
#: includes/admin.php:
|
| 87 |
msgid "Secure SMTP"
|
| 88 |
msgstr ""
|
| 89 |
|
| 90 |
-
#: includes/admin.php:
|
| 91 |
msgid "SMTP"
|
| 92 |
msgstr ""
|
| 93 |
|
| 94 |
-
#: includes/admin.php:
|
| 95 |
msgid "Mailgun WordPress Plugin Test"
|
| 96 |
msgstr ""
|
| 97 |
|
| 98 |
-
#: includes/admin.php:
|
| 99 |
msgid ""
|
| 100 |
"This is a test email generated by the Mailgun WordPress plugin.\n"
|
| 101 |
"\n"
|
|
@@ -104,7 +104,7 @@ msgid ""
|
|
| 104 |
"The method used to send this email was: %s."
|
| 105 |
msgstr ""
|
| 106 |
|
| 107 |
-
#: includes/admin.php:
|
| 108 |
msgid "Success"
|
| 109 |
msgstr ""
|
| 110 |
|
|
@@ -226,8 +226,8 @@ msgstr ""
|
|
| 226 |
msgid ""
|
| 227 |
"The <address@mydomain.com> part of the sender information (<code>\"Excited "
|
| 228 |
"User <user@samples.mailgun.org>\"</code>). This address will appear as "
|
| 229 |
-
"the `From` address on sent mail. It is recommended that the
|
| 230 |
-
"portion matches your
|
| 231 |
msgstr ""
|
| 232 |
|
| 233 |
#: includes/options-page.php:129
|
|
@@ -320,7 +320,7 @@ msgstr ""
|
|
| 320 |
msgid "Collect name:"
|
| 321 |
msgstr ""
|
| 322 |
|
| 323 |
-
#: mailgun.php:
|
| 324 |
msgid ""
|
| 325 |
"Mailgun has been automatically deactivated because the file <strong>%s</"
|
| 326 |
"strong> is missing. Please reinstall the plugin and reactivate."
|
| 1 |
+
# Copyright (C) 2017 Mailgun
|
| 2 |
# This file is distributed under the same license as the Mailgun package.
|
| 3 |
msgid ""
|
| 4 |
msgstr ""
|
| 5 |
+
"Project-Id-Version: Mailgun 1.5.7\n"
|
| 6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mailgun\n"
|
| 7 |
"POT-Creation-Date: 2016-12-27 21:02:24+00:00\n"
|
| 8 |
"MIME-Version: 1.0\n"
|
| 9 |
"Content-Type: text/plain; charset=UTF-8\n"
|
| 10 |
"Content-Transfer-Encoding: 8bit\n"
|
| 11 |
+
"PO-Revision-Date: 2017-01-04 14:32-0600\n"
|
| 12 |
"Last-Translator: Sean Johnson <sean@mailgun.com>\n"
|
| 13 |
"Language-Team: Mailgun <support@mailgun.com>\n"
|
| 14 |
|
| 15 |
+
#. #-#-#-#-# plugin.pot (Mailgun 1.5.7) #-#-#-#-#
|
| 16 |
#. Plugin Name of the plugin/theme
|
| 17 |
+
#. #-#-#-#-# plugin.pot (Mailgun 1.5.7) #-#-#-#-#
|
| 18 |
#. Author of the plugin/theme
|
| 19 |
#: includes/admin.php:96 includes/options-page.php:26
|
| 20 |
msgid "Mailgun"
|
| 39 |
msgid "Test Configuration"
|
| 40 |
msgstr ""
|
| 41 |
|
| 42 |
+
#: includes/admin.php:169 includes/admin.php:385
|
| 43 |
msgid "Failure"
|
| 44 |
msgstr ""
|
| 45 |
|
| 71 |
"set to work properly! <a href=\"%1$s\">Configure Mailgun now</a>."
|
| 72 |
msgstr ""
|
| 73 |
|
| 74 |
+
#: includes/admin.php:326
|
| 75 |
msgid "Settings"
|
| 76 |
msgstr ""
|
| 77 |
|
| 78 |
+
#: includes/admin.php:348
|
| 79 |
msgid "Unauthorized"
|
| 80 |
msgstr ""
|
| 81 |
|
| 82 |
+
#: includes/admin.php:358
|
| 83 |
msgid "HTTP API"
|
| 84 |
msgstr ""
|
| 85 |
|
| 86 |
+
#: includes/admin.php:360
|
| 87 |
msgid "Secure SMTP"
|
| 88 |
msgstr ""
|
| 89 |
|
| 90 |
+
#: includes/admin.php:360
|
| 91 |
msgid "SMTP"
|
| 92 |
msgstr ""
|
| 93 |
|
| 94 |
+
#: includes/admin.php:366
|
| 95 |
msgid "Mailgun WordPress Plugin Test"
|
| 96 |
msgstr ""
|
| 97 |
|
| 98 |
+
#: includes/admin.php:367
|
| 99 |
msgid ""
|
| 100 |
"This is a test email generated by the Mailgun WordPress plugin.\n"
|
| 101 |
"\n"
|
| 104 |
"The method used to send this email was: %s."
|
| 105 |
msgstr ""
|
| 106 |
|
| 107 |
+
#: includes/admin.php:375 includes/admin.php:377
|
| 108 |
msgid "Success"
|
| 109 |
msgstr ""
|
| 110 |
|
| 226 |
msgid ""
|
| 227 |
"The <address@mydomain.com> part of the sender information (<code>\"Excited "
|
| 228 |
"User <user@samples.mailgun.org>\"</code>). This address will appear as "
|
| 229 |
+
"the `From` address on sent mail. <strong>It is recommended that the "
|
| 230 |
+
"@mydomain portion matches your Mailgun sending domain.</strong>"
|
| 231 |
msgstr ""
|
| 232 |
|
| 233 |
#: includes/options-page.php:129
|
| 320 |
msgid "Collect name:"
|
| 321 |
msgstr ""
|
| 322 |
|
| 323 |
+
#: mailgun.php:123
|
| 324 |
msgid ""
|
| 325 |
"Mailgun has been automatically deactivated because the file <strong>%s</"
|
| 326 |
"strong> is missing. Please reinstall the plugin and reactivate."
|
mailgun.php
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
* Plugin Name: Mailgun
|
| 5 |
* Plugin URI: http://wordpress.org/extend/plugins/mailgun/
|
| 6 |
* Description: Mailgun integration for WordPress
|
| 7 |
-
* Version: 1.5.
|
| 8 |
* Author: Mailgun
|
| 9 |
* Author URI: http://www.mailgun.com/
|
| 10 |
* License: GPLv2 or later
|
|
@@ -31,6 +31,52 @@
|
|
| 31 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
| 32 |
*/
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
class Mailgun
|
| 35 |
{
|
| 36 |
/**
|
|
@@ -57,6 +103,7 @@ class Mailgun
|
|
| 57 |
}
|
| 58 |
} else {
|
| 59 |
add_action('phpmailer_init', array(&$this, 'phpmailer_init'));
|
|
|
|
| 60 |
}
|
| 61 |
}
|
| 62 |
|
|
@@ -99,13 +146,41 @@ class Mailgun
|
|
| 99 |
$secure = (defined('MAILGUN_SECURE') && MAILGUN_SECURE) ? MAILGUN_SECURE : $this->get_option('secure');
|
| 100 |
$password = (defined('MAILGUN_PASSWORD') && MAILGUN_PASSWORD) ? MAILGUN_PASSWORD : $this->get_option('password');
|
| 101 |
|
|
|
|
|
|
|
|
|
|
| 102 |
$phpmailer->Mailer = 'smtp';
|
| 103 |
-
$phpmailer->SMTPSecure = (bool) $secure ? 'ssl' : 'none';
|
| 104 |
$phpmailer->Host = 'smtp.mailgun.org';
|
| 105 |
$phpmailer->Port = (bool) $secure ? 465 : 587;
|
| 106 |
$phpmailer->SMTPAuth = true;
|
| 107 |
$phpmailer->Username = $username;
|
| 108 |
$phpmailer->Password = $password;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
}
|
| 110 |
|
| 111 |
/**
|
|
@@ -416,6 +491,81 @@ class Mailgun
|
|
| 416 |
register_widget('list_widget');
|
| 417 |
add_shortcode('mailgun', array(&$this, 'build_list_form'));
|
| 418 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 419 |
}
|
| 420 |
|
| 421 |
$mailgun = new Mailgun();
|
| 4 |
* Plugin Name: Mailgun
|
| 5 |
* Plugin URI: http://wordpress.org/extend/plugins/mailgun/
|
| 6 |
* Description: Mailgun integration for WordPress
|
| 7 |
+
* Version: 1.5.7.1
|
| 8 |
* Author: Mailgun
|
| 9 |
* Author URI: http://www.mailgun.com/
|
| 10 |
* License: GPLv2 or later
|
| 31 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
| 32 |
*/
|
| 33 |
|
| 34 |
+
/**
|
| 35 |
+
* mg_smtp_last_error is a compound getter/setter for the last error that was
|
| 36 |
+
* encountered during a Mailgun SMTP conversation.
|
| 37 |
+
*
|
| 38 |
+
* @param string $error OPTIONAL
|
| 39 |
+
*
|
| 40 |
+
* @return string Last error that occurred.
|
| 41 |
+
*
|
| 42 |
+
* @since 1.5.0
|
| 43 |
+
*/
|
| 44 |
+
function mg_smtp_last_error($error = null)
|
| 45 |
+
{
|
| 46 |
+
static $last_error;
|
| 47 |
+
|
| 48 |
+
if (null === $error) {
|
| 49 |
+
return $last_error;
|
| 50 |
+
} else {
|
| 51 |
+
$tmp = $last_error;
|
| 52 |
+
$last_error = $error;
|
| 53 |
+
|
| 54 |
+
return $tmp;
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* Debugging output function for PHPMailer.
|
| 60 |
+
*
|
| 61 |
+
* @param string $str Log message
|
| 62 |
+
* @param string $level Logging level
|
| 63 |
+
*
|
| 64 |
+
* @return none
|
| 65 |
+
*
|
| 66 |
+
* @since 1.5.7
|
| 67 |
+
*/
|
| 68 |
+
function phpmailer_debug_output($str, $level)
|
| 69 |
+
{
|
| 70 |
+
error_log("PHPMailer [$level] $str");
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
/**
|
| 74 |
+
* Entrypoint for the Mailgun plugin. Sets up the mailing "strategy" -
|
| 75 |
+
* either API or SMTP.
|
| 76 |
+
*
|
| 77 |
+
* Registers handlers for later actions and sets up config variables with
|
| 78 |
+
* Wordpress.
|
| 79 |
+
*/
|
| 80 |
class Mailgun
|
| 81 |
{
|
| 82 |
/**
|
| 103 |
}
|
| 104 |
} else {
|
| 105 |
add_action('phpmailer_init', array(&$this, 'phpmailer_init'));
|
| 106 |
+
add_action('wp_mail_failed', array(&$this, 'wp_mail_failed'));
|
| 107 |
}
|
| 108 |
}
|
| 109 |
|
| 146 |
$secure = (defined('MAILGUN_SECURE') && MAILGUN_SECURE) ? MAILGUN_SECURE : $this->get_option('secure');
|
| 147 |
$password = (defined('MAILGUN_PASSWORD') && MAILGUN_PASSWORD) ? MAILGUN_PASSWORD : $this->get_option('password');
|
| 148 |
|
| 149 |
+
$from_name = (defined('MAILGUN_FROM_NAME') && MAILGUN_FROM_NAME) ? MAILGUN_FROM_NAME : $this->detect_from_name();
|
| 150 |
+
$from_address = (defined('MAILGUN_FROM_ADDRESS') && MAILGUN_FROM_ADDRESS) ? MAILGUN_FROM_ADDRESS : $this->detect_from_address();
|
| 151 |
+
|
| 152 |
$phpmailer->Mailer = 'smtp';
|
|
|
|
| 153 |
$phpmailer->Host = 'smtp.mailgun.org';
|
| 154 |
$phpmailer->Port = (bool) $secure ? 465 : 587;
|
| 155 |
$phpmailer->SMTPAuth = true;
|
| 156 |
$phpmailer->Username = $username;
|
| 157 |
$phpmailer->Password = $password;
|
| 158 |
+
|
| 159 |
+
$phpmailer->SMTPSecure = (bool) $secure ? 'ssl' : 'none';
|
| 160 |
+
// Without this line... wp_mail for SMTP-only will always return false. But why? :(
|
| 161 |
+
$phpmailer->Debugoutput = 'phpmailer_debug_output';
|
| 162 |
+
$phpmailer->SMTPDebug = 2;
|
| 163 |
+
$phpmailer->From = $from_address;
|
| 164 |
+
$phpmailer->FromName = $from_name;
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
/**
|
| 168 |
+
* Capture and store the failure message from PHPmailer so the user will
|
| 169 |
+
* actually know what is wrong.
|
| 170 |
+
*
|
| 171 |
+
* @param WP_Error $error Error raised by Wordpress/PHPmailer
|
| 172 |
+
*
|
| 173 |
+
* @return none
|
| 174 |
+
*
|
| 175 |
+
* @since 1.5.7
|
| 176 |
+
*/
|
| 177 |
+
public function wp_mail_failed($error)
|
| 178 |
+
{
|
| 179 |
+
if (is_wp_error($error)) {
|
| 180 |
+
mg_smtp_last_error($error->get_error_message());
|
| 181 |
+
} else {
|
| 182 |
+
mg_smtp_last_error($error->__toString());
|
| 183 |
+
}
|
| 184 |
}
|
| 185 |
|
| 186 |
/**
|
| 491 |
register_widget('list_widget');
|
| 492 |
add_shortcode('mailgun', array(&$this, 'build_list_form'));
|
| 493 |
}
|
| 494 |
+
|
| 495 |
+
/**
|
| 496 |
+
* Find the sending "From Name" with a similar process used in `wp_mail`.
|
| 497 |
+
*
|
| 498 |
+
* @return string
|
| 499 |
+
*
|
| 500 |
+
* @since 1.5.7
|
| 501 |
+
*/
|
| 502 |
+
private function detect_from_name()
|
| 503 |
+
{
|
| 504 |
+
$from_name = null;
|
| 505 |
+
|
| 506 |
+
if ($this->get_option('override-from') && !is_null($this->get_option('from-name'))) {
|
| 507 |
+
$from_name = $this->get_option('from-name');
|
| 508 |
+
} else {
|
| 509 |
+
if (is_null($this->get_option('from-name'))) {
|
| 510 |
+
if (function_exists('get_current_site')) {
|
| 511 |
+
$from_name = get_current_site()->site_name;
|
| 512 |
+
} else {
|
| 513 |
+
$from_name = 'WordPress';
|
| 514 |
+
}
|
| 515 |
+
} else {
|
| 516 |
+
$from_name = $this->get_option('from-name');
|
| 517 |
+
}
|
| 518 |
+
}
|
| 519 |
+
|
| 520 |
+
if (has_filter('wp_mail_from_name')) {
|
| 521 |
+
$from_name = apply_filters(
|
| 522 |
+
'wp_mail_from_name',
|
| 523 |
+
$from_name
|
| 524 |
+
);
|
| 525 |
+
}
|
| 526 |
+
|
| 527 |
+
return $from_name;
|
| 528 |
+
}
|
| 529 |
+
|
| 530 |
+
/**
|
| 531 |
+
* Find the sending "From Address" with a similar process used in `wp_mail`.
|
| 532 |
+
*
|
| 533 |
+
* @return string
|
| 534 |
+
*
|
| 535 |
+
* @since 1.5.7
|
| 536 |
+
*/
|
| 537 |
+
private function detect_from_address()
|
| 538 |
+
{
|
| 539 |
+
$from_addr = null;
|
| 540 |
+
|
| 541 |
+
if ($this->get_option('override-from') && !is_null($this->get_option('from-address'))) {
|
| 542 |
+
$from_addr = $this->get_option('from-address');
|
| 543 |
+
} else {
|
| 544 |
+
if (is_null($this->get_option('from-address'))) {
|
| 545 |
+
if (function_exists('get_current_site')) {
|
| 546 |
+
$from_addr = get_current_site()->domain;
|
| 547 |
+
} else {
|
| 548 |
+
$sitedomain = strtolower($_SERVER['SERVER_NAME']);
|
| 549 |
+
if (substr($sitedomain, 0, 4) === 'www.') {
|
| 550 |
+
$sitedomain = substr($sitedomain, 4);
|
| 551 |
+
}
|
| 552 |
+
}
|
| 553 |
+
|
| 554 |
+
$from_addr = $sitedomain;
|
| 555 |
+
} else {
|
| 556 |
+
$from_addr = $this->get_option('from-address');
|
| 557 |
+
}
|
| 558 |
+
}
|
| 559 |
+
|
| 560 |
+
if (has_filter('wp_mail_from')) {
|
| 561 |
+
$from_addr = apply_filters(
|
| 562 |
+
'wp_mail_from',
|
| 563 |
+
$from_addr
|
| 564 |
+
);
|
| 565 |
+
}
|
| 566 |
+
|
| 567 |
+
return $from_addr;
|
| 568 |
+
}
|
| 569 |
}
|
| 570 |
|
| 571 |
$mailgun = new Mailgun();
|
readme.txt
CHANGED
|
@@ -4,8 +4,8 @@ Mailgun for WordPress
|
|
| 4 |
Contributors: Mailgun, sivel, lookahead.io, m35dev
|
| 5 |
Tags: mailgun, smtp, http, api, mail, email
|
| 6 |
Requires at least: 3.3
|
| 7 |
-
Tested up to: 4.7
|
| 8 |
-
Stable tag: 1.5.
|
| 9 |
License: GPLv2 or later
|
| 10 |
|
| 11 |
|
|
@@ -47,12 +47,14 @@ Your web server may not allow outbound SMTP connections on port 465 for secure c
|
|
| 47 |
Yes, using the following constants that can be placed in wp-config.php:
|
| 48 |
|
| 49 |
`
|
| 50 |
-
MAILGUN_USEAPI
|
| 51 |
-
MAILGUN_APIKEY
|
| 52 |
-
MAILGUN_DOMAIN
|
| 53 |
-
MAILGUN_USERNAME
|
| 54 |
-
MAILGUN_PASSWORD
|
| 55 |
-
MAILGUN_SECURE
|
|
|
|
|
|
|
| 56 |
`
|
| 57 |
|
| 58 |
|
|
@@ -68,6 +70,18 @@ MAILGUN_SECURE Type: boolean
|
|
| 68 |
|
| 69 |
== Changelog ==
|
| 70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
= 1.5.6 (2016-12-30): =
|
| 72 |
* Fix a very subtle bug causing fatal errors with older PHP versions < 5.5
|
| 73 |
* Respect `wp_mail_content_type` (#37 - @FPCSJames)
|
| 4 |
Contributors: Mailgun, sivel, lookahead.io, m35dev
|
| 5 |
Tags: mailgun, smtp, http, api, mail, email
|
| 6 |
Requires at least: 3.3
|
| 7 |
+
Tested up to: 4.7.1
|
| 8 |
+
Stable tag: 1.5.7.1
|
| 9 |
License: GPLv2 or later
|
| 10 |
|
| 11 |
|
| 47 |
Yes, using the following constants that can be placed in wp-config.php:
|
| 48 |
|
| 49 |
`
|
| 50 |
+
MAILGUN_USEAPI Type: boolean
|
| 51 |
+
MAILGUN_APIKEY Type: string
|
| 52 |
+
MAILGUN_DOMAIN Type: string
|
| 53 |
+
MAILGUN_USERNAME Type: string
|
| 54 |
+
MAILGUN_PASSWORD Type: string
|
| 55 |
+
MAILGUN_SECURE Type: boolean
|
| 56 |
+
MAILGUN_FROM_NAME Type: string
|
| 57 |
+
MAILGUN_FROM_ADDRESS Type: string
|
| 58 |
`
|
| 59 |
|
| 60 |
|
| 70 |
|
| 71 |
== Changelog ==
|
| 72 |
|
| 73 |
+
= 1.5.7.1 (2017-01-18): =
|
| 74 |
+
* Fix an odd `Undefined property: MailgunAdmin::$defaults` when saving config
|
| 75 |
+
* Fix strict mode notice for using `$mailgun['override-from']` without checking `isset`
|
| 76 |
+
|
| 77 |
+
= 1.5.7 (2017-01-04): =
|
| 78 |
+
* Add better support for using recipient variables for batch mailing.
|
| 79 |
+
* Clarify wording on `From Address` note
|
| 80 |
+
* Detect from name and address for `phpmailer_init` / SMTP now will honour Mailgun "From Name / From Addr" settings
|
| 81 |
+
* SMTP configuration test will now provide the error message, if the send fails
|
| 82 |
+
* Fix `undefined variable: content_type` error in `wp-mail.php` (https://wordpress.org/support/topic/minor-bug-on-version-version-1-5-6/#post-8634762)
|
| 83 |
+
* Fix `undefined index: override-from` error in `wp-mail.php` (https://wordpress.org/support/topic/php-notice-undefined-index-override-from/)
|
| 84 |
+
|
| 85 |
= 1.5.6 (2016-12-30): =
|
| 86 |
* Fix a very subtle bug causing fatal errors with older PHP versions < 5.5
|
| 87 |
* Respect `wp_mail_content_type` (#37 - @FPCSJames)
|
