# Problems sending mail

**URL:** <https://www.ruby-forum.com/t/problems-sending-mail/129319>\
**Category:** Ruby\
**Created:** [February 16, 2008, 6:21pm UTC](https://www.ruby-forum.com/t/problems-sending-mail/129319 "2008-02-16T18:21:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![blackhawkf1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/47e85d/32.png) [@blackhawkf1](https://www.ruby-forum.com/u/blackhawkf1)\
**Post date:** [February 16, 2008, 6:21pm UTC](https://www.ruby-forum.com/t/problems-sending-mail/129319/1 "2008-02-16T18:21:14Z")

</div>

Hi!  
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’  
…  
def sendMeError  
to = ‘removed\_email\_address@domain.invalid’  
from = ‘removed\_email\_address@domain.invalid’  
msg = “To: %s\nFrom: %s\nSubject: %s\n\n%s” % [to,from,  
“Error”, @message]  
Net::SMTP.start(‘localhost’,25) do |smtp|  
smtp.send\_message msg, from, to  
end  
end  
VentanaPrincipal#sendMeError: Errno::EADDRNOTAVAIL: Can’t assign  
requested address - connect(2)

And if I chage it for this:  
def sendMeError  
msg = \<\<end\_of\_message from:="" #{from\_alias}=""\>\<#{from}\>  
To: #{to\_alias} \<#{to}\>  
Subject: #{Error}  
#{@message}  
END\_OF\_MESSAGE  
Net::SMTP.start(â€™localhostâ€™,25) do |smtp|  
smtp.send\_message msg, from, to  
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.
