0

I am trying to send a verification email to users upon registration. I'm using Accounts.createUser to add users to the database and that works fine without any email verification system. HThen, when I try implementing email verification by using Accounts.sendVerificationEmail, it does not send any email. I have set MAIL_URL and I'm using Mailgun. When I try sending an email within terminal, it sends as expected. I have tried using the process provided here: https://themeteorchef.com/snippets/sign-up-with-email-verification/ where the method is server-side and then I use Meteor.call to call that method but that isn't sending the verification email. I have also tried implementing Accounts.onCreateUser() and calling Accounts.sendVerificationEmail(user._id) from within but that is also not sending the email.

In my server code I have the following in the startup function: Accounts.config({sendVerificationEmail: true, forbidClientAccountCreation: false}); I've also noticed that when I add in any kind of email verification code server-side, createUser fails and tells me the username is not defined but works 100% as expected without any email verification.

Here are some links to various sources I have been trying to use in order to get this working: verify email using accounts.ui package

https://themeteorchef.com/snippets/sign-up-with-email-verification/

Meteor 1.3 verify email when creating user

I've also been using the Meteor docs but I can't seem to get it working. I also have installed related packages (email, accounts, accounts-ui). Any help is appreciated!

Community
  • 1
  • 1
Hippity Hoopla
  • 68
  • 1
  • 10
  • Are you calling "Accounts.sendVerificationEmail(user._id)" from client side ? – Pankaj Jatav Oct 05 '16 at 07:40
  • @PankajJatav No, I set it up as shown in this link: https://themeteorchef.com/snippets/sign-up-with-email-verification/ because in the meteor docs `Accounts.sendVerificationEmail()` is a server-side function. I use `Meteor.call` to then call the server side method. – Hippity Hoopla Oct 05 '16 at 14:46
  • Are you getting any error on server console ? – Pankaj Jatav Oct 05 '16 at 14:48
  • @PankajJatav Yes I was. I actually just got it working. The issue was with the domain I was using on mailgun. I was using the sandbox domain but I did not have the address I was trying to send to as an authorized recipient. I must not have read through the server console carefully enough because after reading it more carefully I found the error message. Thank you! – Hippity Hoopla Oct 05 '16 at 15:21

1 Answers1

0

Thank you to @PankajJatav for asking me to read through the server console more carefully! The problem for me was that I am using mailgun as my smtp service. I was using the default sandbox domain when trying to implement my email verification system but the sandbox domain is only for testing purposes. In order to actually get emails sent, I had to go to mailgun and add in the recipients as an authorized recipient. If you set up mailgun with your own domain right from the start, this shouldn't be an issue.

Once again, thank you to @PankajJatav

Hippity Hoopla
  • 68
  • 1
  • 10