1
|
# Specific 2013-06-06
|
2
|
# Rails 2.3.14 C.f. actionmailer-2.3.14/lib/action_mailer/base.rb
|
3
|
|
4
|
module ActionMailer
|
5
|
Base.class_eval do
|
6
|
|
7
|
private
|
8
|
|
9
|
def perform_delivery_smtp(mail)
|
10
|
destinations = mail.destinations
|
11
|
mail.ready_to_send
|
12
|
sender = (mail['return-path'] && mail['return-path'].spec) || Array(mail.from).first
|
13
|
|
14
|
# Specific : Fill Enveloppe-From : bounce emails
|
15
|
# sender changed for the user making the change
|
16
|
# only for compagny members (change the domain name of the email)
|
17
|
if User.current.mail.present? && User.current.mail.ends_with?('@smile.fr')
|
18
|
sender = User.current.mail
|
19
|
end
|
20
|
# END -- Specific : Fill Enveloppe-From : bounce emails
|
21
|
|
22
|
smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port])
|
23
|
smtp.enable_starttls_auto if smtp_settings[:enable_starttls_auto] && smtp.respond_to?(:enable_starttls_auto)
|
24
|
smtp.start(smtp_settings[:domain], smtp_settings[:user_name], smtp_settings[:password],
|
25
|
smtp_settings[:authentication]) do |smtp|
|
26
|
smtp.sendmail(mail.encoded, sender, destinations)
|
27
|
end
|
28
|
end
|
29
|
|
30
|
def perform_delivery_sendmail(mail)
|
31
|
sendmail_args = sendmail_settings[:arguments]
|
32
|
|
33
|
# Specific : Fill Enveloppe-From : bounce emails
|
34
|
sender = ''
|
35
|
sender = mail['return-path'] if mail['return-path']
|
36
|
|
37
|
# sender changed for the user making the change
|
38
|
# only for compagny members (change the domain name of the email)
|
39
|
if User.current.mail.present? && User.current.mail.ends_with?('@smile.fr')
|
40
|
sender = User.current.mail
|
41
|
end
|
42
|
|
43
|
sendmail_args += " -f \"#{sender}\"" if sender.present?
|
44
|
# END -- Specific : Fill Enveloppe-From : bounce emails
|
45
|
|
46
|
IO.popen("#{sendmail_settings[:location]} #{sendmail_args}","w+") do |sm|
|
47
|
sm.print(mail.encoded.gsub(/\r/, ''))
|
48
|
sm.flush
|
49
|
end
|
50
|
end
|
51
|
end
|
52
|
end
|