Hello, I’m having a really frustrating problem. I have SMTP setup with Mailgun, and when I send an email through the Communicate form in the System Utilities it works just fine. But when I try to use the default password reset form, I receive the error “Unable to send email at this time.”
This occurs after the site hangs for a bit. I echo’d out the site_system_preferences in the exp_sites table just to make sure the SMTP settings were the same in there, and they are. I’m really at a loss and I don’t know how to troubleshoot this any further.
Running EE 5.3.0, any help would be appreciated.
-Earl
Odd one. The email settings should be the same for each. I have seen something similar when the email subject was really long.
Try sending the email from communicate with the exact same subject and content it would have if sent from the password reset. See if it still goes through ok.
Subject: Login information
{name},
To reset your password, please go to the following page:
{reset_url}
Then log in with your username: {username}
If you do not wish to reset your password, ignore this message. It will expire in 24 hours.
{site_name}
{site_url}
Just flip out the variables.
If that goes through ok, I personally would go in and right before it send the email, I’d var_dump the contents and exit- let’s make sure it’s getting to that point.
If you’re not sure where to do that, let me know which password reset form you’re doing- the one for the cp or the member template one. And I’m assuming you’re on v5, let me know if not.
Thanks for getting back to me Robin!
OK, so the site is setup to use EE Harbor’s User, so the email template I was using is a custom one that I setup to work with that. I copy/pasted that subject and email body into Communicate and it sent fine (replacing the variables with placeholder text).
With that being said, the standard EE reset template at member/forgot_password doesn’t work either, and I think that uses the standard User – Forgotten password instructions email template right?
I guess I should move on to doing a var_dump, and yeah, not totally sure where I need to do that. I’m running EE 5.3.0, and to test I’ll use the member/forgot_password template. I may even just stick with that if it works and the customer User template doesn’t.
Thanks again!
I’m also having this same issue. It’s definitely a bug with SMTP using mailgun. I’ve tried sending an email in EE using communicate and get this:
Error: Unable to send email at this time.
220 Mailgun Influx ready
hello: 250-smtp-out-n03.prod.us-west-2.postgun.com 250-AUTH PLAIN LOGIN 250-SIZE 52428800 250-8BITMIME 250-SMTPUTF8 250-PIPELINING 250 STARTTLS starttls: 220 Go ahead hello: 250-smtp-out-n03.prod.us-west-2.postgun.com 250-AUTH PLAIN LOGIN 250-SIZE 52428800 250-8BITMIME 250-SMTPUTF8 250 PIPELINING from: 250 Sender address accepted to: 250 Recipient address accepted data: 354 Continue
The following SMTP error was encountered: Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
I’ve also tried using our forgot password functionality and get this error: Warning fgets(): SSL operation failed with code 1. OpenSSL Error messages: error:0607A082:digital envelope routines:EVP_CIPHER_CTX_set_key_length:invalid key length ee/legacy/libraries/Email.php, line 2026
Severity: E_WARNING
Any ideas?
@Robin, if you could let me know which EE file I need to var_dump in to see the output that would be super helpful. I’ve been looking through the system files but I have no idea which one is actually responsible for sending emails. I’m trying to setup some ecommerce stuff asap, so getting to the bottom of this would be great, thank you!
Since emails are going out fine with Communicate, but they’re failing with the system’s password reset form, I have to assume their sending functions are slightly different? Maybe the way they connect to SMTP is slightly different and Mailgun is cool with the Communicate method but not with the way reset emails get sent?
If it were me, I’d go to system/ee/legacy/libraries/Email.php first- that’s closes to actual sending. It’s curious that one works and the other doesn’t, so comparing the two might prove fruitful. Around line 1528 is where it calls $this->_spool_email(); which does the sending. I might dump everything there or near the top of spool_email.
It rare that communicate works the frontend native email doesn’t- it’s got to be something quirky. Might play with line endings- maybe something is longer in the password reset and so triggering a line ending that communicate doesn’t. Something along those lines. Though I realize we already tried looking at that.
Man, such a dumb fix haha. Thanks for pointing me to the Email.php file Robin, I just didn’t know where it was.
The error was being thrown by Mailgun, but I still don’t know why it worked in Communicate and not from templates! My only guess is that the emails from Communicate were being sent as HTML and the ones from the system password reset template were being sent as text. That was the only difference I could see. Once I dumped the mail object, I saw the same error as phatmateo
The following SMTP error was encountered: Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
A couple searches later landed me on this SO post, and it was just the Newline character setting!
In the Outgoing Email settings, I just needed to update the \n setting to \r\n, which is apparently what Mailgun expects for new lines.
@phatmateo, because of the SSL error you mentioned as well, you may have some issues beyond this, but try updating your Newline character and see if that helps.
Thanks again, Robin!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.