aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/lib/action_mailer/delivery_method/sendmail.rb
blob: 34e03b806010a50f0cf538ac2865f2c324583eb5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module ActionMailer
  module DeliveryMethod

    # A delivery method implementation which sends via sendmail.
    class Sendmail < Method

      self.settings = {
        :location       => '/usr/sbin/sendmail',
        :arguments      => '-i -t'
      }

      def perform_delivery(mail)
        sendmail_args = settings[:arguments]
        sendmail_args += " -f \"#{mail['return-path']}\"" if mail['return-path']
        IO.popen("#{settings[:location]} #{sendmail_args}","w+") do |sm|
          sm.print(mail.encoded.gsub(/\r/, ''))
          sm.flush
        end
      end
    end
  end
end