From: brad smith Date: 2013-02-21T03:34:41+09:00 Subject: Re: Could you please post a program to send mail without using Action Mailer --f46d042dfc8713c00404d62c1cad Content-Type: text/plain; charset=ISO-8859-1 I ran your example and it works fine. Have you looked in you email logs? On Wed, Feb 20, 2013 at 9:23 AM, chandan mallik wrote: > require 'net/smtp' > > def send_email(to,opts={}) > opts[:server] ||= 'localhost' > opts[:from] ||= 'email@example.com' > opts[:from_alias] ||= 'Example Emailer' > opts[:subject] ||= "You need to see this" > opts[:body] ||= "Important stuff!" > > msg = < From: #{opts[:from_alias]} <#{opts[:from]}> > To: <#{to}> > Subject: #{opts[:subject]} > > #{opts[:body]} > END_OF_MESSAGE > > Net::SMTP.start(opts[:server]) do |smtp| > smtp.send_message msg, opts[:from], to > end > end > I tried this but it doesn"t work > > -- > Posted via http://www.ruby-forum.com/. > > --f46d042dfc8713c00404d62c1cad Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
I ran your example and it works fine. =A0Have you looked i= n you email logs?


On Wed, Feb 20, 2013 at 9:23 AM, chandan mallik <lists@ruby-f= orum.com> wrote:
require 'net/smtp'

def send_email(to,opts=3D{})
=A0 opts[:server] =A0 =A0 =A0||=3D 'localhost'
=A0 opts[:from] =A0 =A0 =A0 =A0||=3D 'email@example.com'
=A0 opts[:from_alias] =A0||=3D 'Example Emailer'
=A0 opts[:subject] =A0 =A0 ||=3D "You need to see this"
=A0 opts[:body] =A0 =A0 =A0 =A0||=3D "Important stuff!"

=A0 msg =3D <<END_OF_MESSAGE
From: #{opts[:from_alias]} <#{opts[:from]}>
To: <#{to}>
Subject: #{opts[:subject]}

#{opts[:body]}
END_OF_MESSAGE

=A0 Net::SMTP.start(opts[:server]) do |smtp|
=A0 =A0 smtp.send_message msg, opts[:from], to
=A0 end
end
=A0I tried this but it doesn"t work

--
Posted via http://= www.ruby-forum.com/.


--f46d042dfc8713c00404d62c1cad--