# Hoq to send a message/mail to particular ip

**URL:** <https://www.ruby-forum.com/t/hoq-to-send-a-message-mail-to-particular-ip/92964>\
**Category:** Ruby\
**Created:** [April 26, 2007, 3:17am UTC](https://www.ruby-forum.com/t/hoq-to-send-a-message-mail-to-particular-ip/92964 "2007-04-26T03:17:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![veeraa2003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b487fb/32.png) [@veeraa2003](https://www.ruby-forum.com/u/veeraa2003)\
**Post date:** [April 26, 2007, 3:17am UTC](https://www.ruby-forum.com/t/hoq-to-send-a-message-mail-to-particular-ip/92964/1 "2007-04-26T03:17:42Z")

</div>

Hello everybody !

I’m newbie to ruby. Is there anyway to send a message or mail to  
particular available ip. Please give some suggestion.

Regards,  
Veeraa.

---

<div class="post-metadata">

**Author:** ![veeraa2003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b487fb/32.png) [@veeraa2003](https://www.ruby-forum.com/u/veeraa2003)\
**Post date:** [April 26, 2007, 3:30pm UTC](https://www.ruby-forum.com/t/hoq-to-send-a-message-mail-to-particular-ip/92964/2 "2007-04-26T15:30:37Z")

</div>

On 26.04.2007 03:17, Veera S. wrote:

> I’m newbie to ruby. Is there anyway to send a message or mail to  
> particular available ip. Please give some suggestion.

What exactly do you mean by this? Can you elaborate a bit more?

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![veeraa2003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b487fb/32.png) [@veeraa2003](https://www.ruby-forum.com/u/veeraa2003)\
**Post date:** [April 26, 2007, 2:59pm UTC](https://www.ruby-forum.com/t/hoq-to-send-a-message-mail-to-particular-ip/92964/3 "2007-04-26T14:59:31Z")

</div>

Veera S. wrote:

> Hello everybody !
> 
> I’m newbie to ruby. Is there anyway to send a message or mail to  
> particular available ip. Please give some suggestion.

Not emails. email addresses aren’t linked to IPs. Your only chance is,  
if it is a UNIX, talk is installed, and accessible for you. Otherwise  
you need to develop a client/server solution (SSH and telnet are  
possibilities, too, if you have access to them on your recipient).

Usually, one uses IPs to talk to machines, and emails to talk to people.  
😉

–  
Phillip “CynicalRyan” Gawlowski  
[http://cynicalryan.110mb.com/](http://cynicalryan.110mb.com/)  
[http://clothred.rubyforge.org](http://clothred.rubyforge.org)

Rule of Open-Source Programming #4:

If you don’t work on your project, chances are that no one will.

---

<div class="post-metadata">

**Author:** ![veeraa2003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b487fb/32.png) [@veeraa2003](https://www.ruby-forum.com/u/veeraa2003)\
**Post date:** [April 26, 2007, 10:53pm UTC](https://www.ruby-forum.com/t/hoq-to-send-a-message-mail-to-particular-ip/92964/4 "2007-04-26T22:53:36Z")

</div>

Hi,

If you want a general solution that will work for anybody, you are out  
of luck. For example, if the person is on a corporate network or behind  
any router (and is thus firewalled), you can’t contact them by IP at  
all. Further, there is no way to send an email to a person by knowing  
their IP. You must know what their email address is, both username and  
e-mail host. However, if you can make some assumptions about your users,  
you might be able to think of something.

I think in the past, you might have been able to use Windows Messenger  
to send messages to arbitrary IP addresses (not sure how it worked, but  
it really annoyed me), but I assume that’s patched in recent service  
packs of Windows, and it’s not a reliable way to communicate because  
people turn that service off (if they can).

Someone else mentioned the unix program “talk”, but I don’t think that  
is commonly used. I would give up on an automatic solution–if you need  
to do this, you probably need to make them log into your site, and get  
their email addresses when they first sign up.

Good luck,  
Dan

---

<div class="post-metadata">

**Author:** ![veeraa2003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b487fb/32.png) [@veeraa2003](https://www.ruby-forum.com/u/veeraa2003)\
**Post date:** [April 27, 2007, 4:23am UTC](https://www.ruby-forum.com/t/hoq-to-send-a-message-mail-to-particular-ip/92964/5 "2007-04-27T04:23:59Z")

</div>

On Behalf Of Veera S.:

# I’m newbie to ruby. Is there anyway to send a message or mail to

# particular available ip. Please give some suggestion.

i’m not sure if this really involves ruby.

you want to mail to an ip, this assumes

1. you wont use dns
2. you have a mail server running on that ip

* * *

## Option I

use the [] op instead of the domain or mail server name in sending the  
email, eg

botp@pc4all:~$ mail botp@[192.168.25.4]  
Subject: test  
.  
Cc:  
Null message body; hope that’s ok

botp@pc4all:~$ tail /var/log/mail.info  
Apr 27 10:00:11 localhost postfix/smtp[6351]: A58DA27EAE:  
to=\<botp@[192.168.25.4]\>, relay=192.168.25.4[192.168.25.4], delay=1,  
status=sent (250 2.6.0  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) Queued mail for  
delivery)  
botp@pc4all:~$

* * *

## Option II

create a crude script to simulate smtp and specify your email server(S),  
eg  
(note, here i’m being fancy, i’m sending/relaying mail thru 10.2.10.1 wc  
delivers it to 192.168.25.4)

C:\family\ruby\mail\>cat simple.rb  
require ‘socket’  
t = TCPSocket.new(‘10.2.10.1’, 25)  
puts t.gets  
t.puts ‘HELO Welcome from Ruby’  
puts t.gets  
t.puts ‘MAIL FROM:[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)’  
puts t.gets  
t.puts ‘RCPT TO:\<botp@[192.168.25.4]\>’  
puts t.gets  
t.puts ‘DATA’  
puts t.gets  
t.puts ‘Test Email from Ruby’  
t.puts “\r\n.\r\n”  
puts t.gets  
t.puts ‘QUIT’  
puts t.gets  
t.close

C:\family\ruby\mail\>ruby simple.rb  
220 pc4all.botp.bugo.dmpi ESMTP Postfix (Ubuntu latest)  
250 pc4all.botp.bugo.dmpi  
250 Ok  
250 Ok  
354 End data with .  
250 Ok: queued as 9856027EAE  
221 Bye

* * *

## Option I

Use ruby’s net/smtp which is way cooler and is left as an exercise (but  
you’ll have to understand the smtp fundamentals first)

hth.  
kind regards -botp

---

<div class="post-metadata">

**Author:** ![veeraa2003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b487fb/32.png) [@veeraa2003](https://www.ruby-forum.com/u/veeraa2003)\
**Post date:** [April 26, 2007, 7:44pm UTC](https://www.ruby-forum.com/t/hoq-to-send-a-message-mail-to-particular-ip/92964/6 "2007-04-26T19:44:33Z")

</div>

Robert K. wrote:

> On 26.04.2007 03:17, Veera S. wrote:
> 
> > I’m newbie to ruby. Is there anyway to send a message or mail to  
> > particular available ip. Please give some suggestion.
> 
> What exactly do you mean by this? Can you elaborate a bit more?
> 
> Kind regards
> 
> robert

Hi,

For example if an user registered his information in my application with  
his static ip, then here i want to send a message when the user is in  
internet connection. ( but he dont need to login my application).

Regards,  
Veeraa.

---

<div class="post-metadata">

**Author:** ![veeraa2003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b487fb/32.png) [@veeraa2003](https://www.ruby-forum.com/u/veeraa2003)\
**Post date:** [April 27, 2007, 9:45am UTC](https://www.ruby-forum.com/t/hoq-to-send-a-message-mail-to-particular-ip/92964/7 "2007-04-27T09:45:21Z")

</div>

On 26.04.2007 19:44, Veera S. wrote:

> Robert K. wrote:
> 
> > On 26.04.2007 03:17, Veera S. wrote:
> > 
> > > I’m newbie to ruby. Is there anyway to send a message or mail to  
> > > particular available ip. Please give some suggestion.  
> > > What exactly do you mean by this? Can you elaborate a bit more?
> 
> For example if an user registered his information in my application with  
> his static ip, then here i want to send a message when the user is in  
> internet connection. ( but he dont need to login my application).

So we have two tasks here

1. Detect that someone is online.

2. Send a message.

ad 1) as Dan pointed out there is no general way that would reliably  
work.

ad 2) you do not state what kind of message is to be send. But  
considering futility of 1 it’s probably not worth digging deeper into 2  
either.

Kind regards

robert
