From: Justin Collins Date: 2006-06-16T02:49:16+09:00 Subject: Re: Getting Net/SMTP to work for me. Peter Bailey wrote: > I've managed to get a simple mail message sent to myself, but, it leaves > a lot to be desired. I get an e-mail from my server, to me, but, there's > no body to the mail, even though I created some message text in a > "message" variable. Also, in the e-mail sent to me, the "to" field in > the e-mail is blank, with my e-mail address under cc: as a blind copy, > (bcc: Peter Bailey/BNA Inc). Can someone help me put in a subject line, > and, get my timestamp to work as my e-mail body? And, I need to put the > name of the file that I'm telling people about in the subject line, too. > That's in a variable. > > (1) message = "Time Sent: 'Time.now'" > (2) Net::SMTP.start('notes1', 25) do |smtp| > (3) smtp.send_message message, > (4) 'pbailey@bna.com', > (5) 'pbailey@bna.com' > end > > Thanks for any help. > > Hi Peter, Please see the Net/SMTP documentation [1]. It gives you an example of a message. Things like the 'to' and 'from' addresses all go in the message. Here's a simpler example (untested): message = < To: Someone Subject: Hi There! Hi Someone, How's it going? Love, Bob EOS require 'net/smtp' Net::SMTP.start('your.smtp.server', 25) do |smtp| smtp.send_message(message, 'bob@bob.com', 'someone@bob.com') end Hope that helps. -Justin [1]http://ruby-doc.org/stdlib/libdoc/net/smtp/rdoc/classes/Net/SMTP.html