繁体   English   中英

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

[英]How configure my server to send emails from Ruby on Rails

我正在使用Rails附带的服务器,我需要对其进行配置以将电子邮件发送给诸如juan@gmail.com和pepe@hotmail.com的收件人。

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

我正在使用Mailers执行此操作。

我在互联网上看到的示例如下。

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 / 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 }

要从本地发送邮件,请将下面的代码放在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  }

参考: http : //guides.rubyonrails.org/action_mailer_basics.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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