Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMTP no longer works on newest builds #911

Closed
doomdance opened this issue Sep 27, 2015 · 10 comments
Closed

SMTP no longer works on newest builds #911

doomdance opened this issue Sep 27, 2015 · 10 comments

Comments

@doomdance
Copy link

I've built RC several times in the past weeks and implimented SMTP successfully each time. As of yesterday I have attempted two builds, each on clean servers, and one local build with meteor and sending emails through SMTP does not work on any of them. I have tested with multiple SMTP accounts as well and monitoring outgoing network connections (nothing). When I finally deployed locally I was able to see the following output in my terminal:

-20:27:47.910(-5)? ====== BEGIN MAIL #2 ======
I20150926-20:27:47.910(-5)? (Mail not sent; to enable sending, set the MAIL_URL environment variable.)
I20150926-20:27:47.910(-5)? MIME-Version: 1.0
I20150926-20:27:47.910(-5)? From: "Rocket.Chat" <no-reply@rocket.chat>
I20150926-20:27:47.910(-5)? To: XXXXXXXXXXXXXXXX@gmail.com
I20150926-20:27:47.910(-5)? Subject: How to verify email address on Rocket.Chat
I20150926-20:27:47.910(-5)? Content-Type: text/plain; charset=utf-8
I20150926-20:27:47.910(-5)? Content-Transfer-Encoding: quoted-printable
I20150926-20:27:47.910(-5)? 
I20150926-20:27:47.910(-5)? Hello,
I20150926-20:27:47.911(-5)? 
I20150926-20:27:47.911(-5)? To verify your account email, simply click the link below.
I20150926-20:27:47.911(-5)? 
I20150926-20:27:47.911(-5)? http://localhost:3000/login/#/verify-email/0dt-_2PFYTa8rK49BXsi9Q_E2ljFURJRcEJ926LUwWr
I20150926-20:27:47.911(-5)? 
I20150926-20:27:47.911(-5)? Thanks.
I20150926-20:27:47.911(-5)? 
I20150926-20:27:47.911(-5)? ====== END MAIL #2 ======

Bear with me as I'm not a developer but I also see there changes made a few days ago: https://github.com/RocketChat/Rocket.Chat/search?utf8=%E2%9C%93&q=MAIL_URL

Could these be the cause?

@k0nsl
Copy link
Contributor

k0nsl commented Sep 27, 2015

Thanks for bringing that up @doomdance, I was in the process of submitting an issue about this myself.

I use Mandrill for delivery and it worked fine until I pulled latest code from GH. I do not have any details at hand at the moment because I'm "on the go".

However, you're not alone with having this issue.

@k0nsl
Copy link
Contributor

k0nsl commented Sep 27, 2015

Okay, so I just tested it and I'm receiving the same message as @doomdance.

I20150926-21:29:10.172(-5)? (Mail not sent; to enable sending, set the MAIL_URL environment variable.)

@geekgonecrazy
Copy link
Contributor

Are you setting MAIL_URL? I assume no?

The loading of settings was recently changed to load quicker. I don't see anything else in the last few days involving that. We'll take a look.

@rwakida
Copy link
Contributor

rwakida commented Sep 27, 2015

It's because we're loading settings ASAP instead of waiting for Meteor.startup (like we used to). MAIL_URL is never set because RocketChat.settings.get calls returns undefined when the following code is executed:

if process?.env? and not process.env['MAIL_URL']? and RocketChat.settings.get('SMTP_Host') and RocketChat.settings.get('SMTP_Username') and RocketChat.settings.get('SMTP_Password')
        process.env['MAIL_URL'] = "smtp://" + encodeURIComponent(RocketChat.settings.get('SMTP_Username')) + ':' + encodeURIComponent(RocketChat.settings.get('SMTP_Password')) + '@' + encodeURIComponent(RocketChat.settings.get('SMTP_Host'))
        if RocketChat.settings.get('SMTP_Port')
            process.env['MAIL_URL'] += ':' + parseInt(RocketChat.settings.get('SMTP_Port'))

RocketChat.settings uses Meteor.settings behind the scenes, and even though we "add" the values, they aren't available until Meteor is fully initialized. Thus, we need to wrap it with Meteor.startup e.g.


Meteor.startup ->
    if process?.env? and not process.env['MAIL_URL']? and RocketChat.settings.get('SMTP_Host') and RocketChat.settings.get('SMTP_Username') and RocketChat.settings.get('SMTP_Password')
        process.env['MAIL_URL'] = "smtp://" + encodeURIComponent(RocketChat.settings.get('SMTP_Username')) + ':' + encodeURIComponent(RocketChat.settings.get('SMTP_Password')) + '@' + encodeURIComponent(RocketChat.settings.get('SMTP_Host'))
        if RocketChat.settings.get('SMTP_Port')
            process.env['MAIL_URL'] += ':' + parseInt(RocketChat.settings.get('SMTP_Port'))

rodrigok added a commit that referenced this issue Sep 28, 2015
Fix #911.  Set MAIL_URL variable after Meteor.startup
@doomdance
Copy link
Author

SMTP for account registration now works but it is still broken for password resetting and re-sending email confirmation.

@rwakida rwakida reopened this Sep 29, 2015
@rwakida rwakida self-assigned this Sep 29, 2015
@rwakida
Copy link
Contributor

rwakida commented Sep 29, 2015

@doomdance confirmed that password reset and re-send email confirmation not working. I found the problem, will submit pull request later tonight.

btw, how did you get to the re-send email confirmation page? I had to hack the login to get to it.

@doomdance
Copy link
Author

@rwakida If you try logging in as a user that is not verified, it should take you to this prompt.
screenshot from 2015-09-28 20-57-37

@rwakida
Copy link
Contributor

rwakida commented Sep 29, 2015

Cool. Thanks @doomdance. Not sure why I couldn't get to that before....oh well. I'll submit a pull request tonight.

@doomdance
Copy link
Author

Anytime! And thank you, @rwakida!

@rasathus
Copy link

I think Im seeing this issue on an instance I built a couple of weeks ago. Im struggling to work out how to tell what version of rocket chat I have installed currently. I can't find anything visible in the UI, or in the app.json etc. Do you know what release this was fixed in, and how I tell what version I currently have installed ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants