I used mail()
command in php and it worked fine without defining any logins and passwords. Now I am learing Ruby on Rails and it's written in guides that I need to configure some e-mail accaunt to be able to send e-mails. Why do I need one on Ruby and don't need any on php? What is difference and what is better?
为什么我需要一个电子邮件帐户来发送ruby上的邮件而不需要这样的PHP?
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- doutangqi4444 2013-12-27 18:28关注
generally speaking you don't need one on rails, anymore than you need one in php. It all depends on your hosting setup. On a well connected server running a local mail server/relay agent you can setup rails to use the local sendmail config, this is normally what php does by default with the mail() command). see
http://guides.rubyonrails.org/action_mailer_basics.html
specifically section 6.1config.action_mailer.delivery_method = :sendmail # Defaults to: # config.action_mailer.sendmail_settings = { # location: '/usr/sbin/sendmail', # arguments: '-i -t' # } config.action_mailer.perform_deliveries = true config.action_mailer.raise_delivery_errors = true config.action_mailer.default_options = {from: 'no-replay@example.com'}
There are also configs there for gmail, etc.
I'll add that the reason most tutorials show the email account being used is that they are being run on localhost which there is a good chance isn't well connected and doesn't have a working sendmail config in place. So in order to make it work, and actually see emails from the app, using something like gmail to relay is a safe choice/default.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报