Help needed with Accounts.forgotPassword

Hello, I am having trouble with Accounts.forgotPassword.
I have done the following:

  1. I set the process.env.MAIL_URL to “smtp://admin:password@sandboxd1d03e5d396e4db3a0aeff298404ab71.mailgun.org:587”;
  2. I am calling the forgotten pass function on the client (I think) as follows:
import React from "react";
import {Link} from 'react-router';
import LanguageChanger from '../ui/LanguageChanger';
import {Session} from "meteor/session";
import {withTracker} from "meteor/react-meteor-data";
import PropTypes from 'prop-types';
import {Accounts} from 'meteor/accounts-base';

export class ForgottenPassword extends React.Component{
    constructor(props) {
        super(props);
        this.state =  {
            error:""
        };
    }

    onSubmit(e) {
        e.preventDefault();
        let email = this.refs.email.value.trim();
        console.log('email', email);

        Accounts.forgotPassword({email: email}, function (e, r) {
            if (e) {
                console.log(e.reason);
            } else {
                // success
            }
        });
    }

    render () {

        return (
            <div>
                <h1> {this.props.staticTexts.forgottenPasswordTexts[0]} </h1>
                {this.state.error?<p>{this.state.error}</p> : undefined}
                <form onSubmit={this.onSubmit.bind(this)} noValidate>
                    <input type="email" ref="email" name = "email" placeholder = {this.props.staticTexts.forgottenPasswordTexts[1]} />
                    <button> {this.props.staticTexts.forgottenPasswordTexts[2]}</button>
                </form>
                <Link to="/"> {this.props.staticTexts.forgottenPasswordTexts[3]}</Link>
                <LanguageChanger/>
            </div>
        );
    }
}
ForgottenPassword.propTypes = {
    staticTexts:PropTypes.object.isRequired,
};
export default withTracker( () => {
    const   staticTexts = Session.get('staticTexts');
    return {
        staticTexts
    };
}) (ForgottenPassword);

And each and every time I run this on my localhost:3000, I get the following output…

I20190117-14:50:06.709(2)? Exception while invoking method 'forgotPassword' { Error: connect ETIMEDOUT 34.205.179.96:587
I20190117-14:50:06.711(2)?     at Object._errnoException (util.js:992:11)
I20190117-14:50:06.711(2)?     at _exceptionWithHostPort (util.js:1014:20)
I20190117-14:50:06.711(2)?     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)
I20190117-14:50:06.712(2)?   code: 'ECONNECTION',
I20190117-14:50:06.712(2)?   errno: 'ETIMEDOUT',
I20190117-14:50:06.712(2)?   syscall: 'connect',
I20190117-14:50:06.713(2)?   address: '34.205.179.96',
I20190117-14:50:06.713(2)?   port: 587,
I20190117-14:50:06.713(2)?   command: 'CONN' }

I tried many things, for example:

  1. uninstall and reinstall email package with version 1.2.0,
  2. try to set smtp server
  3. deploy to heroku and add that domain to mailgun (which is what I am trying to use here)…
    and so on…
    Can you please help me out, because I am starting to lose my patience and this is not good… (e.g. the computer is in grave danger - and he is innocent as always)… Or is he??

All the best,
Peter Y.

I ping your mailgun domain, it’s not 34.205.179.96. I think there is something wrong with your MAIL_URL env.

Ok, but what could it be?
It is placed in the server and it looks like this:

import { Meteor } from 'meteor/meteor';
import '../imports/api/users';

Meteor.startup(() => {
    process.env.MAIL_URL="smtp://admin:44wr11er1-897WET028-qafaax@sandboxd1d03e5d396e4db3a0aeff298404ab71.mailgun.org:587";
});

Other than that I even tried an external service, which did send the email, so you are most likely right…

I mean… do I need to configure something else, like an IP or anything, because this is the only config I am doing…

are you sure those sandbox account works?

So it seems…

OMG!!! Sorry to waste your time… I WAS DOING IT WRONG…
I followed this link: https://themeteorchef.com/tutorials/using-the-email-package and there it is: Mail_URL = username with the sandbox:password@smtp.mailgun.org:587 - fantastic…
Anyway - it works now.
Thank you so much for your time and support - I nearly lost hope to ever fix it…

1 Like