2
votes

I search the equivalent to very simple PHP mail function, in ruby.

I watch http://guides.rubyonrails.org/action_mailer_basics.html and I trid to use it but it's not clear.

The only exemple I found on guide and on others responses on SO it's about "gmail smtp". I don't want used gmail smtp, just local smtp server to test mail function like on WAMP.

I tried :sendmail delivery_method, but it respond "/bin/sendmail doesn't exist", so I install postfix in local and add this config to development.rb :

  config.action_mailer.default_url_options = { :host => 'localhost:3000' }
  config.action_mailer.delivery_method = :sendmail
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true  

log of my rails server :

UserMailer#welcome_email: processed outbound mail in 2.4ms

Sent mail to test@mytruedomain.com (59.5ms) Date: Wed, 10 Dec 2014 12:08:02 +0100 From: contact@test.com To: mytruedomain.com Message-ID: <5488299262e_17a43f9c2ba19314937e6@matrix-PC.mail> Subject: test Mime-Version: 1.0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

un test

but I never recieve it in my mail box at test@mytruedomain.com...

EDIT: when I watch log of postfix :

postfix/error[6335]: 7ECBD5C29E5: to=, relay=none, delay=0.14, delays=0.08/0/0/0.06, dsn=5.0.0, status=bounced (mytruedomain.com)

What specific config is missing/needed with my local postfix?

So how can I do to send mail? I just want send mail, I don't understand how it's so complicated !

2

2 Answers

3
votes

First test if your server is working:

date | mail -s test your.name@domain.com

Then configure your application to send the email using smtp:

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  :address => "localhost",
  :port => 25,
  :domain => "domain.com",
}
0
votes

Try the code from Paulo Fidalgo, and I'll recommend you use mailcatcher.

Actually you just need this line in your development.rb file:

config.action_mailer.delivery_method = :smtp