Accounts.sendverification email not sending


#1

Good day,
My app no longer sends a verificationemail, after a user submits his registration details. I have registered with 2 different emails (one to gmail, the other to my workemail). None of these inboxes receive the verification email.

On the server I eventually get a timeout error: “Exception in setTimeout callback: Error: connect ETIMEDOUT”.

I also get an error on the client, but I am not sure if it is related to the email verification problem. I use firefox 40.0.3 and I get in the console: "Error: ", (blank) which is thrown from meteor.js 525:14

I think my problem might have to do with the latest Meteor 1.2 or that a function is called wrongly from either the client or server.

Any help will be greatly appreciated.
Please find below my code.

server/account.js
//=====================
Accounts.onCreateUser(function(options, user){
var newEmail = user.emails[0].address;
var emailAlreadyExist = Meteor.users.find({“emails.address”: newEmail}, {limit: 1}).count()>0;
if(emailAlreadyExist === true) {
throw new Meteor.Error(403, “email already registered”);
}
else {
if(options.profile) {
user.profile = options.profile;
} else {
user.profile = “No profile”
}
if (options.email) {
Meteor.setTimeout(function() { Accounts.sendVerificationEmail(user._id) }, 2000);
}
return user;
}
});

Accounts.validateLoginAttempt(function(attempt){
if (attempt.error){
throw new Meteor.Error(403, attempt.error.reason);
}
if (attempt.user && attempt.user.emails && !attempt.user.emails[0].verified ) {
console.log(‘email not verified’);
return false; // the login is aborted
}
return true;
});

server/smtp.js
//=====================
Meteor.startup(function () {
smtp = {
username: ‘xxxxx@gmail.com’,
password: ‘xxxx’,
server: ‘smtp.gmail.com’,
port: 25
}

process.env.MAIL_URL = 'smtp://' +  // For user password reset
        encodeURIComponent(smtp.username) + ':' +
        encodeURIComponent(smtp.password) + '@' +
        encodeURIComponent(smtp.server) + ':' +
        smtp.port;

Accounts.config({sendVerificationEmail: true});
Accounts.emailTemplates.from = 'UP <xxxxxxx@gmail.com>';
Accounts.emailTemplates.siteName = 'U Pipe';
Accounts.emailTemplates.verifyEmail.subject = function(user) {
    return 'Confirm Your Email Address, '+user.username;
};
Accounts.emailTemplates.verifyEmail.text = function(user, url) {
    return "Welcome U Pipe! \n" +
        "Click on the following link to verify your email address: " + url;
};

});

client/register.js
//====================
Template.page_register.events({
‘submit #form_register’ : function(event, template) {
event.preventDefault();
var firstname = trimInput(template.find(’#register_firstname’).value.toLowerCase()),
lastname = trimInput(template.find(’#register_lastname’).value.toLowerCase()),
email = trimInput(template.find(’#register_email’).value.toLowerCase()),
password = template.find(’#register_password’).value,
confirmpassword = template.find(’#register_confirmpassword’).value,
message;
// Client side validation
if (isNotEmpty(firstname) && isNotEmpty(lastname) && isNotEmpty(email) && isNotEmpty(password) && isEmail(email) && areValidPasswords(password, confirmpassword)) {
message = “Signing you up…”;
Accounts.createUser({email: email, password : password, profile:{firstname:firstname,lastname:lastname}}, function(error){
if (error) { // Server side validation
message = "There was an error registering: " + error.reason + “”;
} else {
Session.set(‘activemodel’,null);
message = “Account has been created and the user has logged in successfully”;
}
template.find(’#account_messages’).innerHTML=message;
});
}
else if (!isNotEmpty(firstname)) {
message = “Please provide your firstname”;
}
else if (!isNotEmpty(lastname)) {
message = “Please provide your lastname”;
}
else if (!isNotEmpty(email)) {
message = “Please provide your email address”;
}
else if (!isNotEmpty(password)) {
message = “Please provide a password”;
}
else if (password!==confirmpassword) {
message = “Passwords do not match”;
}
else if (!isValidPassword(password)) {
message = “Password should be 6 characters or longer”;
}
template.find(’#account_messages’).innerHTML=message;
return false;
}
});


Meteor accounts sendVerificationEmail
#2

Good day,
I managed to get the code working again! Verification emails are being sent out again.