Title: phpmailer error after moving to https
Last modified: January 26, 2017

---

# phpmailer error after moving to https

 *  Resolved [mbogh77](https://wordpress.org/support/users/mbogh77/)
 * (@mbogh77)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/phpmailer-error-after-moving-to-https/)
 * Hi there I have been getting error messages on bp member approval action as follows:
   Fatal error: Uncaught exception ‘phpmailerException’ with message ‘Invalid address:(
   setFrom) ____@https://____.com
 * We are currently running v4.7.1 but did not see any problems until we changed
   our site over to https. We have found that if we revert back to http we dont 
   see the error. Obviously running as https will be something most sites will be
   looking to do following the recent announcements from google – especially membership/
   eCommerce sites.
 * I have been told that all I have to do is set the from address in the settings
   of the plugin using phpmailer.php and as the error is coming when using the functions
   within your plugin I thought I’d check with you first.

Viewing 12 replies - 1 through 12 (of 12 total)

 *  [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [9 years, 4 months ago](https://wordpress.org/support/topic/phpmailer-error-after-moving-to-https/#post-8702759)
 * Hi [@mbogh77](https://wordpress.org/support/users/mbogh77/).
 * Looks like, somehow, you managed to get an invalid email address all the way 
   through the wp_mail() function.
 *     ```
       ____@https://____.com
       ```
   
 * From my understanding, the “[https://&#8221](https://&#8221); is what’s invalidating
   it.
 * It’s possible it’s getting set at [https://github.com/WordPress/WordPress/blob/4.7.1/wp-includes/pluggable.php#L263-L269](https://github.com/WordPress/WordPress/blob/4.7.1/wp-includes/pluggable.php#L263-L269)
 * It’s also possible you’re getting it to [https://github.com/WordPress/WordPress/blob/4.7.1/wp-includes/pluggable.php#L317-L332](https://github.com/WordPress/WordPress/blob/4.7.1/wp-includes/pluggable.php#L317-L332)
   and the parsing isn’t managing to catch the “[https://&#8221](https://&#8221);
   to remove it.
 * This is the line that is trying to use the value you’re getting through: [https://github.com/WordPress/WordPress/blob/4.7.1/wp-includes/pluggable.php#L352](https://github.com/WordPress/WordPress/blob/4.7.1/wp-includes/pluggable.php#L352)
 * I’m not sure if this is something I’m going to be able to troubleshoot to help
   prevent from our plugin, to be honest, but worth a shot as time permits. All 
   you did was get the SSL certificate, and then try to use the plugin and start
   receiving signups etc? Trying to make sure I have everything needed to recreate
   on my own.
 * As a possible hotfix for you, you could do something like the following:
 *     ```
       function mbogh_email_bpro_hotfix( $email ) {
       	if ( false === strpos( $email, 'https://' ) ) {
       		// Nothing found, return untouched.
       		return $email;
       	}
       	//We found something, let's remove it.
       	return str_replace( 'https://', '', $email );
       }
       add_filter( 'wp_mail_from', 'mbogh_email_bpro_hotfix' );
       ```
   
 * You’ll want to add this to your theme’s functions.php, and look it over to make
   sure this is matching up appropriately with what you’re actually seeing in your
   error logs.
 *  Thread Starter [mbogh77](https://wordpress.org/support/users/mbogh77/)
 * (@mbogh77)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/phpmailer-error-after-moving-to-https/#post-8703893)
 * hmmm, this is strange. I have replied but I cannot see the message I wrote to
   you – I hope you have received it.
 *  [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [9 years, 4 months ago](https://wordpress.org/support/topic/phpmailer-error-after-moving-to-https/#post-8703903)
 * Only replies I’ve seen come through have been trying to debug why you couldn’t
   see a previous reply.
 *  Thread Starter [mbogh77](https://wordpress.org/support/users/mbogh77/)
 * (@mbogh77)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/phpmailer-error-after-moving-to-https/#post-8704085)
 * I have tried again and still it will not let me post the reply and then I get
   this message:
 * ERROR: Duplicate reply detected; it looks as though you’ve already said that!
 * I am not doing so well here :0(
 *  Thread Starter [mbogh77](https://wordpress.org/support/users/mbogh77/)
 * (@mbogh77)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/phpmailer-error-after-moving-to-https/#post-8704087)
 * Shoot – ok I try again thank you.
 * So the site was running originally in non SSL (http). We had cloudflare running
   and BP registration options – everything was working perfectly. Then I followed
   this article to set up SSL using cloudflare: [https://jonnyjordan.com/blog/how-to-setup-cloudflare-flexible-ssl-for-wordpress/](https://jonnyjordan.com/blog/how-to-setup-cloudflare-flexible-ssl-for-wordpress/)
 * It was after this step we started seeing the error.
 *  Thread Starter [mbogh77](https://wordpress.org/support/users/mbogh77/)
 * (@mbogh77)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/phpmailer-error-after-moving-to-https/#post-8704094)
 * I then removed the 2 plugins suggested in the article and stopped cloudflare –
   reverted to http and everything was fine again.
 *  Thread Starter [mbogh77](https://wordpress.org/support/users/mbogh77/)
 * (@mbogh77)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/phpmailer-error-after-moving-to-https/#post-8704114)
 * Sorry, there is more but again it will not let me post the next part of the message.
 *  Thread Starter [mbogh77](https://wordpress.org/support/users/mbogh77/)
 * (@mbogh77)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/phpmailer-error-after-moving-to-https/#post-8704116)
 * Then I took the more traditional approach using a certificate installed on our
   server / host.
 *  Thread Starter [mbogh77](https://wordpress.org/support/users/mbogh77/)
 * (@mbogh77)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/phpmailer-error-after-moving-to-https/#post-8704127)
 * I followed an article but cannot give the link as it keeps refusing the post.
 *  Thread Starter [mbogh77](https://wordpress.org/support/users/mbogh77/)
 * (@mbogh77)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/phpmailer-error-after-moving-to-https/#post-8704130)
 * Anyway the result is that the error is back again.
 * Here is the full error message if that helps with further diagnosis – reads as
   follows:
 * Fatal error: Uncaught exception ‘phpmailerException’ with message ‘Invalid address:(
   setFrom) notifications@https://www.________.com’ in /______/wp-includes/class-
   phpmailer.php:1023 Stack trace: #0 /_____/wp-includes/pluggable.php(352): PHPMailer-
   >setFrom(‘notifications@h…’, ‘The website’, false) #1 /_____/wp-content/plugins/
   bp-registration-options/includes/admin.php(303): wp_mail(‘caseyasay777@ya…’, ‘
   Membership Appr…’, ‘Welcome caseyas…’) #2 [internal function]: bp_registration_options_form_actions(”)#
   3 /_____/wp-includes/class-wp-hook.php(298): call_user_func_array(‘bp_registration…’,
   Array) #4 /_____/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(”,
   Array) #5 /_____/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #6 _____/
   wp-admin/admin.php(154): do_action(‘admin_ in /_____/wp-includes/class-phpmailer.
   php on line 1023
 * Your first reply is great, I will try the links you have provided and see how
   far I can get. Thank you.
 *  [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [9 years, 4 months ago](https://wordpress.org/support/topic/phpmailer-error-after-moving-to-https/#post-8704803)
 * Upon coming back to this thread, I’m pretty confident the issue is coming from
   [https://github.com/WordPress/WordPress/blob/4.7.1/wp-includes/pluggable.php#L326](https://github.com/WordPress/WordPress/blob/4.7.1/wp-includes/pluggable.php#L326)
 * My hunch is that the `$_SERVER['SERVER_NAME']` value is somehow getting set to
   be a full URL instead of just `www.domain.com` or `domain.com`, and that’s tripping
   things up, resulint in the `$from_email` being set to `wordpress@https://domain.
   com` which is invalid due to my previous point.
 * This also makes sense since you’d be trying to change things to properly handle
   SSL certificates, it just may be touching on places it shouldn’t.
 *  Thread Starter [mbogh77](https://wordpress.org/support/users/mbogh77/)
 * (@mbogh77)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/phpmailer-error-after-moving-to-https/#post-8705556)
 * Hi Michael – I had a good read on the links you provided and started digging 
   into the underlying code. I actually did a hard set of the $from_email variable
   in the pluggable.php file and then worked my way through testing and following
   the error – but whatever I did the email address kept getting re-written with
   https in there. The I remembered that way back when we first set the site up 
   I had added some code to the functions.php to modify the from email address following
   this article: [https://premium.wpmudev.org/blog/wordpress-email-settings/](https://premium.wpmudev.org/blog/wordpress-email-settings/)
 * Removing that code alone has fixed / resolved the error – everything else is 
   now back as it was an we are running with SSL ! ! !
 * Thank you so much for taking the time to help me get to the bottom of it. Hopefully
   this little thread may help someone else in the future.

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘phpmailer error after moving to https’ is closed to new replies.

 * ![](https://ps.w.org/bp-registration-options/assets/icon-256x256.png?rev=2882040)
 * [Registration Options for BuddyPress](https://wordpress.org/plugins/bp-registration-options/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/bp-registration-options/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/bp-registration-options/)
 * [Active Topics](https://wordpress.org/support/plugin/bp-registration-options/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/bp-registration-options/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/bp-registration-options/reviews/)

 * 14 replies
 * 2 participants
 * Last reply from: [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/phpmailer-error-after-moving-to-https/#post-8704803)
 * Status: resolved