# Problems sending mail

**URL:** <https://rubytalk.org/t/problems-sending-mail/44556>\
**Category:** ruby-talk\
**Created:** [16 February 2008 17:21 UTC](https://rubytalk.org/t/problems-sending-mail/44556 "2008-02-16T17:21:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benito\_Marcote](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@Benito\_Marcote](https://rubytalk.org/u/Benito_Marcote)\
**Post date:** [16 February 2008 17:21 UTC](https://rubytalk.org/t/problems-sending-mail/44556/1 "2008-02-16T17:21:07Z")

</div>

Hi!  
&nbsp;&nbsp;I want the program send me a email when a exception happens (sending  
it from any computer). But this throws an error:

require 'net/smtp'  
...  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def sendMeError  
&nbsp;&nbsp;&nbsp;&nbsp;to = 'me@mail.com'  
&nbsp;&nbsp;&nbsp;&nbsp;from = 'anyone@mail.com'  
&nbsp;&nbsp;&nbsp;&nbsp;msg = "To: %s\nFrom: %s\nSubject: %s\n\n%s" % [to,from,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Error", @message]  
&nbsp;&nbsp;&nbsp;&nbsp;Net::SMTP.start('localhost',25) do |smtp|  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;smtp.send\_message msg, from, to  
&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;end  
VentanaPrincipal#sendMeError: Errno::EADDRNOTAVAIL: Can't assign  
requested address - connect(2)

And if I chage it for this:  
def sendMeError  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msg = \<\<end\_of\_message from:="" #{from\_alias}=""\>\<#{from}\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#{@message}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;END\_OF\_MESSAGE  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Net::SMTP.start(’localhost’,25) do |smtp|  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;smtp.send\_message msg, from, to  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
end

/Users/benitomarcotemartin/programación/NewtonRaphson/build/Release/NewtonRaphson.app/Contents/Resources/rb\_main.rb:17:in  
`require':  
/Users/benitomarcotemartin/programación/NewtonRaphson/build/Release/NewtonRaphson.app/Contents/Resources/VentanaPrincipal.rb:77:  
can't find string "END\_OF\_MESSAGE" anywhere before EOF (SyntaxError)  
/Users/benitomarcotemartin/programación/NewtonRaphson/build/Release/NewtonRaphson.app/Contents/Resources/VentanaPrincipal.rb:64:  
syntax error, unexpected $end, expecting tSTRING\_CONTENT or tSTRING\_DBEG  
or tSTRING\_DVAR or tSTRING\_END from  
/Users/benitomarcotemartin/programación/NewtonRaphson/build/Release/NewtonRaphson.app/Contents/Resources/rb\_main.rb:17:in  
`rb\_main\_init'

Thanks.

> **···**
>
> To: #{to\_alias} \<#{to}\>  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Subject: #{Error}  
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
