3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/blogpost/sendmail.rb', line 3
def self.post(opts={})
opts = Blogpost.options.merge(opts)
opts[:port] = "25" unless opts.key?(:port)
opts[:host] = "localhost" unless opts.key?(:host)
opts[:user] = "[email protected]" unless opts.key?(:user)
body = "From: \#{opts[:user]}\nTo: \#{opts[:address]}\nSubject: \#{opts[:title]}\nDate: \#{Time::now.strftime(\"%a, %d %b %Y %X %z\")}\nContent-Type: text/html; charset=UTF-8\n\n\#{opts[:content]}\n"
Net::SMTP.start(opts[:host], opts[:port]) do |smtp|
smtp.send_mail body, opts[:user], opts[:address]
end
end
|