I have problem in my heroku app, I am trying to send email using my Godaddy email account, here is my settings in the environment/production.rb:
config.active_support.deprecation = :notify
config.action_mailer.default_url_options = { :host => 'coursebuilder2.heroku.com' }
config.action_mailer.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "smtpout.secureserver.net",
:port => 25,
:user_name => "myemail#domain.com",
:password => "password",
:authentication => :login
}
config.action_mailer.raise_delivery_errors = true
but, here is what I get:
Rendered instructors/mailer/confirmation_instructions.html.erb (1.1ms)
Completed 500 Internal Server Error in 666ms
SocketError (getaddrinfo: Name or service not known):
cache: [POST /instructors] invalidate, pass
So, what's I am missing here ?
EDIT
I have fixed the settings above, but, now, I have a timeout error below:
2012-03-04T04:44:20+00:00 app[web.1]: Rendered instructors/mailer/confirmation_instructions.html.erb (0.4ms)
2012-03-04T04:44:50+00:00 heroku[router]: Error H12 (Request timeout) -> POST coursebuilder2.herokuapp.com/instructors dyno=web.1 queue= wait= service=30000ms status=503 bytes=0
2012-03-04T04:45:20+00:00 app[web.1]: Completed 500 Internal Server Error in 60414ms
2012-03-04T04:45:20+00:00 app[web.1]:
2012-03-04T04:45:20+00:00 app[web.1]:
2012-03-04T04:45:20+00:00 app[web.1]: Timeout::Error (Timeout::Error):
2012-03-04T04:45:20+00:00 app[web.1]:
2012-03-04T04:45:20+00:00 app[web.1]:
2012-03-04T04:45:20+00:00 app[web.1]: cache: [POST /instructors] invalidate, pass
Any one can advice ?
That looks like you're using the wrong connection details to GoDaddy - to be honest, I'd be inclined to use the SendGrid free addon which is widely used and documented.
Related
I have been attempting to set up my rails application on heroku with automated mailings using ActionMailer. My setup for the mail initialization is as follows: Note that the domain and usernames are dummies.
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "domain.edu",
:user_name => "name#wesleyan.edu",
:password => ENV['EMAIL_PASS'],
:authentication => "plain",
:enable_starttls_auto => true
}
The odd thing is, when I try to send mail with one account, I get no issues, then when I try with another, I get the error. I never went through any authentication process with either. Both reports are as follows:
Success:
2013-06-12T00:59:34.801877+00:00 app[web.1]: Sent mail to recipient#domainn.edu (2464ms)
2013-06-12T00:59:34.804391+00:00 app[web.1]: Redirected to http://test.herokuapp.com/
2013-06-12T00:59:34.806552+00:00 app[web.1]: Completed 302 Found in 3394ms (ActiveRecord: 289.6ms)
Failure:
2013-06-12T01:29:25.124493+00:00 app[web.1]: Rendered agreement_mailer/welcome_email.html.erb (23.7ms)
2013-06-12T01:29:26.079394+00:00 app[web.1]: app/controllers/agreements_controller.rb:106:in `block in create'
2013-06-12T01:29:26.079394+00:00 app[web.1]: ):
2013-06-12T01:29:26.078426+00:00 app[web.1]: Sent mail to madelman#wesleyan.edu (929ms)
2013-06-12T01:29:26.078426+00:00 app[web.1]: Completed 500 Internal Server Error in 1137ms
2013-06-12T01:29:26.079394+00:00 app[web.1]:
2013-06-12T01:29:26.079394+00:00 app[web.1]: Net::SMTPAuthenticationError (535-5.7.8 Username and Password not accepted. Learn more at
Any thoughts about why I would get this discrepancy? Thanks so much.
Apparently the issue was that the second email address wasn't a real address at all, but an alias, so I could never get to the real password. I contacted my administrator, and they are fixing the problem.
I have my own domain name hosted on Google Apps.
My email sending works in development mode on my laptop.
In production on Heroku (cedar stack) I get this error:
Net::SMTPAuthenticationError (535-5.7.8 Username and Password not accepted. Learn more at app/controllers/applicants_controller.rb:16:in `create'):
Here is my production.rb file:
config.action_mailer.default_url_options = { :host => 'mydomain.com' }
# ActionMailer Config
# Setup for production - deliveries, no errors raised
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: "mydomain.com",
authentication: "plain",
enable_starttls_auto: true,
user_name: "info#mydomain.com",
password: "mypassword"
}
Here is the create action in the contacts_controller:
def create
#contact = Contact.new(params[:contact])
respond_to do |format|
if #contact.save
ContactMailer.new_contact_notice(#contact).deliver
format.html { redirect_to(:root, :notice => 'Thanks, Your information was successfully sent.') }
else
format.html { render :action => "show" }
end
end
end
Here is the full section of Heroku's logs indicating the error:
2013-05-07T05:01:54.773576+00:00 app[web.1]: Started POST "/applicants" for 108.208.197.181 at 2013-05-07 05:01:54 +0000
2013-05-07T05:01:55.132454+00:00 app[web.1]: app/controllers/applicants_controller.rb:18:in `block in create'
2013-05-07T05:01:55.130426+00:00 app[web.1]:
2013-05-07T05:01:55.132454+00:00 app[web.1]:
2013-05-07T05:01:55.130426+00:00 app[web.1]: Sent mail to name#gmail.com (185ms)
2013-05-07T05:01:55.132454+00:00 app[web.1]:
2013-05-07T05:01:55.132454+00:00 app[web.1]: Net::SMTPAuthenticationError (535-5.7.8 Username and Password not accepted. Learn more at
2013-05-07T05:01:55.132454+00:00 app[web.1]: app/controllers/applicants_controller.rb:16:in `create'
2013-05-07T05:01:55.132454+00:00 app[web.1]: ):
2013-05-07T05:01:55.132454+00:00 app[web.1]:
I've tried some of the things I have read about this error, such as loggin into the gmail account first. I don't see anywhere in settings where it asks you if you are trying to login so I can confirm that.
Any other ideas?
It took my three days but I found the answer. I had checked and rechecked the mail settings everywhere except in the setup_mail.rb in config/initializers. That was it. Even though I had all the mail settings correct in my production.rb, application.yml and mailer files. I only had the username "name" instead of the full email address "name#domain.com".
I am developing a Ruby on Rails 3.2 application on Heroku. I added the sendgrid addon with
heroku addons:add sendgrid:starter
and then restarted with
heroku restart
However, if I try to send a password email in my application (I am using the devise login gem), I get this in the logs
2013-01-24T17:35:37+00:00 app[web.1]: Started POST "/users/password" for xxx.xxx.xxx.xx at 2013-01-24 17:35:37 +0000
2013-01-24T17:35:37+00:00 app[web.1]: Processing by Devise::PasswordsController#create as HTML
2013-01-24T17:35:37+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=", "user"=>{"email"=>"xxxxxxxx.xxxxxx#gmail.com"}, "commit"=>"Send me reset password instructions"}
2013-01-24T17:35:38+00:00 app[web.1]: Rendered vendor/bundle/ruby/1.9.1/gems/devise-2.2.2/app/views/devise/mailer/reset_password_instructions.html.erb (1.0ms)
2013-01-24T17:35:41+00:00 app[web.1]:
2013-01-24T17:35:41+00:00 app[web.1]: Sent mail to xxx.xxxxx#gmail.com (3080ms)
2013-01-24T17:35:41+00:00 app[web.1]: Completed 500 Internal Server Error in 3311ms
2013-01-24T17:35:41+00:00 app[web.1]:
2013-01-24T17:35:41+00:00 app[web.1]: Errno::ECONNREFUSED (Connection refused - connect(2)):
2013-01-24T17:35:41+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `initialize'
2013-01-24T17:35:41+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `open'
2013-01-24T17:35:41+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `tcp_socket'
2013-01-24T17:35:41+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/net/smtp.rb:555:in `block in do_start'
2013-01-24T17:35:41+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/timeout.rb:58:in `timeout'
2013-01-24T17:35:41+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/timeout.rb:89:in `timeout'
2013-01-24T17:35:41+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/net/smtp.rb:555:in `do_start'
2013-01-24T17:35:41+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/net/smtp.rb:525:in `start'
2013-01-24T17:35:41+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/network/delivery_methods/smtp.rb:144:in `deliver!'
2013-01-24T17:35:41+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/message.rb:2034:in `do_delivery'
You need to configure ActiveMailer with something like
ActionMailer::Base.smtp_settings = {
:address => "smtp.sendgrid.net",
:port => "25",
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => ENV['SENDGRID_DOMAIN']
}
and make sure your application has the SENGRID configuration variables in the environment - you can check with heroku config.
I have a user model based off of Michael Hartl's Ruby on Rails Tutorial (Second Edition) It works fine in practice locally hosted from a linux box but when I deploy to Heroku there is a problem with IE ans Safari. (Chrome and firefox work great.) I use the cookie to set the value current_user which I call constantly on the site.
here is my sessions_helper.rb
module SessionsHelper
def sign_in(user)
cookies.permanent[:remember_token] = user.remember_token
self.current_user = user
end
def signed_in?
!current_user.nil?
end
def current_user=(user)
#current_user = user
end
def current_user
#current_user ||= User.find_by_remember_token(cookies[:remember_token])
end
def current_user?(user)
user == current_user
end
def signed_in_user
unless signed_in?
store_location
redirect_to signin_url, notice: "Please sign in."
end
end
def sign_out
self.current_user = nil
cookies.delete(:remember_token)
end
def redirect_back_or(default)
redirect_to(session[:return_to] || default)
session.delete(:return_to)
end
def store_location
session[:return_to] = request.url
end
end
My sessions controller is as follows:
class SessionsController < ApplicationController
def new
end
def create
user = User.find_by_email(params[:session][:email].downcase)
if user && user.authenticate(params[:session][:password])
sign_in user
redirect_back_or user
else
flash.now[:error] = 'Invalid email/password combination'
render 'new'
end
end
def destroy
sign_out
redirect_to root_url
end
end
Again when I create a user/log in it looses my cookie only in IE8> and Safari.
Here is the log I'm getting.
2012-11-06T19:28:08+00:00 app[web.1]: Started POST "/sessions" for XXX.XXX.XXX.XXX at 2012-11-06 19:28:08 +0000
2012-11-06T19:28:08+00:00 app[web.1]: Processing by SessionsController#create as HTML
2012-11-06T19:28:08+00:00 app[web.1]: Parameters: {"utf8"=>"â", "authenticity_token"=>"Eh3xta4VHlHgBVEKiLn3CRKgWb5xFbAx91eNJlYFySs=", "session"=>{"email"=>"A#User.com", "password"=>"[FILTERED]"}, "commit"=>"Sign in"}
2012-11-06T19:28:08+00:00 app[web.1]: WARNING: Can't verify CSRF token authenticity
2012-11-06T19:28:08+00:00 app[web.1]: Redirected to https://some-app_1234.herokuapp.com/users/1
2012-11-06T19:28:08+00:00 app[web.1]: Completed 302 Found in 391ms (ActiveRecord: 16.1ms)
2012-11-06T19:28:08+00:00 heroku[router]: POST some-app-1234.herokuapp.com/sessions dyno=web.1 queue=0 wait=0ms service=508ms status=302 bytes=114
2012-11-06T19:28:09+00:00 app[web.1]:
2012-11-06T19:28:09+00:00 app[web.1]:
2012-11-06T19:28:09+00:00 app[web.1]: Started GET "/users/1" for XXX.XXX.XXX.XXX at 2012-11-06 19:28:09 +0000
2012-11-06T19:28:09+00:00 app[web.1]: Processing by UsersController#show as HTML
2012-11-06T19:28:09+00:00 app[web.1]: Parameters: {"id"=>"1"}
2012-11-06T19:28:09+00:00 app[web.1]: Rendered shared/_stats.html.erb (205.2ms)
2012-11-06T19:28:09+00:00 app[web.1]: Rendered microposts/_micropost.html.erb (15.0ms)
2012-11-06T19:28:09+00:00 app[web.1]: Rendered users/show.html.erb within layouts/application (247.6ms)
2012-11-06T19:28:09+00:00 app[web.1]: Rendered layouts/_shim.html.erb (0.0ms)
2012-11-06T19:28:09+00:00 app[web.1]: Rendered layouts/_header.html.erb (1.2ms)
2012-11-06T19:28:09+00:00 app[web.1]: Rendered layouts/_footer.html.erb (0.3ms)
2012-11-06T19:28:09+00:00 app[web.1]: Completed 200 OK in 256ms (Views: 52.5ms | ActiveRecord: 202.4ms)
2012-11-06T19:28:09+00:00 heroku[router]: GET some-app-1234.herokuapp.com/users/1 dyno=web.1 queue=0 wait=0ms service=544ms status=200 bytes=2394
The problem was I was dns forwarding using an iframe! This made the cookie a third party cookie. If I forward to the actual heroku address it solves the problem. Hope my stupidity helps someone else.
Alright so I have 2 models with uploads, an Auction and a User.
I'm using Paperclip, Rails 3.2, and Ruby 1.9.3. The platform is Heroku Cedar.
Here's the credential details:
S3_BUCKET = ENV['S3_BUCKET'] || "..."
S3_ID = ENV['S3_ID'] || "AKIAJXD4ZBGYF24..."
S3_KEY = ENV['S3_KEY'] || "fJ7eNKQtFGf1s..."
S3_UPLOAD_OPTIONS = {
storage: :s3,
bucket: S3_BUCKET,
s3_credentials: {
access_key_id: S3_ID,
secret_access_key: S3_KEY
}
}
Auction file uploads are working fine. Everything is as expected.
User uploads do not work, and have zero errors as shown below:
2012-05-17T20:39:16+00:00 app[web.1]:
2012-05-17T20:39:16+00:00 app[web.1]: DalliError: No server available
2012-05-17T20:39:16+00:00 app[web.1]:
2012-05-17T20:39:16+00:00 app[web.1]:
2012-05-17T20:39:16+00:00 app[web.1]: Started PUT "/users" for 208.117.193.99 at 2012-05-17 20:39:16 +0000
2012-05-17T20:39:18+00:00 heroku[router]: POST cfac-staging.herokuapp.com/users dyno=web.1 queue=0 wait=0ms service=2006ms status=302 bytes=113
2012-05-17T20:39:18+00:00 app[web.1]: cache: [POST /users] invalidate, pass
2012-05-17T20:39:18+00:00 app[web.1]:
2012-05-17T20:39:18+00:00 app[web.1]: DalliError: No server available
2012-05-17T20:39:18+00:00 app[web.1]:
2012-05-17T20:39:18+00:00 app[web.1]:
2012-05-17T20:39:18+00:00 app[web.1]: Started GET "/auctions/new" for 208.117.193.99 at 2012-05-17 20:39:18 +0000
2012-05-17T20:39:19+00:00 heroku[router]: GET cfac-staging.herokuapp.com/auctions/new dyno=web.1 queue=0 wait=0ms service=1154ms status=304 bytes=0
2012-05-17T20:39:19+00:00 app[web.1]: cache: [GET /auctions/new] miss
2012-05-17T20:39:19+00:00 app[web.1]: DalliError: No server available
2012-05-17T20:39:19+00:00 app[web.1]: cache: [GET /assets/blank-avatar-9a23306b75ac790741fc7e05300183b6.png] miss
2012-05-17T20:39:19+00:00 heroku[router]: GET cfac-staging.herokuapp.com/assets/blank-avatar-9a23306b75ac790741fc7e05300183b6.png dyno=web.1 queue=0 wait=0ms service=3ms status=200 bytes=2212
2012-05-17T20:39:19+00:00 app[web.1]: DalliError: No server available
2012-05-17T20:39:19+00:00 app[web.1]: cache: [GET /assets/get-started-button-f7e9baac88feb2effa461b697df8bcd9.png] miss
2012-05-17T20:39:19+00:00 heroku[router]: GET cfac-staging.herokuapp.com/assets/get-started-button-f7e9baac88feb2effa461b697df8bcd9.png dyno=web.1 queue=0 wait=0ms service=3ms status=200 bytes=2451
I have no idea why the DalliError bit is happening either, so...
Here are the User and Auction models:
class User < ActiveRecord::Base
has_attached_file :logo, { styles: { medium: "x125", thumb: "x40" } }.merge!(S3_UPLOAD_OPTIONS)
end
class Auction < ActiveRecord::Base
has_attached_file :image, { styles: { medium: "122x122#", thumb: "80x80#" }, default_url: ActionController::Base.helpers.image_path('blank-avatar.png') }.merge!(S3_UPLOAD_OPTIONS)
end