简体   繁体   中英

Mercury Mail Server Authentication with Rails

I'm running a Mercury SMTP server (that came with my XAMPP stack) and I'm trying to get my Rails application to use it in development mode. So I added the following to my development.rb file

ActionMailer::Base.delivery_method = :smtp
  ActionMailer::Base.perform_deliveries = true
  ActionMailer::Base.raise_delivery_errors = true
  ActionMailer::Base.smtp_settings = {
  :address              => "localhost",
  :port                 => 25,
  :domain => 'localhost',
  :user_name=>'newuser@localhost',
  :password=>'wampp',
  :authentication => :plain,
  :enable_starttls_auto => true
}

When I set the authentication parameter to plain I get:

504 Unknown or unsupported authentication method.

So I checked out the ActionMailer API and saw that there were two more options login and cram_md5. If I use either of those I get

501 Authentication failed - bad user or password.

That username/password combo is the default though so its definitely valid. I've tried newuser with and without the @localhost and even created a new Mercury user account (which I have other reasons not to do) and tried it with and without @localhost and I always get the 501.

If possible I want to make this work on the Rails side rather than enabling plain authentication in Mercury, but I guess I'll settle for that solution if someone knows how to make that work. Worst case scenario I'll take a recommendation for a different SMTP server to use with Rails development.

Thanks!

Configure Mercury SMTP server not to require authentication. Maybe it is the default?

For your Rails smtp settings, use:

ActionMailer::Base.smtp_settings = {
  :address              => "localhost",
  :port                 => 25
}

This is the configuration I use with Apache James server. When no authentication is required, you must omit most of the params.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM