I'm not an expert in Ruby and Redmine, but I'm trying to configure email notifications in redmine.
Redmine version 3.4
ruby 2.3.3p222
Phusion Passenger 5.1.7
In configuration.yml I have
production:
email_delivery:
delivery_method: :smtp
smtp_settings:
address: "xxxx.pl"
port: 587
authentication: :plain
domain: 'redmine.xxx.pl'
user_name: '.....#redmine.xxx.pl'
password: '......'
But I get this error:
Error ID: 54731089
Error details saved to: /tmp/passenger-error-WqNBmN.html
Message from application: undefined method `address=' for ActionMailer::Base:Class (NoMethodError)
I search little bit and figure out, that I have missing methods in application.rb file.
So in Redmine config/application.rb I add something like that:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "xxx.pl",
port: 587,
user_name: 'powiadomienia#redmine.xxx.pl',
password: '.....',
authentication: :plain
}
but still have the same error. Unfortunately I can't find any examples in Redmine configuration.
Can anyone help me?
Make sure your configuration.yml is properly indented (use 2 spaces per level of indentation):
production:
email_delivery:
delivery_method: :smtp
smtp_settings:
address: 'example.org'
port: 587
The smtp settings (address, port etc) need to be keys in the smtp_settings hash. From the error you get I'd say they are keys on the same level as smtp_settings, which is wrong.
Related
I add to configuration.yml email settings. But notifications not come to email. I try to send test mail from settings page, but also I doesn`t recieve any emails.
configuration.yml:
default:
email_delivery:
smtp_settings:
address: mail.mysite.ru
port: 587
authentication: :login
user_name: "redmine#mysite.ru"
password: "mypass"
Production.log (https://yadi.sk/d/31jli2yOiraHn1) doesn`t contains mail errors, redmine.error.log is empty.
I don't know if you're missing smtp settings for development/production environment. If so, try
default: &default
email_delivery:
smtp_settings:
# Your settings
development:
<<: *default
production:
<<: *default
# Override default settings if necessary
user_name: "redmine#othersite.ru"
password: "otherpass"
Since you're using port 587, I suppose your smtp server uses StartTLS to secure mail exchanges. So you have to add the following line in your smtp_settings:
enable_starttls_auto: true
And if the smtp server is using untrusted SSL certification, then add this line too:
openssl_verify_mode: 'none'
Try sending email again. If still not working, then try changing authentication: :login to authentication: :plain.
I have problem with sending emails from localhost.
it was working on linux and now I'm trying to run my app on mac and it doesn't work already.
I have an error:
ArgumentError in Devise::RegistrationsController#create
SMTP-AUTH requested but missing user name
in config/environments/development.rb:
#Action Mailer config
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_mailer.delivery_method = :smtp
# Send email in development mode.
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: "587",
domain: "mail.google.com",
authentication: "plain",
enable_starttls_auto: true,
user_name: ENV["GMAIL_USER_ID"],
password: ENV["GMAIL_PASSWORD"]
}
My env variables are good, I tried put my credential into code as well and it still doesn't work :/
I checked similiar topics but didn't found the solution.
What can I try?
I read:
I tried put my credential into code as well and it still doesn't work :/
But have you tried replacing your var env with your gmail id/password like this ?
#Action Mailer config
**********
user_name: "my_username",
password: "my_password"
}
Just to be sure.
Ok, solved.
credentials didn't work because I havn't restarted my server (stupid laziness)
my env vars didn't work because I've puted them into ~.profile but it work in ~.bash_profile, that was helpful (I use OS X Yosemite).
I am trying to send emails via action mailer. I have the same config for production and for development:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'ee.ex.my_domain.net',
port: 465,
domain: 'my_domain',
user_name: 'email#my_mail.com',
password: 'my_pass',
authentication: :ntlm,
enable_starttls_auto: true
}
config.action_mailer.default_url_options = { :host => "localhost:3000" }
The only difference between development and production config is the host. For production I use an existing url, on my local machine it works ok but when I try it on the server I got this error:
Net::SMTPSyntaxError (504 5.7.4 Unrecognized authentication type)
I have had this error before on my local machine but I changed the authentication to :ntml and it works fine.
UPDATE
tried in server console (code from ntlm gem github page)
require 'ntlm/smtp'
smtp = Net::SMTP.new('smtp.example.com')
smtp.start('localhost.localdomain', 'Domain\\User', 'Password', :ntlm) do |smtp|
smtp.send_mail(mail_body, from_addr, to_addr)
end
but have the same error
I've configured email on redmine according to the instructions in the redmine wiki, and it all works fine. Here are the contents of my config/configuration.yml file:
production:
delivery_method: :smtp
smtp_settings:
address: "smtp.sendgrid.net"
port: 587
authentication: :plain
domain: "heroku.com"
user_name: my_email#gmail.com
password: my_password
However I am trying to use environment variables in place of my_email#gmail.com and my_password like so:
production:
delivery_method: :smtp
smtp_settings:
address: "smtp.sendgrid.net"
port: 587
authentication: :plain
domain: "heroku.com"
user_name: <%= ENV['SENDGRID_USERNAME'] %>
password: <%= ENV['SENDGRID_PASSWORD'] %>
When I try to send a test email, with the environment variables in the config file, redmine give this error:
'An error occurred while sending mail (535 Authentication failed: Bad username / password )'.
So I guess the erb snippet is not being evaluated (I have double checked the values of the environment variables).
I've searched for a solution and come up empty, does anyone have any suggestions as to how I should configure email in redmine so that I don't expose my sendgrid credentials in the config file?
Alternatively if someone can tell me that it's not a security risk to use the credentials directly, without environment variables, that would also solve my problem.
I had answered this question 2 weeks ago, and it was deleted by someone else right away.
So I'm not sure if someone will delete this answer again to prevent other guys knowing how to solve this problem. Good luck!
I got the same issue and this article
Set up mailing in redmine on heroku solved my problem.
The idea is moving the settings from config/configuration.yml to config/environments/production.rb and using Ruby code to set it up. Since ENV['key'] is handled by erb, I guess configuration.yml is not handled that way. Maybe there is some security issue?
So in your case, you should add these codes to config/environments/production.rb as follows,
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'heroku.com'
}
ActionMailer::Base.delivery_method = :smtp
And remove codes from config/configuration.yml and make it looks like this,
default:
# Outgoing emails configuration (see examples above)
email_delivery:
delivery_method: :smtp
I am getting this error whilst trying to send emails through gmail -
Net::SMTPAuthenticationError (530 5.7.0 Must issue a STARTTLS command first. pw17sm4922458lab.5
):
app/controllers/contact_controller.rb:11:in `create'
I have tried loads of different things but to no avail, below is my settings from production.rb
# Change mail delvery to either :smtp, :sendmail, :file, :test
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: "bizmodev.com",
authentication: "plain",
enable_starttls_auto: true,
user_name: '******.*****#gmail.com',
password: '********'
}
# Specify what domain to use for mailer URLs
config.action_mailer.default_url_options = {host: "bizmo.co.uk"}
Any help on this matter would really be appreciated.
OK fixed it, basically I installed sendmail on my VPS and then restarted Apache and it now works -
Ubuntu Sendmail command line install
apt-get install sendmail
Hope this may help someone in the future...
you can enable starttls like this:
config.action_mailer.smtp_settings = {
....
:enable_starttls_auto => true}