2

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 [email protected] (59.5ms) Date: Wed, 10 Dec 2014 12:08:02 +0100 From: [email protected] To: mytruedomain.com Message-ID: <[email protected]> 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 [email protected]...

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 Answers 2

3

First test if your server is working:

date | mail -s test [email protected]

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",
}
3
  • the cmd "date | mail -s test [email protected]" => The program 'mail' is currently not installed.
    – Matrix
    Commented Dec 10, 2014 at 18:02
  • @Matrix install mailx Commented Dec 11, 2014 at 9:33
  • ok, I do, log mail : pastebin.com/REpMi581 Nothing happen in log of my server. Maybe need specific config in postfix?
    – Matrix
    Commented Dec 11, 2014 at 11:10
0

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
1
  • If I use only this line, log postfix said just: "connect from localhost[127.0.0.1] Dec 11 01:16:13 matrix-PC postfix/smtpd[10007]: lost connection after STARTTLS from localhost[127.0.0.1] Dec 11 01:16:13 matrix-PC postfix/smtpd[10007]: disconnect from localhost[127.0.0.1]"
    – Matrix
    Commented Dec 11, 2014 at 0:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.