# Gmailer

**URL:** <https://www.ruby-forum.com/t/gmailer/85809>\
**Category:** Ruby\
**Created:** [February 16, 2007, 2:01pm UTC](https://www.ruby-forum.com/t/gmailer/85809 "2007-02-16T14:01:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![unni.tallman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/f04885/32.png) [@unni.tallman](https://www.ruby-forum.com/u/unni.tallman)\
**Post date:** [February 16, 2007, 2:01pm UTC](https://www.ruby-forum.com/t/gmailer/85809/1 "2007-02-16T14:01:40Z")

</div>

How can i send HTML emails using the ruby gmailer module?

---

<div class="post-metadata">

**Author:** ![unni.tallman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/f04885/32.png) [@unni.tallman](https://www.ruby-forum.com/u/unni.tallman)\
**Post date:** [February 17, 2007, 2:08pm UTC](https://www.ruby-forum.com/t/gmailer/85809/2 "2007-02-17T14:08:27Z")

</div>

There are a few aspects to it:

This is were the question belongs:  
[http://rubyforge.org/forum/forum.php?forum\_id=3738](http://rubyforge.org/forum/forum.php?forum_id=3738)

This is about the pitfalls of how popular email clients read HTML and  
therefore how you should write HTML that would display correctly.

> **[PageResource.com - All About Web Development](https://pageresource.com)**
>
> PageResource.com is being discontinued as we’re merging with WebsiteSetup.org If you need web development tutorials, follow the links below (from WebsiteSetup.org) HTML Beginner’s Tutorial HTML Cheat Sheet How to Make a Website: Step by Step Guide If...

Markaby is a great way to generate HTML, although you might want to  
try what Ara announced yesterday (xx I think) which is claimed to be  
more powerful.

This is an example of how to send email with Gmailer:  
GMailer.connect(name, pwd) do |g|  
# ‘From’ default [gmail.com](http://gmail.com) account  
g.send(  
:to =\> “removed\_email\_address@domain.invalid, my\_friend@his\_company.com,  
removed\_email\_address@domain.invalid”,  
:cc =\> “removed\_email\_address@domain.invalid”,  
:subject =\> “Hello There!”,  
:body =\> “Hi…\n\nBlah blah blah~…”,  
:files =\> [“./my\_pic.jpg”, “./my\_cv.txt”])

```
  # multiple verified email addresses and choose one 'From:' email 

```

address  
g.send(  
:from =\> “removed\_email\_address@domain.invalid”,  
:to =\> “removed\_email\_address@domain.invalid, my\_friend@his\_company.com,  
removed\_email\_address@domain.invalid”,  
:cc =\> “removed\_email\_address@domain.invalid”,  
:subject =\> “Hello There!”,  
:body =\> “Hi…\n\nBlah blah blah~…”,  
:files =\> [“./my\_pic.jpg”, “./my\_cv.txt”])  
end

(taken form gmailer readme).

This helps you with MIME handling so you can compose a MIME message  
easily:  
[http://rubyforge.org/projects/rubymail/](http://rubyforge.org/projects/rubymail/)

I think you can just stick the MIME message’s .to\_s as :body for  
Gmailer#send. Experiment with it.

In case you don’t know about MIME and HTML email, well… All you need  
to do is have a content-type of text/html for the message body.

Google further.

I also advise you to have a look at the adopt-a-newbie project here at  
the ML.

Aur S.

---

<div class="post-metadata">

**Author:** ![unni.tallman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/f04885/32.png) [@unni.tallman](https://www.ruby-forum.com/u/unni.tallman)\
**Post date:** [February 17, 2007, 4:08pm UTC](https://www.ruby-forum.com/t/gmailer/85809/3 "2007-02-17T16:08:37Z")

</div>

Might want to give mailfactory a try  
[http://www.grayskies.net/mailfactory](http://www.grayskies.net/mailfactory)
