Rails 3 devise i need help with confermation - ruby-on-rails-3

I have watched the railscast on devise for some reason he pulled out the confrmation e-mail part so i have no idea how it works i have it up and running but what i need to know is dose it send an e-mail in development or not?
is there a way to force it to send the mail just to test it or can you enplane how to do it in the console!

it doesn't send email on development environment. You need to edit your config/environments/development.rb and add :
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
Then look in your console running your server when it try to send an email you will see actually all what your need there (headers, title and body email)

Related

Default reset password email not sent via Appcelerator backend, nor emails with a template, only email configuration changes are sent

When I execute the following code,
Cloud.Users.requestResetPassword({
email: myUsersEmailAddress
}, function (e) {
if (e.success) {
Ti.API.info('Success: Reset Request Sent ' + JSON.stringify(e));
} else {
Ti.API.error('Error:\n' + ((e.error && e.message) || JSON.stringify(e)));
}
});
I should receive an email to reset my password, as seen in the documentation:
GET users/request_reset_password.json Sends an email to a user
containing a link to recover a lost password. You can use the default
email template provided by ACS, or specify a custom email template
that you have created. When using a custom email template, the email
must contain a properly formatted URL, as explained in the template
method parameter documentation below.
When the alert pops up, I can see that there was a match and that an email should have been sent.
However, I do not receive an email, nor do I see anything in the logs of my email backend (which does receive an email when I adapt my email configuration on the appc backend, thus my email is correctly configured)
I don't have any email templates configured, but according to the documentation it should use appc's default reset password email.
Does anyone has an idea about what I am doing wrong, or does this indicate an issue with appc's documentation or backend?
UPDATE: I have another function which sends email using a self-defined email template. When I invoke this function, i receive the following event(between the {}):
[INFO] : Deactivation email sent. {"success":true,"error":false,"meta":{"status":"ok","code":200,"method_name":"emailFromTemplate"}}
However, nothing is seen on our smtp backend. The only things we do see (and which we receive in our mailbox) are the emails which are sent when you adapt your email configuration settings in Appcelerator's backend, eg.
Subject: Appcelerator Cloud Services SMTP Test
Appcelerator Logo Hi Peter,
Your SMTP settings have been updated successfully!
Onward,
The Appcelerator Platform Team
Thanks,
David
It turned out to be a configuration issue, which could only be discovered by doing some curl calls against the api. So a good advice, test your config with curl too, and don't rely on the emails which are sent after you made a configuration change!

How to do confirmation with devise authentication in Ruby on Rails

I am using devise in my application for authentication. When I try to register, I get the following error:
Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
I am using :comfirmable and had uncommented t.confirmable in the migration
In order to use confirmable module you need to configure ActionMailer that is used by devise for sending confirmation emails. First step for solving your problem is setting up mailer host in you environment.rb or in the corresponding file for a particular environment like that:
config.action_mailer.default_url_options = { :host => “example.com” }
For further steps have a look at this rails guide and answers to this question.

In Heroku Sendgrid, is there a way to see how many emails have my app sent today?

I have a Rails 3.0.5 app hosted in heroku. To send emails I use Sendgrid. Im in the free plan but it has a 200 email daily limit. I want to know if there is a way in Rails or in this addon "Sendgrid", to see how many emails have been sent today.
Use the Heroku Sendgrid Stats plugin
Look at the SendGrid API..
REST GET request to:
https://sendgrid.com/apiv2/reseller.account.json?api_user=username&api_key=secureSecret&task=overview&user=customer#example.com
Source: AccountOverview API
Will return something like:
<result>
<overview>
<reputation>100</reputation>
<requests>50000</requests>
<package>Silver Package</package>
<credits_allowed>50000</credits_allowed>
<credits_used>100000</credits_used>
<credits_remain>0</credits_remain>
<credits_overage>50000</credits_overage>
<billing_start_date>2010-08-30</billing_start_date>
<billing_end_date>2010-09-29</billing_end_date>
<billing_process_date>2010-09-30</billing_process_date>
</overview>
</result>
(Edited due to linking the wrong API page).
The easiest way I found was to click on the SendGrid add-on in your app on Heroku. The main screen will tell you how many emails were sent today. If you click on the "Email Activity" tab you can see all of the emails that were sent.

Setting Up Devise & Sendgrid on Heroku

My site is hosted on Heroku and I installed the Sendgrid Add-On as it looked almost too good to be true - but so far none of the email functionality is working. I have read the documentation and it clearly says just add-the add on - is more configuration required to get Devise working?
When I select 'send me new password' I get a 404 page which makes me think there is more to this. Like how does Sendgrid know/where to use the pre-installed Devise templates?
Thx.
I just set up Devise and SendGrid this morning and have no problems. I'm going to resume the steps I took.
First, install Devise and SendGrid. Congratulations, you've already done that ;)
Then, for production, add this to your files:
config/initializers/devise.rb :
config.mailer_sender = "mail-to-send#from.com"
Set up Rails ActionMailer to use SendGrid
config/environments/production.rb
config.action_mailer.default_url_options = { :host => 'your.websitedomain.com' }
ActionMailer::Base.smtp_settings = {
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:address => "smtp.sendgrid.net",
:port => 587,
:enable_starttls_auto => true,
:authentication => :plain,
:domain => "yourdomain.com"
}
And everything's working great with that. Sign up confirmations, password recovery...
Also, you should use Logging Expanded (it's Free!) and check your logs with heroku logs --tail (for real time).
If you still get errors, post your logs.
Have a good day !
I've used the sendgrid Add-On and it really should just work. Like you said, even the docs say so:
Rails apps using ActionMailer will just work, no setup is needed after the add-on is installed.
So, this makes me think something else is going on. Have you tried using the heroku logs command to see if your application is logging any errors?

Setting up a Gmail Account to work with ActionMailer in Rails 3

I have a contact page form that is setup to send an email to a Gmail account. Only problem is it won't send. I believe I have narrowed the error down to my settings inside of the initializers directory.
These are my current settings for trying to setup a standard gmail account to send mail:
Could it be that my domain setting is wrong or should I be typing in myemail#gmail.com for :user_name? This is the first time I have used ActionMailer so I don't really know what I am doing. Can somebody please help me out!? Thanks!
If you are using the development environment, change the development.rb to raise delivery errors, with
config.action_mailer.raise_delivery_errors = true
Also, the problem might be that :user_name should be the entire email address (myemail#gmail.com), that's how Gmail authenticates users.
domain does not necessarily have to be "gmail.com". You can put your own domain here is you wish.
You also need to specify :from. I found that if you deliver your email with .deliver you do not get an exception for the errors. Try .deliver! instead. With .deliver! you get details about what is wrong.