# Trouble Sending Emails

**URL:** <https://rubytalk.org/t/trouble-sending-emails/40377>\
**Category:** ruby-talk\
**Created:** [4 September 2007 16:15 UTC](https://rubytalk.org/t/trouble-sending-emails/40377 "2007-09-04T16:15:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_White1](https://avatars.discourse-cdn.com/v4/letter/m/a87d85/32.png) [@Matt\_White1](https://rubytalk.org/u/Matt_White1)\
**Post date:** [4 September 2007 16:15 UTC](https://rubytalk.org/t/trouble-sending-emails/40377/1 "2007-09-04T16:15:04Z")

</div>

Hello,

One of my scripts that used to send e-mails on successful completion  
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. 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|  
&nbsp;&nbsp;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 irb when I cut-and-paste this code...  
Thanks!

---

<div class="post-metadata">

**Author:** ![Glen\_Holcomb](https://avatars.discourse-cdn.com/v4/letter/g/ecc23a/32.png) [@Glen\_Holcomb](https://rubytalk.org/u/Glen_Holcomb)\
**Post date:** [4 September 2007 16:19 UTC](https://rubytalk.org/t/trouble-sending-emails/40377/2 "2007-09-04T16:19:38Z")

</div>

Is your irb session running as the same user the script is being run as?

> **···**
>
> On 9/4/07, Matt White \<whiteqt@gmail.com\> wrote:
> 
> > Hello,
> > 
> > One of my scripts that used to send e-mails on successful completion  
> > 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. 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|  
> > &nbsp;&nbsp;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 irb when I cut-and-paste this code...  
> > Thanks!
> 
> --  
> "Hey brother Christian with your high and mighty errand, Your actions speak  
> so loud, I can't hear a word you're saying."
> 
> -Greg Graffin (Bad Religion)
