Running into SMTP error when trying to send email in RoR app

前端 未结 4 936
死守一世寂寞
死守一世寂寞 2020-12-05 20:47

I\'ve been desperately trying to send an email using the Action Mailer class in RoR, and even though the terminal shows that a message is being sent, it keeps returning with

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-05 21:40

    I resolved my issue by doing this.

    config.action_mailer.default :charset => "utf-8"
    config.action_mailer.perform_deliveries = true
    config.action_mailer.raise_delivery_errors = true
    config.action_mailer.delivery_method = :smtp
    config.action_mailer.smtp_settings = {
        address: 'smtp.gmail.com',
        port: 587,
        domain: 'mysite.com',
        user_name: myemail@gmail.com,
        password: mypassword,
        authentication: 'plain',
        enable_starttls_auto: true
    }
    

    As google will try to block your sign-in if you have turned off access for less secure apps in your accounts settings. Therefore, follow this link and "Turn on" access for less secure apps.

提交回复
热议问题