Search code examples
ruby-on-railsruby-on-rails-3emailproduction-environment

Sending email through Rails 3 with gmail problems


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.


Solution

  • 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...