Support » Plugin: Mailgun for WordPress » 1.6 settings page?

  • Resolved blueclochard

    (@blueclochard)



    Hello Mailgun!

    I just updated to version 1.6 coming from a fully configured 1.5.14. I am using WordPress 4.9.8 and multi-site. On my dashboard I now get a notification stating that Mailgun is almost ready, but that I still need to set the region. It then explains that I can change these settings either on the settings page or in wp-config.php. Clicking the link to the settings page I get:

    A Mailgun account is required to use this plugin and the Mailgun service.
    
    If you need to register for an account, you can do so at Mailgun.com.
    Configuration
    
    Once you have configured the plugin settings in your wp-config.php, you can test it here.
    
    The definitions are as follows:
    
    MAILGUN_REGION		Choices: 'us' or 'eu'
    	ex. define('MAILGUN_REGION', 'us');
    MAILGUN_USEAPI		Choices: '0' or '1' (0 = false/no)
    MAILGUN_APIKEY
    MAILGUN_DOMAIN
    MAILGUN_USERNAME
    MAILGUN_PASSWORD
    MAILGUN_SECURE
    MAILGUN_SECTYPE		Choices: 'ssl' or 'tls'
    MAILGUN_FROM_NAME
    MAILGUN_FROM_ADDRESS
    			
    Lists
    Shortcode 	
    [mailgun id="{mailgun list id}" collect_name="true"]
    
    Use the shortcode above to associate a widget instance with a mailgun list
    Lists 	View available lists.

    There is no longer a way to change the settings on the settings page. Is this by design? Because it seems a bit weird. There is also no way to enter my API key, so that would suggest the only way to enter this is by using wp-config.php. But how does that work with multi-site? I use different From addresses for different domains.

    Important:

    My previous settings from 1.5.14 are still saved however. If I send a test e-mail or use my contact form, everything still works including the different From addresses I set previously. I just have no way of changing the settings anymore, unless I dive directly into the WordPress database or edit wp-config.php by hand.

    I just can’t help but feel this is not as intended.

    • This topic was modified 4 months, 2 weeks ago by  blueclochard.
Viewing 15 replies - 1 through 15 (of 15 total)
  • I’m also seeing the same “minimal” settings page with v1.6 on a single site WordPress set up. Another site on the same server also using v1.6 displays the usual “user friendly” version of the settings page. Would like to know why there is a difference.

    +1!

    I just came here to report the same issue.

    I’m confused about where the interface went, especially since I use Mailgun on a multiste network and need to use separate domains for each subsite.

    Same thing as above, I rant the Test Configuration and everything works normally, so it looks like the settings are still in the database somewhere.

    I would also agree that this does not look intentional, and if it was, this is no bueno.

    Same issue here.
    Please can you (@mailgun) provide follow up on this? (Bring back the UI settings please?)
    Thank you.

    Update…
    What is “MAILGUN_SECURE”? What are the parameters?
    The other settings are self explanatory, except the above.

    For anyone else that needs some help, I took a look at the database and found the existing data still stored in wp_options. Look for the option name “mailgun”. Or just search for it.

    You can duplicate the existing, working settings, from the database, to look something similar to the below syntax usage (but DO NOT edit your database):

    define('MAILGUN_REGION', 'us');
    define('MAILGUN_USEAPI', '1');
    define('MAILGUN_APIKEY', 'key-XXXXXXXXXXXXXXXXXXXXXX');
    define('MAILGUN_DOMAIN', 'mg.yourdomain.com');
    define('MAILGUN_USERNAME', 'postmaster@mg.yourdomain.com');
    define('MAILGUN_PASSWORD', 'XXXXXXXXXXXXXXXXXXXXXX');
    define('MAILGUN_SECURE', '1');
    define('MAILGUN_SECTYPE', 'ssl');
    define('MAILGUN_FROM_NAME', 'SomeName');
    define('MAILGUN_FROM_ADDRESS', 'some-email@yourdomain.com');

    Naturally, you would substitute (adding) your correct settings instead of using the above as is.

    I observed more settings than were advised in the version 1.6 updated screen

    I hope this helps someone in some small way.

    Me too

    me as well – multisite

    Same here. We use this on many multisites and need different mailgun credentials per site. With this new settings interface this is impossible without additional logic in the wp-config file.

    I agree with the above as I do not believe this was an intended change.

    Gonçalo Peres

    (@gonperesgmailcom)

    Same problem here, also using WordPress Multisite 4.9.8.
    You cannot change the settings on wp-config.php on a Multisite instalation, because all sites share the same wp-config.php file and we need different settings for each domain.
    Went back to version 1.5.14 until this is fixed.

    From what I can see it looks like this was an intentional change.

    Look in includes/options-page.php on line 68 and 408. You will see the following:
    if (!$isMultisite):

    Basically forcing the user to use wp-config on a multi-site install. Removing this logic actually brings back the admin fields and can be edited properly. I believe instead of one or the other give both options. Some people use the wp-config.php while others use the admin. Leave them both in there as you have support for both.

    I removed the logic for now but this was definitely poorly implemented on their end. Below is a working file without the updated broken multi-site admin interface.

    <?php
    
    	/*
    	 * mailgun-wordpress-plugin - Sending mail from WordPress using Mailgun
    	 * Copyright (C) 2016 Mailgun, et al.
    	 *
    	 * This program is free software; you can redistribute it and/or modify
    	 * it under the terms of the GNU General Public License as published by
    	 * the Free Software Foundation; either version 2 of the License, or
    	 * (at your option) any later version.
    	 *
    	 * This program is distributed in the hope that it will be useful,
    	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    	 * GNU General Public License for more details.
    	 *
    	 * You should have received a copy of the GNU General Public License along
    	 * with this program; if not, write to the Free Software Foundation, Inc.,
    	 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    	 */
    
    ?>
    <div class="wrap">
    	<div id="icon-options-general" class="icon32"><br/></div>
    	<span class="alignright">
    				<a target="_blank" href="http://www.mailgun.com/">
    					<img src="https://assets.mailgun.com/img/mailgun.svg" alt="Mailgun" style="width:10em;"/>
    				</a>
    			</span>
    	<h2><?php _e('Mailgun', 'mailgun'); ?></h2>
    	<p>
    		<?php
    			$url = 'https://www.mailgun.com';
    			$link = sprintf(
    				wp_kses(
    					__('A <a href="%1$s" target="%2$s">Mailgun</a> account is required to use this plugin and the Mailgun service.', 'mailgun'),
    					array('a' => array(
    							'href' => array(),
    							'target' => array()
    						)
    					)
    				), esc_url($url), '_blank'
    			);
    			echo $link;
    		?>
    	</p>
    	<p>
    		<?php
    			$url = 'https://signup.mailgun.com/new/signup';
    			$link = sprintf(
    				wp_kses(
    					__('If you need to register for an account, you can do so at <a href="%1$s" target="%2$s">Mailgun.com</a>.', 'mailgun'),
    					array('a' => array(
    							'href' => array(),
    							'target' => array()
    						)
    					)
    				), esc_url($url), '_blank'
    			);
    			echo $link;
    		?>
    	</p>
    
    	<h3><?php _e('Configuration', 'mailgun'); ?></h3>
    
    	<?php
    		$isMultisite = defined('WP_ALLOW_MULTISITE');
    		$wpConfigSettings = defined('MAILGUN_DOMAIN');
    		if (!$isMultisite || !$wpConfigSettings):
    	?>
    	<form id="mailgun-form" action="options.php" method="post">
    		<?php settings_fields('mailgun'); ?>
    
    		<table class="form-table">
    			<tr valign="top">
    				<th scope="row">
    					<?php _e('Select Your Region', 'mailgun'); ?>
    				</th>
    				<td>
    					<select id="mailgun-region" name="mailgun[region]">
    						<option value="us"<?php selected('us', $this->get_option('region')); ?>><?php _e('U.S./North America', 'mailgun') ?></option>
    						<option value="eu"<?php selected('eu', $this->get_option('region')); ?>><?php _e('Europe', 'mailgun') ?></option>
    					</select>
    					<p class="description">
    						<?php
    							_e('Choose a region - U.S./North America or Europe - from which to send email, and to store your customer data. Please note that your sending domain must be set up in whichever region you choose.', 'mailgun');
    						?>
    					</p>
    				</td>
    			</tr>
    			<tr valign="top">
    				<th scope="row">
    					<?php _e('Use HTTP API', 'mailgun'); ?>
    				</th>
    				<td>
    					<select id="mailgun-api" name="mailgun[useAPI]">
    						<option value="1"<?php selected('1', $this->get_option('useAPI')); ?>><?php _e('Yes', 'mailgun'); ?></option>
    						<option value="0"<?php selected('0', $this->get_option('useAPI')); ?>><?php _e('No', 'mailgun'); ?></option>
    					</select>
    					<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>
    				</td>
    			</tr>
    			<tr valign="top">
    				<th scope="row">
    					<?php _e('Mailgun Domain Name', 'mailgun'); ?>
    				</th>
    				<td>
    					<input type="text" class="regular-text"
    						   name="mailgun[domain]"
    						   value="<?php esc_attr_e($this->get_option('domain')); ?>"
    						   placeholder="samples.mailgun.org"
    					/>
    					<p class="description">
    						<?php _e('Your Mailgun Domain Name.', 'mailgun'); ?>
    					</p>
    				</td>
    			</tr>
    			<tr valign="top" class="mailgun-api">
    				<th scope="row">
    					<?php _e('API Key', 'mailgun'); ?>
    				</th>
    				<td>
    					<input type="text" class="regular-text" name="mailgun[apiKey]"
    						   value="<?php esc_attr_e($this->get_option('apiKey')); ?>"
    						   placeholder="key-3ax6xnjp29jd6fds4gc373sgvjxteol0"
    					/>
    					<p class="description">
    						<?php
    							_e('Your Mailgun API key. Only valid for use with the API.', 'mailgun');
    						?>
    					</p>
    				</td>
    			</tr>
    			<tr valign="top" class="mailgun-smtp">
    				<th scope="row">
    					<?php _e('Username', 'mailgun'); ?>
    				</th>
    				<td>
    					<input type="text" class="regular-text"
    						   name="mailgun[username]"
    						   value="<?php esc_attr_e($this->get_option('username')); ?>"
    						   placeholder="postmaster"
    					/>
    					<p class="description">
    						<?php
    							_e('Your Mailgun SMTP username. Only valid for use with SMTP.', 'mailgun');
    						?>
    					</p>
    				</td>
    			</tr>
    			<tr valign="top" class="mailgun-smtp">
    				<th scope="row">
    					<?php _e('Password', 'mailgun'); ?>
    				</th>
    				<td>
    					<input type="text" class="regular-text"
    						   name="mailgun[password]"
    						   value="<?php esc_attr_e($this->get_option('password')); ?>"
    						   placeholder="my-password"
    					/>
    					<p class="description">
    						<?php
    							_e('Your Mailgun SMTP password that goes with the above username. Only valid for use with SMTP.', 'mailgun');
    						?>
    					</p>
    				</td>
    			</tr>
    			<tr valign="top" class="mailgun-smtp">
    				<th scope="row">
    					<?php _e('Use Secure SMTP', 'mailgun'); ?>
    				</th>
    				<td>
    					<select name="mailgun[secure]">
    						<option value="1"<?php selected('1', $this->get_option('secure')); ?>><?php _e('Yes', 'mailgun'); ?></option>
    						<option value="0"<?php selected('0', $this->get_option('secure')); ?>><?php _e('No', 'mailgun'); ?></option>
    					</select>
    					<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>
    				</td>
    			</tr>
    			<tr valign="top" class="mailgun-smtp">
    				<th scope="row">
    					<?php _e('Security Type', 'mailgun'); ?>
    				</th>
    				<td>
    					<select name="mailgun[sectype]">
    						<option value="ssl"<?php selected('ssl', $this->get_option('sectype')); ?>>SSL</option>
    						<option value="tls"<?php selected('tls', $this->get_option('sectype')); ?>>TLS</option>
    					</select>
    					<p class="description">
    						<?php
    							_e('Leave this at "TLS" unless mail sending fails. This option only matters for Secure SMTP. Default "TLS".', 'mailgun');
    						?>
    					</p>
    				</td>
    			</tr>
    			<tr valign="top">
    				<th scope="row">
    					<?php _e('Click Tracking', 'mailgun'); ?>
    				</th>
    				<td>
    					<select name="mailgun[track-clicks]">
    						<option value="htmlonly"<?php selected('htmlonly', $this->get_option('track-clicks')); ?>><?php _e('HTML Only', 'mailgun'); ?></option>
    						<option value="yes"<?php selected('yes', $this->get_option('track-clicks')); ?>><?php _e('Yes', 'mailgun'); ?></option>
    						<option value="no"<?php selected('no', $this->get_option('track-clicks')); ?>><?php _e('No', 'mailgun'); ?></option>
    					</select>
    					<p class="description">
    						<?php
    							$url = 'http://documentation.mailgun.com/user_manual.html#tracking-clicks';
    							$link = sprintf(
    								wp_kses(
    									__('If enabled, Mailgun will and track links. <a href="%1$s" target="%2$s">Open Tracking Documentation</a>.', 'mailgun'),
    									array('a' => array(
    										'href' => array(),
    										'target' => array()
    										)
    									)
    								), esc_url($url), '_blank'
    							);
    							echo $link;
    						?>
    					</p>
    				</td>
    			</tr>
    			<tr valign="top">
    				<th scope="row">
    					<?php _e('Open Tracking', 'mailgun'); ?>
    				</th>
    				<td>
    					<select name="mailgun[track-opens]">
    						<option value="1"<?php selected('1', $this->get_option('track-opens')); ?>><?php _e('Yes', 'mailgun'); ?></option>
    						<option value="0"<?php selected('0', $this->get_option('track-opens')); ?>><?php _e('No', 'mailgun'); ?></option>
    					</select>
    					<p class="description">
    						<?php
    							$url = 'http://documentation.mailgun.com/user_manual.html#tracking-opens';
    							$link = sprintf(
    								wp_kses(
    									__('If enabled, HTML messages will include an open tracking beacon. <a href="%1$s" target="%2$s">Open Tracking Documentation</a>.', 'mailgun'),
    									array('a' => array(
    										'href' => array(),
    										'target' => array()
    										)
    									)
    								), esc_url($url), '_blank'
    							);
    							echo $link;
    						?>
    					</p>
    				</td>
    			</tr>
    			<tr valign="top">
    				<th scope="row">
    					<?php _e('From Address', 'mailgun'); ?>
    				</th>
    				<td>
    					<input type="text"
    						   class="regular-text"
    						   name="mailgun[from-address]"
    						   value="<?php esc_attr_e($this->get_option('from-address')); ?>"
    						   placeholder="wordpress@mydomain.com"
    					/>
    					<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 <code>From</code> address on sent mail. <strong>It is recommended that the @mydomain portion matches your Mailgun sending domain.</strong>', 'mailgun');
    						?>
    					</p>
    				</td>
    			</tr>
    			<tr valign="top">
    				<th scope="row">
    					<?php _e('From Name', 'mailgun'); ?>
    				</th>
    				<td>
    					<input type="text" class="regular-text"
    						   name="mailgun[from-name]"
    						   value="<?php esc_attr_e($this->get_option('from-name')); ?>"
    						   placeholder="WordPress"
    					/>
    					<p class="description">
    						<?php
    							_e('The "User Name" part of the sender information (<code>"Excited User <user@samples.mailgun.org>"</code>).', 'mailgun');
    						?>
    					</p>
    				</td>
    			</tr>
    			<tr valign="top">
    				<th scope="row">
    					<?php _e('Override "From" Details', 'mailgun'); ?>
    				</th>
    				<td>
    					<select name="mailgun[override-from]">
    						<option value="1"<?php selected('1', $this->get_option('override-from', null, '0')); ?>><?php _e('Yes', 'mailgun'); ?></option>
    						<option value="0"<?php selected('0', $this->get_option('override-from', null, '0')); ?>><?php _e('No', 'mailgun'); ?></option>
    					</select>
    					<p class="description">
    						<?php
    							_e('If enabled, all emails will be sent with the above "From Name" and "From Address", regardless of values set by other plugins. Useful for cases where other plugins don\'t play nice with our "From Name" / "From Address" setting.', 'mailgun');
    						?>
    					</p>
    				</td>
    			</tr>
    			<tr valign="top">
    				<th scope="row">
    					<?php _e('Tag', 'mailgun'); ?>
    				</th>
    				<td>
    					<input type="text" class="regular-text"
    						   name="mailgun[campaign-id]"
    						   value="<?php esc_attr_e($this->get_option('campaign-id')); ?>"
    						   placeholder="tag"
    					/>
    					<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');
    							_e('Learn more about', 'mailgun');
    
    							$url1 = 'https://documentation.mailgun.com/user_manual.html#tracking-messages';
    							$url2 = 'https://documentation.mailgun.com/user_manual.html#tagging';
    							$link = sprintf(
    								wp_kses(
    									__('<a href="%1$s" target="%3$s">Tracking</a> and <a href="%2$s">Tagging</a>', 'mailgun'),
    									array('a' => array(
    										'href' => array(),
    										'target' => array()
    										)
    									)
    								), esc_url($url1), esc_url($url2), '_blank'
    							);
    							echo $link;
    						?>
    					</p>
    				</td>
    			</tr>
    		</table>
    		<?php else: ?>
    			<p>
    				<?php
    					_e('Once you have configured the plugin settings in your wp-config.php, you can test it here.', 'mailgun');
    				?>
    			</p>
    			<p><?php _e('The definitions are as follows:', 'mailgun'); ?></p>
    			<p>
    			<pre>
    MAILGUN_REGION		Choices: 'us' or 'eu'
    	ex. define('MAILGUN_REGION', 'us');
    MAILGUN_USEAPI		Choices: '0' or '1' (0 = false/no)
    MAILGUN_APIKEY
    MAILGUN_DOMAIN
    MAILGUN_USERNAME
    MAILGUN_PASSWORD
    MAILGUN_SECURE
    MAILGUN_SECTYPE		Choices: 'ssl' or 'tls'
    MAILGUN_FROM_NAME
    MAILGUN_FROM_ADDRESS
    			</pre>
    			</p>
    		<?php endif; ?>
    		<h3><?php _e('Lists', 'mailgun'); ?></h3>
    		<table class="form-table">
    			<tr valign="top">
    				<th scope="row">
    					<?php _e('Shortcode', 'mailgun'); ?>
    				</th>
    				<td>
    					<div>
    						<code>[mailgun id="<em>{mailgun list id}</em>" collect_name="true"]</code>
    					</div>
    					<div>
    						<p class="description">
    							<?php
    								_e('Use the shortcode above to associate a widget instance with a mailgun list', 'mailgun');
    							?>
    						</p>
    					</div>
    				</td>
    			</tr>
    			<tr valign="top">
    				<th scope="row">
    					<?php _e('Lists', 'mailgun'); ?>
    				</th>
    				<td>
    					<?php
    						$url = '?page=mailgun-lists';
    
    						$link = sprintf(
    							wp_kses(
    								__('<a href="%1$s" target="%2$s">View available lists</a>.', 'mailgun'),
    								array('a' => array(
    									'href' => array(),
    									'target' => array()
    									)
    								)
    							), esc_url($url), '_blank'
    						);
    						echo $link;
    					?>
    				</td>
    			</tr>
    		</table>
    
    		<?php if (!$isMultisite || !$wpConfigSettings): ?>
    			<p>
    				<?php
    					_e('Before attempting to test the configuration, please click "Save Changes".', 'mailgun');
    				?>
    			</p>
    			<p class="submit">
    				<input type="submit"
    					   class="button-primary"
    					   value="<?php _e('Save Changes', 'mailgun'); ?>"
    				/>
    				<input type="button"
    					   id="mailgun-test"
    					   class="button-secondary"
    					   value="<?php _e('Test Configuration', 'mailgun'); ?>"
    				/>
    			</p>
    		<?php else: ?>
    			<p class="submit">
    				<input type="button"
    					   id="mailgun-test"
    					   class="button-secondary"
    					   value="<?php _e('Test Configuration', 'mailgun'); ?>"
    				/>
    			</p>
    		<?php endif; ?>
    	</form>
    </div>
    

    UPDATED: I changed the file to check for the MAILGUN_DOMAIN Constant on Multisite and if it doesn’t exist bring back the interface.

    • This reply was modified 4 months, 1 week ago by  rhinogroup.
    • This reply was modified 4 months, 1 week ago by  rhinogroup.
    • This reply was modified 4 months, 1 week ago by  rhinogroup.

    You the real MVP, rhinogroup.

    Thanks for sharing your fix while we impatiently await Mailgun to [hopefully] roll out a new update!

    @rhinogroup, thanks for this solution. I still would like to hear from Mailgun whether this was intentional or not though.

    Fixed in 1.6.1, thanks!

    Gonçalo Peres

    (@gonperesgmailcom)

    Version 1.7 of the Mailgun plugin again removes the settings page for Multisite installations.
    This is no good because we need different settings for each domain.

    To fix this, I went to “includes/admin.php” and commented the logic that removes the settings page on Multisite. Basically I just commented lines 46 an 55. As simples as this:

    //if( (!defined('MULTISITE') || !MULTISITE) && (!defined('MAILGUN_USEAPI') || !MAILGUN_USEAPI) ):
    	// Hook into admin_init and register settings and potentially register an admin_notice
    	add_action('admin_init', array(&$this, 'admin_init'));
    
    	// Activate the options page
    	add_action('admin_menu', array(&$this, 'admin_menu'));
    
    	// Register an AJAX action for testing mail sending capabilities
    	add_action('wp_ajax_mailgun-test', array(&$this, 'ajax_send_test'));
    //endif;

    But I ask the plugin developers to please make the settings page available again.
    I don’t understand why you removed it? It doesn’t make sense and it still works with this simple fix.

    +1 to @gonperesgmailcom. I saw that they removed the multisite settings once again in the 1.7 changelog, so I refrained from updating this go around. We need different domains for each install too, so I’m seriously questioning why they would intentionally do this..

    @gonperesgmailcom , I tried your fix but it did not seem to take on my install. Was there anything else you did?

    Never mind, commented out the entire thing by mistake.

    • This reply was modified 1 week, 5 days ago by  taropaa.
Viewing 15 replies - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.