Sending emails with Devise - ruby-on-rails

I've set up confirmable with devise and am sending emails in development and test mode. However, I couldn't find any good tutorials for triggering emails for other situations using devise.
For example if a user makes a reservation on my app- how can I email a confirmation to them?

ActionMailer Basics would be a good place to start.

Related

Not receiving email verification link through heroku sendgrid add-on to new sign up gmail account

In my heroku logs the email confirmation link has been sent successfully but didn't received any mail to gmail accountheroku logs
Some code and/or what you configured would help a lot, just the logs does not really give any clue on what's going on.
Make sure you have configured everything correctly for devise (here are some questions already asked that might help you):
Rails devise not sending an email confirmation in development
Rails: Devise not sending confirmation email in production (Heroku)
And I also advise you to not use a gmail account to send emails as they are usually flagged as spam, or sometimes don't even go through at all.

Rails ActiveJob/Sidekiq sending emails inconsistently; sometimes sends, sometimes doesn't

I have a Rails 4.2 app using ActiveJob/ActionMailer and Sidekiq/Redis with Devise for authentication. I require email confirmations when signing up, which is handled by Devise. I'm running into an issue when users sign up, but the confirmation email sometimes doesn't get sent.
The logs show that the confirmation email is enqueued by ActiveJob, and sometimes it gets processed, sometimes it does not. When the confirmation email isn't processed, and the user requests for it again, the new confirmation email goes through.
Any ideas as to why this is happening?
Also, I am not iterating over any users, I'm using the standard Devise sign up process. So this doesn't apply.
I think I know the reason for the inconsistent emails. I had two separate staging environments using the same redis server instance. For the sake of explanation I will call them staging1 and staging2.
I believe what was happening was that when a user (ID=1) was being created on staging2, sometimes staging1 would be processing the email for its own user (ID=1), and so the user from staging2 would not get the email, but rather the email was being sent to the user from staging1.
To resolve this issue, one of two things can be done.
Use a separate redis server for each environment.
Use redis namespaces for each environment.

Using Spree's Devise for confirmation email, and connect via facebook and google

I have a spree app. Along with it comes the Devise authentication. I want to set-up devise :confirmable, and subsequently connect via google and facebook. I tried to set up the file config/initializers/devise.rb for devise :confirmable but changing any config in it doesn't seem to affect my rails app on my local development server. Does this config file provide very limited functionality? Do I need to create a Spree.user_class as specified in this guide?
I am able to send mails and see them using the mailcatcher gem. But no mail is being sent when I am creating a new user.
Please advice.
EDIT
I have created a custom Spree.user_class following the guide and added :confirmable to it but still I am facing the same problem.
As per Ryan's suggestion in this mailinglist post, the best way to implement Devise :confirmable is to fork spree_auth_devise and make the changes. Sadly it appears no one has done this as yet, or atleast I couldn't find it on github.
Extending the above for Login via google or facebook, etc, is possible but a better way would be to use spree_social. Keep in mind that spree_social is still in beta.

Preventing Devise/ActionMailer from sending confirmation email

I am using Devise with ActionMailer. I would like to allow users to create an account without email if they use Twitter. But I still need devise:confirmable if they choose to add email later on.
However, Devise automatically send confirmation email when an user create a new account, even if user does not supply it. Therefore, I got error when deploy my Rails app to Heroku:
ArgumentError (At least one recipient (To, Cc or Bcc) is required to send a message):
How can I prevent Devise or ActionMailer from sending confirmation email when there's no email address?
Thank you.
Devise has a skip_confirmation! method that should allow you to accomplish this, check out the confirmable.rb

Sending a signup confirmation email with having to confirm using Devise

I'm using devise to handle user authentication with my rails app. I'd like to allow my users to sign up and be instantly logged in and receive a confirmation email.
Devise has the Confirmable module which sends out an email but requires the user to open up their mail application, find the email and click a link which then leads them to the site again.
I'd like to just email the user a confirmation that they signed up and that's it.
Is there a way for devise to do this or do I need to resolve to handling ActionMailer myself (if so, is there a quick and non-complex example)?
Many thanks!
-Tony
I'm pretty new to devise and rails, but I have set it all up in may app (rails 2.3.5) and got it working in it's basic functionality. I'm guessing some advanced devise users may teach you a trick to handle this in devise, but I'm going to say that you could easily handle this in a controller action, using some plain rails ActionMailer coding...
Here's a link that I ran across that will show you the basic approach. At the end of the tutorial, they gather the email parts from a simple web page, but you should easily see how to use the class to do it in code.
http://www.tutorialspoint.com/ruby-on-rails/rails-send-email.htm
check out #user.skip_confirmation!
it sets a user as confirmed but doesn't generate the confirmation_token or send the email.

Resources