# Sending mail through gmail

**URL:** <https://www.ruby-forum.com/t/sending-mail-through-gmail/97282>\
**Category:** Ruby\
**Created:** [July 6, 2006, 2:50am UTC](https://www.ruby-forum.com/t/sending-mail-through-gmail/97282 "2006-07-06T02:50:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![the-companion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47774/32.png) [@the-companion](https://www.ruby-forum.com/u/the-companion)\
**Post date:** [July 6, 2006, 2:50am UTC](https://www.ruby-forum.com/t/sending-mail-through-gmail/97282/1 "2006-07-06T02:50:24Z")

</div>

Hi. Could someone give me an example of how to send mail through a gmail  
account using the Ruby Net::SMTP class? Park H.'s gmailer library  
doesn’t work for me.

Thanks

---

<div class="post-metadata">

**Author:** ![the-companion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47774/32.png) [@the-companion](https://www.ruby-forum.com/u/the-companion)\
**Post date:** [July 6, 2006, 3:28am UTC](https://www.ruby-forum.com/t/sending-mail-through-gmail/97282/2 "2006-07-06T03:28:07Z")

</div>

On 7/5/06, Ell Q. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi. Could someone give me an example of how to send mail through a gmail  
> account using the Ruby Net::SMTP class? Park H.'s gmailer library  
> doesn’t work for me.

It’s probably better to figure out why gmailer isn’t working. I’m not  
sure what you’d have to do for SASL support with gmail/SMTP.

-austin

---

<div class="post-metadata">

**Author:** ![the-companion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47774/32.png) [@the-companion](https://www.ruby-forum.com/u/the-companion)\
**Post date:** [July 6, 2006, 12:38pm UTC](https://www.ruby-forum.com/t/sending-mail-through-gmail/97282/3 "2006-07-06T12:38:11Z")

</div>

On 06/07/06, Ell Q. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi. Could someone give me an example of how to send mail through a gmail  
> account using the Ruby Net::SMTP class? Park H.'s gmailer library  
> doesn’t work for me.

I saw this the other day:

[http://typo.onxen.info/articles/2006/06/27/activemailer-sending-via-gmail](http://typo.onxen.info/articles/2006/06/27/activemailer-sending-via-gmail)

It’s using ActionMailer, but I wonder if the same technique might work  
in your case.

Paul.

---

<div class="post-metadata">

**Author:** ![the-companion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47774/32.png) [@the-companion](https://www.ruby-forum.com/u/the-companion)\
**Post date:** [July 6, 2006, 12:47pm UTC](https://www.ruby-forum.com/t/sending-mail-through-gmail/97282/4 "2006-07-06T12:47:21Z")

</div>

Ell Q. wrote:

> Hi. Could someone give me an example of how to send mail through a gmail  
> account using the Ruby Net::SMTP class? Park H.'s gmailer library  
> doesn’t work for me.

There’s a recent blog post by stoyan at Bloggitation on this topic just  
here:  
[http://typo.onxen.info/articles/2006/06/27/activemailer-sending-via-gmail](http://typo.onxen.info/articles/2006/06/27/activemailer-sending-via-gmail)

Cheers,  
Dave

---

<div class="post-metadata">

**Author:** ![the-companion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47774/32.png) [@the-companion](https://www.ruby-forum.com/u/the-companion)\
**Post date:** [July 6, 2006, 7:40pm UTC](https://www.ruby-forum.com/t/sending-mail-through-gmail/97282/5 "2006-07-06T19:40:07Z")

</div>

Ell Q. wrote:

> Hi. Could someone give me an example of how to send mail through a gmail  
> account using the Ruby Net::SMTP class? Park H.'s gmailer library  
> doesn’t work for me.
> 
> Thanks

may be you should check the SMTP port you provided; because gmail uses  
port 587.

~sind

---

<div class="post-metadata">

**Author:** ![the-companion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47774/32.png) [@the-companion](https://www.ruby-forum.com/u/the-companion)\
**Post date:** [July 6, 2006, 10:06pm UTC](https://www.ruby-forum.com/t/sending-mail-through-gmail/97282/6 "2006-07-06T22:06:00Z")

</div>

Ell Q. wrote:

> Hi. Could someone give me an example of how to send mail through a gmail  
> account using the Ruby Net::SMTP class? Park H.'s gmailer library  
> doesn’t work for me.
> 
> Thanks

I’m just trying to write some normal Ruby code (i.e., not Rails),  
though, so should I be trying to use ActionMailer?

If not, and I can just use the Net::SMTP library, I’m not sure what I do  
here:  
Net::SMTP.start(‘your.smtp.server’, 25, ‘mail.from.domain’, ‘Your  
Account’, ‘Your Password’, :login)

Is it just  
Net::SMTP.start(‘[smtp.gmail.com](http://smtp.gmail.com)’, 587, ‘[gmail.com](http://gmail.com)’, ‘ellquing’,  
'mypassword, :login)? (The main problem is I don’t know what to put in  
the ‘mail.from.domain’–I know absolutely nothing about mail servers or  
whatnot.)

Also, for those curious, the problem with the gmailer library is that I  
used to be able to use it to receive and send mail…but then one day,  
I’m not sure why, I got the following error when trying to login to any  
of my accounts:

> g = GMailer.connect( “ellquing”, “mypassword” )  
> Net::HTTPBadResponse: wrong status line: “\<meta  
> http-equiv="content-type" content="text/html;charset=utf-8"\>”  
> from /usr/lib/ruby/1.8/net/http.rb:1556:in `read_status_line' from /usr/lib/ruby/1.8/net/http.rb:1538:in `read\_new’  
> from /usr/lib/ruby/1.8/net/http.rb:833:in `request' from /usr/lib/ruby/1.8/net/http.rb:615:in `get’  
> from ./gmailer.rb:196:in `connect_no_cookie' from ./gmailer.rb:195:in `start’  
> from ./gmailer.rb:195:in `connect_no_cookie' from ./gmailer.rb:123:in `initialize’  
> from ./gmailer.rb:1767:in `new' from ./gmailer.rb:1767:in `connect’  
> from (irb):2

However, I then proceeded to create a new GMail account, and I was able  
to login fine…

---

<div class="post-metadata">

**Author:** ![the-companion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47774/32.png) [@the-companion](https://www.ruby-forum.com/u/the-companion)\
**Post date:** [August 3, 2006, 2:24pm UTC](https://www.ruby-forum.com/t/sending-mail-through-gmail/97282/7 "2006-08-03T14:24:11Z")

</div>

sindica wrote:

> ~sind

and it uses TLS for authentication

~sind
