Mailgun for WordPress - Version 1.2

Version Description

(2014-08-19): = * Fixed errors related to undefined variable. https://github.com/mailgun/wordpress-plugin/pull/3

Download this release

Release Info

Developer Mailgun
Plugin Icon 128x128 Mailgun for WordPress
Version 1.2
Comparing to
See all releases

Code changes from version 1.1 to 1.2

includes/wp-mail.php CHANGED
@@ -139,8 +139,8 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
139
  'text' => $message
140
  );
141
 
142
- $body['o:tracking-clicks'] = $mailgun['track-clicks'] ? $mailgun['track-clicks'] : "no";
143
- $body['o:tracking-opens'] = $mailgun['track-opens'] ? "yes" : "no";
144
 
145
  if ( isset( $mailgun['tag'] ) ){
146
  $tags = explode(",", str_replace(" ","", $mailgun['tag']));
@@ -235,12 +235,12 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
235
  $i++;
236
  }
237
  }
238
-
239
  $payload .= '--' . $boundary . '--';
240
-
241
  $data = array(
242
  'body' => $payload,
243
- 'headers' => array('Authorization' => 'Basic ' . base64_encode( "api:{$apiKey}"),
244
  'content-type' => 'multipart/form-data; boundary=' . $boundary)
245
  );
246
 
139
  'text' => $message
140
  );
141
 
142
+ $body['o:tracking-clicks'] = isset( $mailgun['track-clicks'] ) ? $mailgun['track-clicks'] : "no";
143
+ $body['o:tracking-opens'] = isset( $mailgun['track-opens'] ) ? "yes" : "no";
144
 
145
  if ( isset( $mailgun['tag'] ) ){
146
  $tags = explode(",", str_replace(" ","", $mailgun['tag']));
235
  $i++;
236
  }
237
  }
238
+
239
  $payload .= '--' . $boundary . '--';
240
+
241
  $data = array(
242
  'body' => $payload,
243
+ 'headers' => array('Authorization' => 'Basic ' . base64_encode( "api:{$apiKey}"),
244
  'content-type' => 'multipart/form-data; boundary=' . $boundary)
245
  );
246
 
mailgun.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Mailgun
4
  * Plugin URI: http://wordpress.org/extend/plugins/mailgun/
5
  * Description: Mailgun integration for WordPress
6
- * Version: 1.1
7
  * Author: Mailgun
8
  * Author URI: http://www.mailgun.com/
9
  * License: GPLv2 or later
3
  * Plugin Name: Mailgun
4
  * Plugin URI: http://wordpress.org/extend/plugins/mailgun/
5
  * Description: Mailgun integration for WordPress
6
+ * Version: 1.2
7
  * Author: Mailgun
8
  * Author URI: http://www.mailgun.com/
9
  * License: GPLv2 or later
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: Mailgun, sivel
3
  Tags: mailgun, smtp, http, api, mail, email
4
  Requires at least: 3.3
5
- Tested up to: 3.5
6
- Stable tag: 1.1
7
  License: GPLv2 or later
8
 
9
  Easily send email from your WordPress site through Mailgun using the HTTP API or SMTP.
@@ -62,6 +62,9 @@ Initial Release
62
 
63
  == ChangeLog ==
64
 
 
 
 
65
  = 1.1 (2013-12-09): =
66
  * Attachments are now handled properly.
67
  * Added ability to customize tags and campaigns.
2
  Contributors: Mailgun, sivel
3
  Tags: mailgun, smtp, http, api, mail, email
4
  Requires at least: 3.3
5
+ Tested up to: 3.9
6
+ Stable tag: 1.2
7
  License: GPLv2 or later
8
 
9
  Easily send email from your WordPress site through Mailgun using the HTTP API or SMTP.
62
 
63
  == ChangeLog ==
64
 
65
+ = 1.2 (2014-08-19): =
66
+ * Fixed errors related to undefined variable. https://github.com/mailgun/wordpress-plugin/pull/3
67
+
68
  = 1.1 (2013-12-09): =
69
  * Attachments are now handled properly.
70
  * Added ability to customize tags and campaigns.
trunk/includes/admin.php DELETED
@@ -1,304 +0,0 @@
1
- <?php
2
-
3
- class MailgunAdmin extends Mailgun {
4
- /**
5
- * Setup backend functionality in WordPress
6
- *
7
- * @return none
8
- * @since 0.1
9
- */
10
- function __construct() {
11
- Mailgun::__construct();
12
-
13
- // Load localizations if available
14
- load_plugin_textdomain( 'mailgun' , false , 'mailgun/languages' );
15
-
16
- // Activation hook
17
- register_activation_hook( $this->plugin_file, array( &$this, 'init' ) );
18
-
19
- if ( ! defined( 'MAILGUN_USEAPI' ) || ! MAILGUN_USEAPI ) {
20
- // Hook into admin_init and register settings and potentially register an admin_notice
21
- add_action( 'admin_init', array( &$this, 'admin_init' ) );
22
-
23
- // Activate the options page
24
- add_action( 'admin_menu', array( &$this , 'admin_menu' ) );
25
- }
26
-
27
- // Register an AJAX action for testing mail sending capabilities
28
- add_action( 'wp_ajax_mailgun-test', array( &$this, 'ajax_send_test' ) );
29
- }
30
-
31
- /**
32
- * Initialize the default options during plugin activation
33
- *
34
- * @return none
35
- * @since 0.1
36
- */
37
- function init() {
38
- $sitename = strtolower( $_SERVER['SERVER_NAME'] );
39
- if ( substr( $sitename, 0, 4 ) == 'www.' ) {
40
- $sitename = substr( $sitename, 4 );
41
- }
42
-
43
- $defaults = array(
44
- 'useAPI' => '1',
45
- 'apiKey' => '',
46
- 'domain' => '',
47
- 'username' => '',
48
- 'password' => '',
49
- 'secure' => '1',
50
- 'track-clicks' => '',
51
- 'track-opens' => '',
52
- 'campaign-id' => '',
53
- 'tag' => $sitename,
54
- );
55
- if ( ! $this->options ) {
56
- $this->options = $defaults;
57
- add_option( 'mailgun', $this->options );
58
- }
59
- }
60
-
61
- /**
62
- * Add the options page
63
- *
64
- * @return none
65
- * @since 0.1
66
- */
67
- function admin_menu() {
68
- if ( current_user_can( 'manage_options' ) ) {
69
- $this->hook_suffix = add_options_page( __( 'Mailgun', 'mailgun' ), __( 'Mailgun', 'mailgun' ), 'manage_options', 'mailgun', array( &$this , 'options_page' ) );
70
- add_action( "admin_print_scripts-{$this->hook_suffix}" , array( &$this , 'admin_js' ) );
71
- add_filter( "plugin_action_links_{$this->plugin_basename}" , array( &$this , 'filter_plugin_actions' ) );
72
- add_action( "admin_footer-{$this->hook_suffix}" , array( &$this , 'admin_footer_js' ) );
73
- }
74
- }
75
-
76
- /**
77
- * Enqueue javascript required for the admin settings page
78
- *
79
- * @return none
80
- * @since 0.1
81
- */
82
- function admin_js() {
83
- wp_enqueue_script( 'jquery' );
84
- }
85
-
86
- /**
87
- * Output JS to footer for enhanced admin page functionality
88
- *
89
- * @since 0.1
90
- */
91
- function admin_footer_js() {
92
- ?>
93
- <script type="text/javascript">
94
- /* <![CDATA[ */
95
- var mailgunApiOrNot = function() {
96
- if (jQuery("#mailgun-api").val() == 1) {
97
- jQuery(".mailgun-smtp").hide();
98
- jQuery(".mailgun-api").show();
99
- } else {
100
- jQuery(".mailgun-api").hide();
101
- jQuery(".mailgun-smtp").show();
102
- }
103
-
104
- }
105
- var formModified = false;
106
- jQuery().ready(function() {
107
- mailgunApiOrNot();
108
- jQuery('#mailgun-api').change(function() {
109
- mailgunApiOrNot();
110
- });
111
- jQuery('#mailgun-test').click(function(e) {
112
- e.preventDefault();
113
- if ( formModified ) {
114
- var doTest = confirm('<?php _e( 'The Mailgun plugin configuration has changed since you last saved. Do you wish to test anyway?\n\nClick "Cancel" and then "Save Changes" if you wish to save your changes.', 'mailgun'); ?>');
115
- if ( ! doTest ) {
116
- return false;
117
- }
118
- }
119
- jQuery(this).val('<?php _e( 'Testing...', 'mailgun' ); ?>');
120
- jQuery("#mailgun-test-result").text('');
121
- jQuery.get(
122
- ajaxurl,
123
- {
124
- action: 'mailgun-test',
125
- _wpnonce: '<?php echo wp_create_nonce(); ?>'
126
- }
127
- )
128
- .complete(function() {
129
- jQuery("#mailgun-test").val('<?php _e( 'Test Configuration', 'mailgun' ); ?>');
130
- })
131
- .success(function(data) {
132
- alert('Mailgun ' + data.method + ' Test ' + data.message);
133
- })
134
- .error(function() {
135
- alert('Mailgun Test <?php _e( 'Failure', 'mailgun' ); ?>');
136
- });
137
- });
138
- jQuery("#mailgun-form").change(function() {
139
- formModified = true;
140
- });
141
- });
142
- /* ]]> */
143
- </script>
144
- <?php
145
- }
146
-
147
- /**
148
- * Output the options page
149
- *
150
- * @return none
151
- * @since 0.1
152
- */
153
- function options_page() {
154
- if ( ! @include( 'options-page.php' ) ) {
155
- printf( __( '<div id="message" class="updated fade"><p>The options page for the <strong>Mailgun</strong> plugin cannot be displayed. The file <strong>%s</strong> is missing. Please reinstall the plugin.</p></div>', 'mailgun'), dirname( __FILE__ ) . '/options-page.php' );
156
- }
157
- }
158
-
159
- /**
160
- * Wrapper function hooked into admin_init to register settings
161
- * and potentially register an admin notice if the plugin hasn't
162
- * been configured yet
163
- *
164
- * @return none
165
- * @since 0.1
166
- */
167
- function admin_init() {
168
- $this->register_settings();
169
- $apiKey = $this->get_option( 'apiKey' );
170
- $useAPI = $this->get_option( 'useAPI' );
171
- $password = $this->get_option( 'password' );
172
- if ( ( empty( $apiKey ) && $useAPI == '1' ) || ( empty( $password ) && $useAPI == '0' ) ) {
173
- add_action( 'admin_notices', array( &$this, 'admin_notices' ) );
174
- }
175
- }
176
-
177
- /**
178
- * Whitelist the mailgun options
179
- *
180
- * @since 0.1
181
- * @return none
182
- */
183
- function register_settings() {
184
- register_setting( 'mailgun', 'mailgun', array( &$this, 'validation' ) );
185
- }
186
-
187
- /**
188
- * Data validation callback function for options
189
- *
190
- * @param array $options An array of options posted from the options page
191
- * @return array
192
- * @since 0.1
193
- */
194
- function validation( $options ) {
195
- $apiKey = trim( $options['apiKey'] );
196
- $username = trim( $options['username'] );
197
- if ( ! empty( $apiKey ) ) {
198
- $pos = strpos( $apiKey, 'key-' );
199
- if ( $pos === false || $pos > 4 )
200
- $apiKey = "key-{$apiKey}";
201
-
202
- $pos = strpos( $apiKey, 'api:' );
203
- if ( $pos !== false && $pos == 0 )
204
- $apiKey = substr( $apiKey, 4 );
205
- $options['apiKey'] = $apiKey;
206
- }
207
-
208
- if ( ! empty( $username ) ) {
209
- $username = preg_replace( '/@.+$/', '', $username );
210
- $options['username'] = $username;
211
- }
212
-
213
- foreach ( $options as $key => $value )
214
- $options[$key] = trim( $value );
215
-
216
- $this->options = $options;
217
- return $options;
218
- }
219
-
220
- /**
221
- * Function to output an admin notice when the plugin has not
222
- * been configured yet
223
- *
224
- * @return none
225
- * @since 0.1
226
- */
227
- function admin_notices() {
228
- $screen = get_current_screen();
229
- if ( $screen->id == $this->hook_suffix )
230
- return;
231
- ?>
232
- <div id='mailgun-warning' class='updated fade'><p><strong><?php _e( 'Mailgun is almost ready. ', 'mailgun' ); ?></strong><?php printf( __( 'You must <a href="%1$s">configure Mailgun</a> for it to work.', 'mailgun' ), menu_page_url( 'mailgun' , false ) ); ?></p></div>
233
- <?php
234
- }
235
-
236
- /**
237
- * Add a settings link to the plugin actions
238
- *
239
- * @param array $links Array of the plugin action links
240
- * @return array
241
- * @since 0.1
242
- */
243
- function filter_plugin_actions( $links ) {
244
- $settings_link = '<a href="' . menu_page_url( 'mailgun', false ) . '">' . __( 'Settings', 'mailgun' ) . '</a>';
245
- array_unshift( $links, $settings_link );
246
- return $links;
247
- }
248
-
249
- /**
250
- * AJAX callback function to test mail sending functionality
251
- *
252
- * @return string
253
- * @since 0.1
254
- */
255
- function ajax_send_test() {
256
- nocache_headers();
257
- header( 'Content-Type: application/json' );
258
-
259
- if ( ! current_user_can( 'manage_options' ) || ! wp_verify_nonce( $_GET[ '_wpnonce' ] ) ) {
260
- die(
261
- json_encode(
262
- array(
263
- 'message' => __( 'Unauthorized', 'mailgun' ),
264
- 'method' => null
265
- )
266
- )
267
- );
268
- }
269
-
270
- $useAPI = ( defined( 'MAILGUN_USEAPI' ) && MAILGUN_USEAPI ) ? MAILGUN_USEAPI : $this->get_option( 'useAPI' );
271
- $secure = ( defined( 'MAILGUN_SECURE' ) && MAILGUN_SECURE ) ? MAILGUN_SECURE : $this->get_option( 'secure' );
272
- if ( (bool) $useAPI )
273
- $method = __( 'HTTP API', 'mailgun' );
274
- else
275
- $method = ( (bool) $secure ) ? __( 'Secure SMTP', 'mailgun' ) : __( 'SMTP', 'mailgun' );
276
-
277
- $admin_email = get_option( 'admin_email' );
278
- $result = wp_mail(
279
- $admin_email,
280
- __( 'Mailgun WordPress Plugin Test', 'mailgun' ),
281
- sprintf( __( "This is a test email generated by the Mailgun WordPress plugin.\n\nIf you have received this message, the requested test has succeeded.\n\nThe method used to send this email was: %s.", 'mailgun' ), $method )
282
- );
283
-
284
- if ( $result ) {
285
- die(
286
- json_encode(
287
- array(
288
- 'message' => __( 'Success', 'mailgun' ),
289
- 'method' => $method
290
- )
291
- )
292
- );
293
- } else {
294
- die(
295
- json_encode(
296
- array(
297
- 'message' => __( 'Failure', 'mailgun' ),
298
- 'method' => $method
299
- )
300
- )
301
- );
302
- }
303
- }
304
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/includes/options-page.php DELETED
@@ -1,121 +0,0 @@
1
- <div class="wrap">
2
- <div id="icon-options-general" class="icon32"><br /></div>
3
- <span class="alignright"><a target="_blank" href="http://www.mailgun.com/"><img src="https://2e6874288eee3bf7ca22-d122329f808928cff1e9967578106854.ssl.cf1.rackcdn.com/mailgun-logo.png" alt="Mailgun" /></a></span>
4
- <h2><?php _e( 'Mailgun' , 'mailgun' ); ?></h2>
5
- <p>A <a target="_blank" href="http://www.mailgun.com/">Mailgun</a> account is required to use this plugin and the Mailgun service.</p>
6
- <p>If you need to register for an account, you can do so at <a target="_blank" href="http://www.mailgun.com/">http://www.mailgun.com/</a>.</p>
7
- <form id="mailgun-form" action="options.php" method="post">
8
- <?php settings_fields( 'mailgun' ); ?>
9
- <h3><?php _e( 'Configuration' , 'mailgun' ); ?></h3>
10
- <table class="form-table">
11
- <tr valign="top">
12
- <th scope="row">
13
- <?php _e( 'Use HTTP API' , 'mailgun' ); ?>
14
- </th>
15
- <td>
16
- <select id="mailgun-api" name="mailgun[useAPI]">
17
- <option value="1"<?php selected( '1' , $this->get_option( 'useAPI' ) ); ?>><?php _e( 'Yes' , 'mailgun' ); ?></option>
18
- <option value="0"<?php selected( '0' , $this->get_option( 'useAPI' ) ); ?>><?php _e( 'No' , 'mailgun' ); ?></option>
19
- </select>
20
- <p class="description"><?php _e( 'Set this to "No" if your server cannot make outbound HTTP connections or if emails are not being delivered. "No" will cause this plugin to use SMTP. Default "Yes".', 'mailgun' ); ?></p>
21
- </td>
22
- </tr>
23
- <tr valign="top">
24
- <th scope="row">
25
- <?php _e( 'Mailgun Domain Name' , 'mailgun' ); ?>
26
- </th>
27
- <td>
28
- <input type="text" class="regular-text" name="mailgun[domain]" value="<?php esc_attr_e( $this->get_option( 'domain' ) ); ?>" placeholder="samples.mailgun.org" />
29
- <p class="description"><?php _e( 'Your Mailgun Domain Name.', 'mailgun' ); ?></p>
30
- </td>
31
- </tr>
32
- <tr valign="top" class="mailgun-api">
33
- <th scope="row">
34
- <?php _e( 'API Key' , 'mailgun' ); ?>
35
- </th>
36
- <td>
37
- <input type="text" class="regular-text" name="mailgun[apiKey]" value="<?php esc_attr_e( $this->get_option( 'apiKey' ) ); ?>" placeholder="key-3ax6xnjp29jd6fds4gc373sgvjxteol0" />
38
- <p class="description"><?php _e( 'Your Mailgun API key, that starts with and includes "key-". Only valid for use with the API.', 'mailgun' ); ?></p>
39
- </td>
40
- </tr>
41
- <tr valign="top" class="mailgun-smtp">
42
- <th scope="row">
43
- <?php _e( 'Username' , 'mailgun' ); ?>
44
- </th>
45
- <td>
46
- <input type="text" class="regular-text" name="mailgun[username]" value="<?php esc_attr_e( $this->get_option( 'username' ) ); ?>" placeholder="postmaster" />
47
- <p class="description"><?php _e( 'Your Mailgun SMTP username. Only valid for use with SMTP.', 'mailgun' ); ?></p>
48
- </td>
49
- </tr>
50
- <tr valign="top" class="mailgun-smtp">
51
- <th scope="row">
52
- <?php _e( 'Password' , 'mailgun' ); ?>
53
- </th>
54
- <td>
55
- <input type="text" class="regular-text" name="mailgun[password]" value="<?php esc_attr_e( $this->get_option( 'password' ) ); ?>" placeholder="my-password" />
56
- <p class="description"><?php _e( 'Your Mailgun SMTP password that goes with the above username. Only valid for use with SMTP.', 'mailgun' ); ?></p>
57
- </td>
58
- </tr>
59
- <tr valign="top" class="mailgun-smtp">
60
- <th scope="row">
61
- <?php _e( 'Use Secure SMTP' , 'mailgun' ); ?>
62
- </th>
63
- <td>
64
- <select name="mailgun[secure]">
65
- <option value="1"<?php selected( '1' , $this->get_option( 'secure' ) ); ?>><?php _e( 'Yes' , 'mailgun' ); ?></option>
66
- <option value="0"<?php selected( '0' , $this->get_option( 'secure' ) ); ?>><?php _e( 'No' , 'mailgun' ); ?></option>
67
- </select>
68
- <p class="description"><?php _e( 'Set this to "No" if your server cannot establish SSL SMTP connections or if emails are not being delivered. If you set this to "No" your password will be sent in plain text. Only valid for use with SMTP. Default "Yes".', 'mailgun' ); ?></p>
69
- </td>
70
- </tr>
71
- <tr valign="top">
72
- <th scope="row">
73
- <?php _e( 'Click Tracking' , 'mailgun' ); ?>
74
- </th>
75
- <td>
76
- <select name="mailgun[track-clicks]">
77
- <option value="yes"<?php selected( 'yes' , $this->get_option( 'track-clicks' ) ); ?>><?php _e( 'Yes' , 'mailgun' ); ?></option>
78
- <option value="htmlonly"<?php selected( 'htmlonly' , $this->get_option( 'track-clicks' ) ); ?>><?php _e( 'HTML Only' , 'mailgun' ); ?></option>
79
- <option value="no"<?php selected( 'no' , $this->get_option( 'track-clicks' ) ); ?>><?php _e( 'No' , 'mailgun' ); ?></option>
80
- </select>
81
- <p class="description"><?php _e( 'If enabled, Mailgun will and track links.', 'mailgun' ); ?> <a href="http://documentation.mailgun.com/user_manual.html#tracking-clicks" target="_blank">Click Tracking Documentation</a></p>
82
- </td>
83
- </tr>
84
- <tr valign="top">
85
- <th scope="row">
86
- <?php _e( 'Open Tracking' , 'mailgun' ); ?>
87
- </th>
88
- <td>
89
- <select name="mailgun[track-opens]">
90
- <option value="1"<?php selected( '1' , $this->get_option( 'track-opens' ) ); ?>><?php _e( 'Yes' , 'mailgun' ); ?></option>
91
- <option value="0"<?php selected( '0' , $this->get_option( 'track-opens' ) ); ?>><?php _e( 'No' , 'mailgun' ); ?></option>
92
- </select>
93
- <p class="description"><?php _e( 'If enabled, HTML messages will include an open tracking beacon.', 'mailgun' ); ?> <a href="http://documentation.mailgun.com/user_manual.html#tracking-opens" target="_blank">Open Tracking Documentation</a></p>
94
- </td>
95
- </tr>
96
- <tr valign="top">
97
- <th scope="row">
98
- <?php _e( 'Campaign ID' , 'mailgun' ); ?>
99
- </th>
100
- <td>
101
- <input type="text" class="regular-text" name="mailgun[campaign-id]" value="<?php esc_attr_e( $this->get_option( 'campaign-id' ) ); ?>" placeholder="campaign-id" />
102
- <p class="description"><?php _e( 'If added, this campaign will exist on every outbound message. Statistics will be populated in the Mailgun Control Panel. Use a comma to define multiple campaigns.', 'mailgun' ); ?> <a href="http://documentation.mailgun.com/user_manual.html#campaign-analytics" target="_blank">Campaign Documentation</a></p>
103
- </td>
104
- </tr>
105
- <tr valign="top">
106
- <th scope="row">
107
- <?php _e( 'Tag' , 'mailgun' ); ?>
108
- </th>
109
- <td>
110
- <input type="text" class="regular-text" name="mailgun[tag]" value="<?php esc_attr_e( $this->get_option( 'tag' ) ); ?>" placeholder="tag" />
111
- <p class="description"><?php _e( 'If added, this tag will exist on every outbound message. Statistics will be populated in the Mailgun Control Panel. Use a comma to define multiple tags.', 'mailgun' ); ?> <a href="http://documentation.mailgun.com/user_manual.html#tagging" target="_blank">Tagging Documentation</a></p>
112
- </td>
113
- </tr>
114
- </table>
115
- <p><?php _e( 'Before attempting to test the configuration, please click "Save Changes".', 'mailgun' ); ?></p>
116
- <p class="submit">
117
- <input type="submit" class="button-primary" value="<?php _e( 'Save Changes' , 'mailgun' ); ?>" />
118
- <input type="button" id="mailgun-test" class="button-secondary" value="<?php _e( 'Test Configuration', 'mailgun' ); ?>" />
119
- </p>
120
- </form>
121
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/includes/wp-mail.php DELETED
@@ -1,265 +0,0 @@
1
- <?php
2
- /**
3
- * wp_mail function to be loaded in to override the core wp_mail function
4
- * from wp-includes/pluggable.php
5
- *
6
- * Based off of the core wp_mail function, but with modifications required to
7
- * send email using the Mailgun HTTP API
8
- *
9
- * @param string|array $to Array or comma-separated list of email addresses to send message.
10
- * @param string $subject Email subject
11
- * @param string $message Message contents
12
- * @param string|array $headers Optional. Additional headers.
13
- * @param string|array $attachments Optional. Files to attach.
14
- * @return bool Whether the email contents were sent successfully.
15
- * @since 0.1
16
- */
17
- function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
18
- // Compact the input, apply the filters, and extract them back out
19
- extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) );
20
-
21
- $mailgun = get_option( 'mailgun' );
22
- $apiKey = ( defined( 'MAILGUN_APIKEY' ) && MAILGUN_APIKEY ) ? MAILGUN_APIKEY : $mailgun['apiKey'];
23
- $domain = ( defined( 'MAILGUN_DOMAIN' ) && MAILGUN_DOMAIN ) ? MAILGUN_DOMAIN : $mailgun['domain'];
24
-
25
- if ( empty( $apiKey ) || empty( $domain ) )
26
- return false;
27
-
28
- if ( !is_array($attachments) )
29
- $attachments = explode( "\n", str_replace( "\r\n", "\n", $attachments ) );
30
-
31
- // Headers
32
- if ( empty( $headers ) ) {
33
- $headers = array();
34
- } else {
35
- if ( !is_array( $headers ) ) {
36
- // Explode the headers out, so this function can take both
37
- // string headers and an array of headers.
38
- $tempheaders = explode( "\n", str_replace( "\r\n", "\n", $headers ) );
39
- } else {
40
- $tempheaders = $headers;
41
- }
42
- $headers = array();
43
- $cc = array();
44
- $bcc = array();
45
-
46
- // If it's actually got contents
47
- if ( !empty( $tempheaders ) ) {
48
- // Iterate through the raw headers
49
- foreach ( (array) $tempheaders as $header ) {
50
- if ( strpos($header, ':') === false ) {
51
- if ( false !== stripos( $header, 'boundary=' ) ) {
52
- $parts = preg_split('/boundary=/i', trim( $header ) );
53
- $boundary = trim( str_replace( array( "'", '"' ), '', $parts[1] ) );
54
- }
55
- continue;
56
- }
57
- // Explode them out
58
- list( $name, $content ) = explode( ':', trim( $header ), 2 );
59
-
60
- // Cleanup crew
61
- $name = trim( $name );
62
- $content = trim( $content );
63
-
64
- switch ( strtolower( $name ) ) {
65
- // Mainly for legacy -- process a From: header if it's there
66
- case 'from':
67
- if ( strpos($content, '<' ) !== false ) {
68
- // So... making my life hard again?
69
- $from_name = substr( $content, 0, strpos( $content, '<' ) - 1 );
70
- $from_name = str_replace( '"', '', $from_name );
71
- $from_name = trim( $from_name );
72
-
73
- $from_email = substr( $content, strpos( $content, '<' ) + 1 );
74
- $from_email = str_replace( '>', '', $from_email );
75
- $from_email = trim( $from_email );
76
- } else {
77
- $from_email = trim( $content );
78
- }
79
- break;
80
- case 'content-type':
81
- if ( strpos( $content, ';' ) !== false ) {
82
- list( $type, $charset ) = explode( ';', $content );
83
- $content_type = trim( $type );
84
- if ( false !== stripos( $charset, 'charset=' ) ) {
85
- $charset = trim( str_replace( array( 'charset=', '"' ), '', $charset ) );
86
- } elseif ( false !== stripos( $charset, 'boundary=' ) ) {
87
- $boundary = trim( str_replace( array( 'BOUNDARY=', 'boundary=', '"' ), '', $charset ) );
88
- $charset = '';
89
- }
90
- } else {
91
- $content_type = trim( $content );
92
- }
93
- break;
94
- case 'cc':
95
- $cc = array_merge( (array) $cc, explode( ',', $content ) );
96
- break;
97
- case 'bcc':
98
- $bcc = array_merge( (array) $bcc, explode( ',', $content ) );
99
- break;
100
- default:
101
- // Add it to our grand headers array
102
- $headers[trim( $name )] = trim( $content );
103
- break;
104
- }
105
- }
106
- }
107
- }
108
-
109
- // From email and name
110
- // If we don't have a name from the input headers
111
- if ( !isset( $from_name ) )
112
- $from_name = 'WordPress';
113
-
114
- /* If we don't have an email from the input headers default to wordpress@$sitename
115
- * Some hosts will block outgoing mail from this address if it doesn't exist but
116
- * there's no easy alternative. Defaulting to admin_email might appear to be another
117
- * option but some hosts may refuse to relay mail from an unknown domain. See
118
- * http://trac.wordpress.org/ticket/5007.
119
- */
120
-
121
- if ( !isset( $from_email ) ) {
122
- // Get the site domain and get rid of www.
123
- $sitename = strtolower( $_SERVER['SERVER_NAME'] );
124
- if ( substr( $sitename, 0, 4 ) == 'www.' ) {
125
- $sitename = substr( $sitename, 4 );
126
- }
127
-
128
- $from_email = 'wordpress@' . $sitename;
129
- }
130
-
131
- // Plugin authors can override the potentially troublesome default
132
- $from_email = apply_filters( 'wp_mail_from' , $from_email );
133
- $from_name = apply_filters( 'wp_mail_from_name', $from_name );
134
-
135
- $body = array(
136
- 'from' => "{$from_name} <{$from_email}>",
137
- 'to' => $to,
138
- 'subject' => $subject,
139
- 'text' => $message
140
- );
141
-
142
- $body['o:tracking-clicks'] = $mailgun['track-clicks'] ? $mailgun['track-clicks'] : "no";
143
- $body['o:tracking-opens'] = $mailgun['track-opens'] ? "yes" : "no";
144
-
145
- if ( isset( $mailgun['tag'] ) ){
146
- $tags = explode(",", str_replace(" ","", $mailgun['tag']));
147
- $body['o:tag'] = $tags;
148
- }
149
-
150
- if ( isset( $mailgun['campaign-id'] ) ){
151
- $campaigns = explode(",", str_replace(" ","", $mailgun['campaign-id']));
152
- $body['o:campaign'] = $campaigns;
153
- }
154
-
155
- if ( ! empty( $cc ) && is_array( $cc ) )
156
- $body['cc'] = implode( ', ', $cc );
157
-
158
- if ( ! empty( $bcc ) && is_array( $bcc ) )
159
- $body['bcc'] = implode( ', ', $bcc );
160
-
161
- // Set Content-Type and charset
162
- // If we don't have a content-type from the input headers
163
- if ( !isset( $content_type ) )
164
- $content_type = 'text/plain';
165
-
166
- $content_type = apply_filters( 'wp_mail_content_type', $content_type );
167
- if ( $content_type == 'text/html' ) {
168
- $body['html'] = $message;
169
- $body['text'] = strip_tags( $message );
170
- }
171
-
172
- // If we don't have a charset from the input headers
173
- if ( !isset( $charset ) )
174
- $charset = get_bloginfo( 'charset' );
175
-
176
- // Set the content-type and charset
177
- $charset = apply_filters( 'wp_mail_charset', $charset );
178
- if ( isset( $headers['Content-Type'] ) ) {
179
- if ( ! strstr( $headers['Content-Type'], 'charset' ) )
180
- $headers['Content-Type'] = rtrim( $headers['Content-Type'], '; ' ) . "; charset={$charset}";
181
- }
182
-
183
- // Set custom headers
184
- if ( !empty( $headers ) ) {
185
- foreach( (array) $headers as $name => $content ) {
186
- $body["h:{$name}"] = $content;
187
- }
188
-
189
- // TODO: Can we handle this?
190
- //if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) )
191
- // $phpmailer->AddCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) );
192
- }
193
-
194
- /*
195
- * Deconstruct post array and create POST payload.
196
- * This entire routine is because wp_remote_post does
197
- * not support files directly.
198
- */
199
-
200
- // First, generate a boundary for the multipart message.
201
- $boundary = base_convert(uniqid('boundary', true), 10, 36);
202
-
203
- $payload = null;
204
-
205
- // Iterate through pre-built params and build payload:
206
- foreach ( $body as $key => $value ) {
207
- if ( is_array( $value ) ){
208
- $parent_key = $key;
209
- foreach($value as $key => $value){
210
- $payload .= '--' . $boundary;
211
- $payload .= "\r\n";
212
- $payload .= 'Content-Disposition: form-data; name="' . $parent_key . '[' . $key . ']"' . "\r\n\r\n";
213
- $payload .= $value;
214
- $payload .= "\r\n";
215
- }
216
- }
217
- else{
218
- $payload .= '--' . $boundary;
219
- $payload .= "\r\n";
220
- $payload .= 'Content-Disposition: form-data; name="' . $key . '"' . "\r\n\r\n";
221
- $payload .= $value;
222
- $payload .= "\r\n";
223
- }
224
- }
225
-
226
- // If we have attachments, add them to the payload.
227
- if ( !empty( $attachments ) ){
228
- $i = 0;
229
- foreach ( $attachments as $attachment ) {
230
- $payload .= '--' . $boundary;
231
- $payload .= "\r\n";
232
- $payload .= 'Content-Disposition: form-data; name="attachment[' . $i . ']"; filename="' . basename( $attachment ) . '"' . "\r\n\r\n";
233
- $payload .= file_get_contents( $attachment );
234
- $payload .= "\r\n";
235
- $i++;
236
- }
237
- }
238
-
239
- $payload .= '--' . $boundary . '--';
240
-
241
- $data = array(
242
- 'body' => $payload,
243
- 'headers' => array('Authorization' => 'Basic ' . base64_encode( "api:{$apiKey}"),
244
- 'content-type' => 'multipart/form-data; boundary=' . $boundary)
245
- );
246
-
247
- $url = "https://api.mailgun.net/v2/{$domain}/messages";
248
-
249
- // TODO: Mailgun only supports 1000 recipients per request, since we are
250
- // overriding this function, let's add looping here to handle that
251
- $response = wp_remote_post( $url, $data );
252
- if ( is_wp_error( $response ) )
253
- return false;
254
-
255
- $response_code = wp_remote_retrieve_response_code( $response );
256
- if ( (int) $response_code != 200 )
257
- return false;
258
-
259
- // Not sure there is any additional checking that needs to be done here, but why not?
260
- $response_body = json_decode( wp_remote_retrieve_body( $response ) );
261
- if ( ! isset( $response_body->message ) || $response_body->message != 'Queued. Thank you.' )
262
- return false;
263
-
264
- return true;
265
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/languages/mailgun-template.po DELETED
@@ -1,175 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: Mailgun\n"
4
- "POT-Creation-Date: 2012-11-20 13:54-0600\n"
5
- "PO-Revision-Date: 2012-11-20 13:54-0600\n"
6
- "Last-Translator: Matt Martz <matt@sivel.net>\n"
7
- "Language-Team: Mailgun <matt@sivel.net>\n"
8
- "Language: en_US\n"
9
- "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=UTF-8\n"
11
- "Content-Transfer-Encoding: 8bit\n"
12
-
13
- #: mailgun.php:89
14
- #, php-format
15
- msgid ""
16
- "Mailgun has been automatically deactivated because the file <strong>%s</"
17
- "strong> is missing. Please reinstall the plugin and reactivate."
18
- msgstr ""
19
-
20
- #: includes/admin.php:60 includes/options-page.php:4
21
- msgid "Mailgun"
22
- msgstr ""
23
-
24
- #: includes/admin.php:105
25
- msgid ""
26
- "The Mailgun plugin configuration has changed since you last saved. Do you "
27
- "wish to test anyway?\\n\\nClick \"Cancel\" and then \"Save Changes\" if you "
28
- "wish to save your changes."
29
- msgstr ""
30
-
31
- #: includes/admin.php:110
32
- msgid "Testing..."
33
- msgstr ""
34
-
35
- #: includes/admin.php:120 includes/options-page.php:75
36
- msgid "Test Configuration"
37
- msgstr ""
38
-
39
- #: includes/admin.php:126 includes/admin.php:288
40
- msgid "Failure"
41
- msgstr ""
42
-
43
- #: includes/admin.php:146
44
- #, php-format
45
- msgid ""
46
- "<div id=\"message\" class=\"updated fade\"><p>The options page for the "
47
- "<strong>Mailgun</strong> plugin cannot be displayed. The file <strong>%s</"
48
- "strong> is missing. Please reinstall the plugin.</p></div>"
49
- msgstr ""
50
-
51
- #: includes/admin.php:223
52
- msgid "Mailgun is almost ready. "
53
- msgstr ""
54
-
55
- #: includes/admin.php:223
56
- #, php-format
57
- msgid "You must <a href=\"%1$s\">configure Mailgun</a> for it to work."
58
- msgstr ""
59
-
60
- #: includes/admin.php:235
61
- msgid "Settings"
62
- msgstr ""
63
-
64
- #: includes/admin.php:254
65
- msgid "Unauthorized"
66
- msgstr ""
67
-
68
- #: includes/admin.php:264
69
- msgid "HTTP API"
70
- msgstr ""
71
-
72
- #: includes/admin.php:266
73
- msgid "Secure SMTP"
74
- msgstr ""
75
-
76
- #: includes/admin.php:266
77
- msgid "SMTP"
78
- msgstr ""
79
-
80
- #: includes/admin.php:271
81
- msgid "Mailgun WordPress Plugin Test"
82
- msgstr ""
83
-
84
- #: includes/admin.php:272
85
- #, php-format
86
- msgid ""
87
- "This is a test email generated by the Mailgun WordPress plugin.\n"
88
- "\n"
89
- "If you have received this message, the requested test has succeeded.\n"
90
- "\n"
91
- "The method used to send this email was: %s."
92
- msgstr ""
93
-
94
- #: includes/admin.php:279
95
- msgid "Success"
96
- msgstr ""
97
-
98
- #: includes/options-page.php:9
99
- msgid "Configuration"
100
- msgstr ""
101
-
102
- #: includes/options-page.php:13
103
- msgid "Use HTTP API"
104
- msgstr ""
105
-
106
- #: includes/options-page.php:17 includes/options-page.php:65
107
- msgid "Yes"
108
- msgstr ""
109
-
110
- #: includes/options-page.php:18 includes/options-page.php:66
111
- msgid "No"
112
- msgstr ""
113
-
114
- #: includes/options-page.php:20
115
- msgid ""
116
- "Set this to \"No\" if your server cannot make outbound HTTP connections or "
117
- "if emails are not being delivered. \"No\" will cause this plugin to use "
118
- "SMTP. Default \"Yes\"."
119
- msgstr ""
120
-
121
- #: includes/options-page.php:25
122
- msgid "Mailgun Domain Name"
123
- msgstr ""
124
-
125
- #: includes/options-page.php:29
126
- msgid "Your Mailgun Domain Name."
127
- msgstr ""
128
-
129
- #: includes/options-page.php:34
130
- msgid "API Key"
131
- msgstr ""
132
-
133
- #: includes/options-page.php:38
134
- msgid ""
135
- "Your Mailgun API key, that starts with and includes \"key-\". Only valid for "
136
- "use with the API."
137
- msgstr ""
138
-
139
- #: includes/options-page.php:43
140
- msgid "Username"
141
- msgstr ""
142
-
143
- #: includes/options-page.php:47
144
- msgid "Your Mailgun SMTP username. Only valid for use with SMTP."
145
- msgstr ""
146
-
147
- #: includes/options-page.php:52
148
- msgid "Password"
149
- msgstr ""
150
-
151
- #: includes/options-page.php:56
152
- msgid ""
153
- "Your Mailgun SMTP password that goes with the above username. Only valid for "
154
- "use with SMTP."
155
- msgstr ""
156
-
157
- #: includes/options-page.php:61
158
- msgid "Use Secure SMTP"
159
- msgstr ""
160
-
161
- #: includes/options-page.php:68
162
- msgid ""
163
- "Set this to \"No\" if your server cannot establish SSL SMTP connections or "
164
- "if emails are not being delivered. If you set this to \"No\" your password "
165
- "will be sent in plain text. Only valid for use with SMTP. Default \"Yes\"."
166
- msgstr ""
167
-
168
- #: includes/options-page.php:72
169
- msgid ""
170
- "Before attempting to test the configuration, please click \"Save Changes\"."
171
- msgstr ""
172
-
173
- #: includes/options-page.php:74
174
- msgid "Save Changes"
175
- msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/mailgun.php DELETED
@@ -1,106 +0,0 @@
1
- <?php
2
- /**
3
- * Plugin Name: Mailgun
4
- * Plugin URI: http://wordpress.org/extend/plugins/mailgun/
5
- * Description: Mailgun integration for WordPress
6
- * Version: 1.1
7
- * Author: Mailgun
8
- * Author URI: http://www.mailgun.com/
9
- * License: GPLv2 or later
10
- * Text Domain: mailgun
11
- * Domain Path: /languages/
12
- */
13
-
14
- class Mailgun {
15
-
16
- /**
17
- * Setup shared functionality for Admin and Front End
18
- *
19
- * @return none
20
- * @since 0.1
21
- */
22
- function __construct() {
23
- $this->options = get_option( 'mailgun' );
24
- $this->plugin_file = __FILE__;
25
- $this->plugin_basename = plugin_basename( $this->plugin_file );
26
-
27
- // Either override the wp_mail function or configure PHPMailer to use the
28
- // Mailgun SMTP servers
29
- if ( $this->get_option( 'useAPI' ) || ( defined( 'MAILGUN_USEAPI' ) && MAILGUN_USEAPI ) ) {
30
- if ( ! function_exists( 'wp_mail' ) ) {
31
- if ( ! @include( dirname( __FILE__ ) . '/includes/wp-mail.php' ) )
32
- Mailgun::deactivate_and_die( dirname( __FILE__ ) . '/includes/wp-mail.php' );
33
- }
34
- } else {
35
- add_action( 'phpmailer_init', array( &$this, 'phpmailer_init' ) );
36
- }
37
- }
38
-
39
- /**
40
- * Get specific option from the options table
41
- *
42
- * @param string $option Name of option to be used as array key for retrieving the specific value
43
- * @return mixed
44
- * @since 0.1
45
- */
46
- function get_option( $option, $options = null ) {
47
- if ( is_null( $options ) )
48
- $options = &$this->options;
49
- if ( isset( $options[$option] ) )
50
- return $options[$option];
51
- else
52
- return false;
53
- }
54
-
55
- /**
56
- * Hook into phpmailer to override SMTP based configurations
57
- * to use the Mailgun SMTP server
58
- *
59
- * @param object $phpmailer The PHPMailer object to modify by reference
60
- * @return none
61
- * @since 0.1
62
- */
63
- function phpmailer_init( &$phpmailer ) {
64
- $username = ( defined( 'MAILGUN_USERNAME' ) && MAILGUN_USERNAME ) ? MAILGUN_USERNAME : $this->get_option( 'username' );
65
- $domain = ( defined( 'MAILGUN_DOMAIN' ) && MAILGUN_DOMAIN ) ? MAILGUN_DOMAIN : $this->get_option( 'domain' );
66
- $username = preg_replace( '/@.+$/', '', $username ) . "@{$domain}";
67
- $secure = ( defined( 'MAILGUN_SECURE' ) && MAILGUN_SECURE ) ? MAILGUN_SECURE : $this->get_option('secure');
68
- $password = ( defined( 'MAILGUN_PASSWORD' ) && MAILGUN_PASSWORD ) ? MAILGUN_PASSWORD : $this->get_option('password');
69
-
70
- $phpmailer->Mailer = 'smtp';
71
- $phpmailer->SMTPSecure = (bool) $secure ? 'ssl' : 'none';
72
- $phpmailer->Host = 'smtp.mailgun.net';
73
- $phpmailer->Port = (bool) $secure ? 465 : 587;
74
- $phpmailer->SMTPAuth = true;
75
- $phpmailer->Username = $username;
76
- $phpmailer->Password = $password;
77
- }
78
-
79
- /**
80
- * Deactivate this plugin and die
81
- *
82
- * Used to deactivate the plugin when files critical to it's operation can not be loaded
83
- *
84
- * @since 0.1
85
- * @return none
86
- */
87
- function deactivate_and_die( $file ) {
88
- load_plugin_textdomain( 'mailgun', false, 'mailgun/languages' );
89
- $message = sprintf( __( "Mailgun has been automatically deactivated because the file <strong>%s</strong> is missing. Please reinstall the plugin and reactivate." ), $file );
90
- if ( ! function_exists( 'deactivate_plugins' ) )
91
- include( ABSPATH . 'wp-admin/includes/plugin.php' );
92
- deactivate_plugins( __FILE__ );
93
- wp_die( $message );
94
- }
95
-
96
- }
97
-
98
- if ( is_admin() ) {
99
- if ( @include( dirname( __FILE__ ) . '/includes/admin.php' ) ) {
100
- $mailgunAdmin = new MailgunAdmin();
101
- } else {
102
- Mailgun::deactivate_and_die( dirname( __FILE__ ) . '/includes/admin.php' );
103
- }
104
- } else {
105
- $mailgun = new Mailgun();
106
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/readme.txt DELETED
@@ -1,74 +0,0 @@
1
- === Mailgun for WordPress ===
2
- Contributors: Mailgun, sivel
3
- Tags: mailgun, smtp, http, api, mail, email
4
- Requires at least: 3.3
5
- Tested up to: 3.5
6
- Stable tag: 1.1
7
- License: GPLv2 or later
8
-
9
- Easily send email from your WordPress site through Mailgun using the HTTP API or SMTP.
10
-
11
- == Description ==
12
-
13
- [Mailgun](http://www.mailgun.com/) is the email automation engine trusted by over 10,000 website and application developers for sending, receiving and tracking emails. By taking advantage of Mailgun's powerful email APIs, developers can spend more time building awesome websites and less time fighting with email servers. Mailgun supports all of the most popular languages including PHP, Ruby, Python, C# and Java.
14
-
15
- One particularly useful feature of this plugin is that it provides you with a way to send email when the server you are on does not support SMTP or where outbound SMTP is restricted since the plug-in uses the Mailgun HTTP API for sending email by default. All you need to use the plugin is a [Mailgun account](http://www.mailgun.com/). Mailgun has a free account that lets you send up to 200 emails per day, which is great for testing. Paid subscriptions are available for increased limits.
16
-
17
- The current version of this plugin only handles sending emails. Future releases will include additional functionality around processing incoming emails, tracking and analytics. Until then, you can configure how to handle incoming emails and set up analytics in the Mailgun control panel or using the Mailgun API.
18
-
19
- == Installation ==
20
-
21
- 1. Upload the `mailgun` folder to the `/wp-content/plugins/` directory or install directly through the plugin installer
22
- 1. Activate the plugin through the 'Plugins' menu in WordPress or by using the link provided by the plugin installer
23
- 1. Visit the settings page in the Admin at `Settings -> Mailgun` and configure the plugin with your account details
24
-
25
- == Frequently Asked Questions ==
26
-
27
- = Testing the configuration fails when using the HTTP API =
28
-
29
- Your web server may not allow outbound HTTP connections. Set `Use HTTP API` to "No", and fill out the configuration options to SMTP and test again.
30
-
31
- = Testing the configuration fails when using SMTP =
32
-
33
- Your web server may not allow outbound SMTP connections on port 465 for secure connections or 587 for unsecured connections. Try changing `Use Secure SMTP` to "No" or "Yes" depending on your current configuration and testing again. If both fail, try setting `Use HTTP API` to "Yes" and testing again.
34
-
35
- = Can this be configured globally for WordPress Multisite? =
36
-
37
- Yes, using the following constants that can be placed in wp-config.php:
38
-
39
- `
40
- MAILGUN_USEAPI Type: boolean
41
- MAILGUN_APIKEY Type: string
42
- MAILGUN_DOMAIN Type: string
43
- MAILGUN_USERNAME Type: string
44
- MAILGUN_PASSWORD Type: string
45
- MAILGUN_SECURE Type: boolean
46
- `
47
-
48
- == Screenshots ==
49
-
50
- 1. Configuration options for using the Mailgun HTTP API
51
- 2. Configuration options for using the Mailgun SMTP servers
52
-
53
- == Upgrade Notice ==
54
-
55
- = 1.0 =
56
-
57
- Re-release to update versioning to start at 1.0 instead of 0.1
58
-
59
- = 0.1 =
60
-
61
- Initial Release
62
-
63
- == ChangeLog ==
64
-
65
- = 1.1 (2013-12-09): =
66
- * Attachments are now handled properly.
67
- * Added ability to customize tags and campaigns.
68
- * Added ability to toggle URL and open tracking.
69
-
70
- = 1.0 (2012-11-27): =
71
- * Re-release to update versioning to start at 1.0 instead of 0.1
72
-
73
- = 0.1 (2012-11-21): =
74
- * Initial Release