# Sending mail in RUBY

**URL:** <https://www.ruby-forum.com/t/sending-mail-in-ruby/63358>\
**Category:** Ruby\
**Created:** [June 14, 2006, 3:38pm UTC](https://www.ruby-forum.com/t/sending-mail-in-ruby/63358 "2006-06-14T15:38:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [June 14, 2006, 3:38pm UTC](https://www.ruby-forum.com/t/sending-mail-in-ruby/63358/1 "2006-06-14T15:38:16Z")

</div>

Can someone please point me to a simple mail utility for RUBY? I see  
that I have both RUBYmail and Tmail in my ruby folder on my hard drive,  
but, I canâ??t find any decent documentation on either. Iâ??m on Windows,  
not UNIX. Do I just do a “require” for either to use them? RI yields  
nothing about either.

Thanks.

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [June 14, 2006, 6:28pm UTC](https://www.ruby-forum.com/t/sending-mail-in-ruby/63358/2 "2006-06-14T18:28:05Z")

</div>

Peter B. wrote:

> Can someone please point me to a simple mail utility for RUBY? I see  
> that I have both RUBYmail and Tmail in my ruby folder on my hard drive,  
> but, I canâ??t find any decent documentation on either. Iâ??m on Windows,  
> not UNIX. Do I just do a “require” for either to use them? RI yields  
> nothing about either.
> 
> Thanks.

Documentation for RubyMail: [http://www.lickey.com/rubymail/rubymail/doc/](http://www.lickey.com/rubymail/rubymail/doc/)  
Documentation for TMail: [TMail User Manual](http://i.loveruby.net/en/projects/tmail/doc/)

Hope that helps.

-Justin

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [June 14, 2006, 7:34pm UTC](https://www.ruby-forum.com/t/sending-mail-in-ruby/63358/3 "2006-06-14T19:34:06Z")

</div>

Justin C. wrote:

> Peter B. wrote:
> 
> > Can someone please point me to a simple mail utility for RUBY? I see  
> > that I have both RUBYmail and Tmail in my ruby folder on my hard drive,  
> > but, I canâ??t find any decent documentation on either. Iâ??m on Windows,  
> > not UNIX. Do I just do a “require” for either to use them? RI yields  
> > nothing about either.
> > 
> > Thanks.
> 
> Documentation for RubyMail: [http://www.lickey.com/rubymail/rubymail/doc/](http://www.lickey.com/rubymail/rubymail/doc/)  
> Documentation for TMail: [TMail User Manual](http://i.loveruby.net/en/projects/tmail/doc/)
> 
> Hope that helps.
> 
> -Justin

Thanks, Justin. Yes, that helps. I’d seen those web sites before, but,  
for whatever reason, the links weren’t working. Now I see them, and, I  
can read them. . . .

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [June 14, 2006, 7:40pm UTC](https://www.ruby-forum.com/t/sending-mail-in-ruby/63358/4 "2006-06-14T19:40:36Z")

</div>

Peter B. wrote:

> > > Thanks.
> 
> Thanks, Justin. Yes, that helps. I’d seen those web sites before, but,  
> for whatever reason, the links weren’t working. Now I see them, and, I  
> can read them. . . .

Just be aware that those will only format/parse messages and mailboxes.  
If you want to actually send email you will have to use Net::SMTP or  
Net::IMAP.

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [June 15, 2006, 3:50pm UTC](https://www.ruby-forum.com/t/sending-mail-in-ruby/63358/5 "2006-06-15T15:50:12Z")

</div>

Daniel S. wrote:

> Peter B. wrote:
> 
> > > > Thanks.
> > 
> > Thanks, Justin. Yes, that helps. I’d seen those web sites before, but,  
> > for whatever reason, the links weren’t working. Now I see them, and, I  
> > can read them. . . .
> 
> Just be aware that those will only format/parse messages and mailboxes.  
> If you want to actually send email you will have to use Net::SMTP or  
> Net::IMAP.

Yes, thanks. Iâ??ve seen that. But, Iâ??ve tried tmail and when I run the  
script, it complains about 'require tmail." So, even though I see it in  
my RUBY subdirectories, I don’t know if itâ??s actually installed or not.  
With rubymail, Iâ??ve tried running the 3 install instructions that are on  
the doc. page, but, nothing happens. It doesnâ??t know what Iâ??m talking  
about. I’ll look into SMTP and IMAP. Thanks again.

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [June 17, 2006, 4:43am UTC](https://www.ruby-forum.com/t/sending-mail-in-ruby/63358/6 "2006-06-17T04:43:53Z")

</div>

On Jun 14, 2006, at 10:40 AM, Daniel S. wrote:

> Just be aware that those will only format/parse messages and  
> mailboxes. If you want to actually send email you will have to use  
> Net::SMTP or Net::IMAP.

You can’t send mail with IMAP, only SMTP.

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [June 16, 2006, 11:50pm UTC](https://www.ruby-forum.com/t/sending-mail-in-ruby/63358/7 "2006-06-16T23:50:44Z")

</div>

On 6/15/06, Peter B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Yes, thanks. I’ve seen that. But, I’ve tried tmail and when I run the  
> script, it complains about 'require tmail."

What is the exact line that you’re trying to use?  
I am not sure if you have things setup right, but the “require”  
statement should look like:

require ‘tmail’

(assuming that you have a file called tmail in one of the right  
directories).

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [June 17, 2006, 2:40pm UTC](https://www.ruby-forum.com/t/sending-mail-in-ruby/63358/8 "2006-06-17T14:40:39Z")

</div>

I found the gem ‘mailfactory’ to be a simple and terse message  
generator that outputs MIME, handles attachments and supports text/  
plain and text/html.

To install it just, assuming you have rubygems installed just do:

gem install mailfactory

The rdoc that comes with it has an example on the first page which  
shows you how to use it. Open the rdoc file by looking in wherever  
rubygems lives on windows.
