Help: Why is mailer.rb in app/models
Added by kuolai shu over 10 years ago
I got errors trying to get Redmine to send emails. The error looks like this: "Error: Email delivery error: No connection could be made because the target machine actively refused it. - connect(2)".
I went to Redmine guide and Rails guide action mailer basics. And got myself a question:
Why is mailer.rb in redmine/app/models while Rails Guide suggests mailer.rb in app/mailers?
$ bin/rails generate mailer UserMailer create app/mailers/user_mailer.rb invoke erb create app/views/user_mailer invoke test_unit create test/mailers/user_mailer_test.rb
Is there any document in Redmine about Mailer?
Thanks.
Replies (4)
RE: Help: Why is mailer.rb in app/models
-
Added by kuolai shu over 10 years ago
I found the answer that the home of action Mailer (hence mailer.rb) has changed as Rails version changes.
In Rails Guides 2.3.11, action mailer resides in app/models.
While in Current Rails Guides 4.1.7, action mailer has its own home at app/mailers.
I still have problems sending emails in Redmine, eliminating the conflict in redmine guides and rails guides gives me a comfort to proceed.
RE: Help: Why is mailer.rb in app/models
-
Added by Martin Denizet (redmine.org team member) over 10 years ago
Hello Kuolai,
The error message seems to point to a bad configuration (such as wrong host/port or firewall blocking).I suggest you:
- Double check your
configuration.yml
, take note that the configuration is per environment - Double check which environment your Redmine instance is using. (In Administration/information)
In case it could be a firewall configuration problem, you could test making the connection from your Redmine server to the SMTP server using telnet
.
If that doesn't allow you to discover a faulty configuration, you could also try a tcpdump
to make sure of what connection is attempted (and refused) by Redmine to the SMTP server.
Cheers,
RE: Help: Why is mailer.rb in app/models
-
Added by kuolai shu over 10 years ago
Hi Martin,
Thanks for offering a help. Even I did not state clear error messages, you have pointed me to a few possible directions: configuration, environment, and SMTP server.
I checked and they seemed ok to me. And I am using gmail smtp server with my own gmail account under development mode.
$ rails s => Booting WEBrick => Rails 3.2.19 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server Connecting to database specified by database.yml Creating scope :sorted. Overwriting existing method User.sorted. Creating scope :sorted. Overwriting existing method Group.sorted. [2014-11-14 11:36:45] INFO WEBrick 1.3.1 [2014-11-14 11:36:45] INFO ruby 1.9.3 (2014-10-27) [i386-mingw32] [2014-11-14 11:36:45] INFO WEBrick::HTTPServer#start: pid=5240 port=3000
Redmine web screen: Administration/Settings/Email notifications/Send a test email/ got an error message:
An error occurred while sending mail (535-5.7.8 Username and Password not accepted. Learn more at )
config/configuration.yml
development: email_delivery: delivery_method: :smtp smtp_settings: enable_starttls_auto: true address: "smtp.gmail.com" port: '587' domain: "smtp.gmail.com" authentication: :plain user_name: "me@gmail" password: "myPWD"
localhost:3000/admin/info
Redmine 2.5.2.devel Default administrator account changed Exclamation Attachments directory writable True Plugin assets directory writable True RMagick available (optional) True ImageMagick convert available (optional) True Environment: Redmine version 2.5.2.devel Ruby version 1.9.3-p550 (2014-10-27) [i386-mingw32] Rails version 3.2.19 Environment development Database adapter PostgreSQL SCM: ... Git 1.8.1 Filesystem Redmine plugins: clipboard_image_paste 1.8 latest_issues 0.0.1
Any clue?
Thanks.
RE: Help: Why is mailer.rb in app/models
-
Added by kuolai shu over 10 years ago
Never mind. I found the solution and it is a stupid one.
In config/configuration.yml
...
user_name: "me@gmail"
...
should be
user_name: "me@gmail。com"
My bad.
Thanks for your support and it gets me going.