Note that there are some explanatory texts on larger screens.

plurals
  1. POSendmail working in Linux Terminal, not in Rails 3
    text
    copied!<p>I'm running Ubuntu 10.04 with Rails 3.2.2. </p> <p>I just installed and configured sendmail. When mail is sent <strong>through terminal it worked perfectly</strong>.</p> <p>But when i try to call it <strong>through Rails, no success</strong>.</p> <p>Although it doesn't really looks like it's failing though. I get no errors, and see this in my console:</p> <pre><code>#&lt;Mail::Message:40338240, Multipart: false, Headers: &lt;From: alert@email.com&gt;, &lt;To: chris@email.com&gt;, &lt;Subject: Hi chris, a testmail too you!&gt;, &lt;Mime-Version: 1.0&gt;, &lt;Content-Type: text/html&gt;, &lt;importance: High&gt;, &lt;X-Priority: 1&gt;&gt; </code></pre> <p>I am in development have the following settings in my development.rb:</p> <pre><code>config.action_mailer.delivery_method = :sendmail config.action_mailer.sendmail_settings = { :location =&gt; '/usr/sbin/sendmail', :arguments =&gt; '-i -t' } config.action_mailer.perform_deliveries = true config.action_mailer.raise_delivery_errors = true </code></pre> <p>I have setup an actionmailer, with the corresponding alert_mail.html.erb:</p> <pre><code>class UserMailer &lt; ActionMailer::Base default from: "alert@email.com" def alert_mail(site) @site = site @user = site.user @url = "http://example.com/login" mail(:to =&gt; @user.email_address, :subject =&gt; "Hi chris, a testmail too you!", :importance =&gt; "High", 'X-Priority' =&gt; '1') end end </code></pre> <p>And this is what I call:</p> <pre><code>UserMailer.alert_mail(site) </code></pre> <p>Could it be something with permissions?</p> <p>Things i've tried - Tried running in production mode - chmod'd the sendmail executables to 777 - Tried removing the priority settings - Running it with rails server instead of nginx</p> <p>I hope someone can help me, thanks in advance! (email.com is just a replacement, i use a valid domain)</p> <p><strong>EDIT:</strong> sadiqxs answer does indeed solve the problem when I try to execute the mail function through rails console. But it still doesn't work when it is supposed to, through my browser. Strange thing is, this seems to be happening in nginx only. When I stop nginx, and start rails server, then it works. But when I when nginx is the server, it doesnt send any mail.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload