If you need to send an e-mail in ruby, this little function works well.
def send_email(from, from_alias, to, to_alias, subject, message) msg = <To: #{to_alias} <#{to}> Subject: #{subject} #{message} END_OF_MESSAGE Net::SMTP.start(’localhost’) do |smtp| smtp.send_message msg, from, to end end
Satish Talim wrote,
What a coincidence, I juts wrote a similar program on our group blog…
Link | August 2nd, 2006 at 2:38 pm
Satish Talim wrote,
One more thing, which Wordpress plugin are you using for code on your blog?
Link | August 2nd, 2006 at 2:40 pm
Ian Purton wrote,
I am not using a wordpress plugin, I hand code the entries then I have some css to style them.
Please feel free to look at the HTML and stylesheets.
Link | August 2nd, 2006 at 3:17 pm
abhi wrote,
i m trying to send mail with the given code of net::smtp.start().
but it give me error like
Address family not supported by protocol - socket(2)
/opt/lampp/lib/ruby/1.8/net/protocol.rb:206:in `initialize’
/opt/lampp/lib/ruby/1.8/net/protocol.rb:206:in `old_open’
/opt/lampp/lib/ruby/1.8/timeout.rb:56:in `timeout’
/opt/lampp/lib/ruby/1.8/timeout.rb:76:in `timeout’
/opt/lampp/lib/ruby/1.8/net/protocol.rb:206:in `old_open’
/opt/lampp/lib/ruby/1.8/net/smtp.rb:393:in `do_start’
/opt/lampp/lib/ruby/1.8/net/smtp.rb:378:in `start’
/opt/lampp/lib/ruby/1.8/net/smtp.rb:316:in `start’
app/controllers/hello_controller.rb:15:in `deliverMail’
Link | March 28th, 2007 at 4:50 am
sathyz wrote,
Ian.. I followed the steps and it works.. Thanks..
I have to add 2 things here.. We need to install postfix (not sure what to install in windows machine) and add require ‘net/smtp’ ..
Hope the problem with Abi is she might not have installed postfix.
Link | February 15th, 2008 at 6:27 am