Ruby on rails 如何配置我的服务器从Ruby on Rails发送电子邮件

Ruby on rails 如何配置我的服务器从Ruby on Rails发送电子邮件,ruby-on-rails,actionmailer,Ruby On Rails,Actionmailer,我正在使用Rails附带的服务器,我需要将其配置为向收件人发送电子邮件,例如juan@gmail.com及pepe@hotmail.com. 我是否需要使用我的Gmail帐户或安装本地SMTP服务。我是RubyonRails的新手 我正在使用邮件程序执行此操作 下面是我在互联网上看到的一个例子 ActionMailer::Base.smtp_settings = { :user_name => 'your_sendgrid_username', :password => 'y

我正在使用Rails附带的服务器,我需要将其配置为向收件人发送电子邮件,例如juan@gmail.com及pepe@hotmail.com.

我是否需要使用我的Gmail帐户或安装本地SMTP服务。我是RubyonRails的新手

我正在使用邮件程序执行此操作

下面是我在互联网上看到的一个例子

ActionMailer::Base.smtp_settings = {
  :user_name => 'your_sendgrid_username',
  :password => 'your_sendgrid_password',
  :domain => 'yourdomain.com',
  :address => 'smtp.sendgrid.net',
  :port => 587,
  :authentication => :plain,
  :enable_starttls_auto => true
} 

要从本地发送邮件,请在config/environments/devleopment.rb中输入以下代码

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address:              'smtp.gmail.com',
  port:                 587,
  domain:               'example.com',
  user_name:            '<your gmail username>',
  password:             '<and its password>',
  authentication:       'plain',
  enable_starttls_auto: true  }
config.action\u mailer.delivery\u method=:smtp
config.action\u mailer.smtp\u设置={
地址:'smtp.gmail.com',
港口:587,
域:“example.com”,
用户名:“”,

密码:'

要从本地发送邮件,请在config/application.rb中输入下面的代码

config.action_mailer.delivery_method = :smtp
    config.action_mailer.smtp_settings = {
      :address              => "smtp.gmail.com",
      :port                 => 587,
      :domain               => 'gmail.com',
      :user_name            => 'your_email_id',
      :password             => 'password',
      :authentication       => 'plain',
      :enable_starttls_auto => true  }
在application.rb文件中添加以下行

config.action_mailer.default_url_options = { :host => 'localhost', :port => 3000 }

我刚刚得到gmail smtp,上面有类似的设置。根据你的gmail帐户,你可能必须授予“设备”访问权限才能使用gmail smtp。[请参阅此处]()。我必须授予设备访问我的开发和生产机器的权限,以及在google帐户设置>允许访问“不太安全”的应用程序下的权限。