# Trouble Sending E-mails

**URL:** <https://www.ruby-forum.com/t/trouble-sending-e-mails/113210>\
**Category:** Rails\
**Created:** [August 28, 2007, 8:55pm UTC](https://www.ruby-forum.com/t/trouble-sending-e-mails/113210 "2007-08-28T20:55:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwalsh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/91b2a8/32.png) [@mwalsh](https://www.ruby-forum.com/u/mwalsh)\
**Post date:** [August 28, 2007, 8:55pm UTC](https://www.ruby-forum.com/t/trouble-sending-e-mails/113210/1 "2007-08-28T20:55:28Z")

</div>

Hello,

One of my scripts that used to send e-mails on success has stopped  
sending e-mails. Using ruby-debug, I found that it is indeed reaching  
those lines of code but no e-mail ever gets sent. I can send e-mails  
using the exact same code from irb and from script/console. Here’s  
what I have:

body = “Subject: Product Import succeeded for supplier #{supplierid}  
at #{Time.now.to\_s}\r\n\r\n”  
Net::SMTP.start(mailserver, 25, helo\_domain, email\_address,  
password, :login) do |smtp|  
smtp.send\_message(body, from\_address, to\_address)  
end

Any ideas where I can look or what I can try to solve this problem?  
Like I said, it works from script/console when I cut-and-paste this  
code… Thanks!

---

<div class="post-metadata">

**Author:** ![mwalsh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/91b2a8/32.png) [@mwalsh](https://www.ruby-forum.com/u/mwalsh)\
**Post date:** [September 4, 2007, 9:39pm UTC](https://www.ruby-forum.com/t/trouble-sending-e-mails/113210/2 "2007-09-04T21:39:00Z")

</div>

I can only get e-mail to send using irb on my Windows box. If I run it  
on a Linux box with this script, here’s what happens:

irb(main):001:0\> supplierid = 8  
=\> 8  
irb(main):002:0\> require ‘net/smtp’  
=\> true  
irb(main):003:0\> body = “Subject: Product Import succeeded for  
supplier #{supplierid} at #{Time.now.to\_s}\r\n\r\n”  
=\> “Subject: Product Import succeeded for supplier 8 at Tue Sep 04  
13:26:56 -0600 2007\r\n\r\n”  
irb(main):004:0\> Net::SMTP.start(mail\_server, 25, helo\_domain,  
login\_email, password, :login) do |smtp|  
irb(main):005:1\* smtp.send\_message(body, from\_address,  
to\_address)  
irb(main):006:1\> end  
=\> “250 Ok: queued as B8876116D122\n”

But the e-mail never arrives. Any ideas?
