Robbie Done
Robbie Done

Reputation: 1157

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.

Upvotes: 2

Views: 247

Answers (2)

Robbie Done
Robbie Done

Reputation: 1157

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

Upvotes: 1

tw airball
tw airball

Reputation: 1359

you can enable starttls like this:

config.action_mailer.smtp_settings = {
   ....
   :enable_starttls_auto => true}

Upvotes: 0

Related Questions