# Binding to a local address in Net::SMTP

**URL:** <https://www.ruby-forum.com/t/binding-to-a-local-address-in-net-smtp/54621>\
**Category:** Ruby\
**Created:** [March 10, 2006, 7:58am UTC](https://www.ruby-forum.com/t/binding-to-a-local-address-in-net-smtp/54621 "2006-03-10T07:58:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jim\_Cain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c0e974/32.png) [@Jim\_Cain](https://www.ruby-forum.com/u/Jim_Cain)\
**Post date:** [March 10, 2006, 7:58am UTC](https://www.ruby-forum.com/t/binding-to-a-local-address-in-net-smtp/54621/1 "2006-03-10T07:58:27Z")

</div>

For TCPSocket, I know it’s possible to specify the local IP address if  
you want to:

socket = TCPSocket.new(remote\_addr, remote\_port, local\_addr, local\_port)

BTW I found this by looking in the source code, since every document I  
was referencing only showed the first two arguments.

I am mailing from a host with multiple IP addresses, and I’d like to  
be able to specify the local address when I open a connection with  
Net::SMTP. Looking at the source, I don’t see any way to do this. I’m  
thinking about modifying Net::InternetMessageIO.open (1.8.2) or  
old\_open (1.8.4) so that it calls TCPSocket.new with the four  
arguments, rather than two.

Has anyone had this same issue and created such a workaround? Thanks  
for any help.

Cheers,  
Jim
