Hi Folks,
I am trying to develop an application in which i need to check for new
incoming mails on regular basis. I am using Redhat 9.0 and I was
wondering if anyone out there has any ideas howto do this.
Basically the aim of my project is to be able to retrieve the message
from mail server and convert this into some sort of commands. I wrote
a program to convert the message into commands using a simple text
file but dont know howto retrieve the message from mail server.
Thanks in advance for any help anyone offering.
|
|
0
|
|
|
|
Reply
|
haydargokmen
|
11/9/2003 6:35:20 PM |
|
haydar wrote:
> I am trying to develop an application in which i need to check for new
> incoming mails on regular basis.
Maybe you're looking for the POP3 specification, available as RFC 1939.
Thor
--
http://thorweb.anta.net/
|
|
0
|
|
|
|
Reply
|
Thor
|
11/9/2003 6:45:51 PM
|
|
On 9 Nov 2003 10:35:20 -0800, haydar <haydargokmen@hotmail.com> wrote:
>
>
> Hi Folks,
> I am trying to develop an application in which i need to check for new
> incoming mails on regular basis. I am using Redhat 9.0 and I was
> wondering if anyone out there has any ideas howto do this.
>
I have a script (sh) called by a crontab that does this. It runs the
commands to connect to the Internet and retrieve mail and upload/download
news once every so-many minutes and is quite simple. It looks like this:
#!/bin/sh
if ! /sbin/ifconfig -a ppp0 &> /dev/null ; then
/usr/bin/pon
while true ; do
sleep 1 ; if tail -1 /var/log/syslog | grep IP &> /dev/null ; then sleep 2
fetchmail -s -t 100 ; sleep 2
/usr/bin/slrnpull -d /boot/slrnpull -h news.abc.homespun.net
sleep 1
/usr/bin/poff ; exit 0
else continue; fi ; done
else echo "cronjob checkmail found ppp0 already up and did not run at \
`date` " >> $HOME/dead.letter ; exit 1 ;
fi
exit 0
Is that what you mean?
It checks to see if the internet connection is up, and if isn't, establish
the connection, looking for evidence that it is completed by greping the
end of /var/log/syslog. If the connection is already up it appends a message
to a logfile and exits.
> Basically the aim of my project is to be able to retrieve the message
> from mail server and convert this into some sort of commands. I wrote
> a program to convert the message into commands using a simple text
> file but dont know howto retrieve the message from mail server.
>
Don't have any idea what you are talking about there. Retrieving messages
from a POP or IMAP server can be done in a variety of ways but is usually
done by fetchmail or the same functionality built into a mail client.
Alternatively, you can use a net-tool like netcat or telnet and write a
script to do the job using the POP or IMAP protocols.
> Thanks in advance for any help anyone offering.
Try again and explain what you want more carefully, okay?
--
Alan C this post ends with w
q
|
|
0
|
|
|
|
Reply
|
Alan
|
11/9/2003 11:29:16 PM
|
|
* haydar <haydargokmen@hotmail.com>:
> I am trying to develop an application in which i need
> to check for new incoming mails on regular basis.
> I was wondering if anyone out there has any ideas howto do this.
trying to reinvent the wheel? well - see the page in my sig
for a small overview to mail notification programs.
feedback and help welcome!
> Basically the aim of my project is to be able to retrieve the message
> from mail server and convert this into some sort of commands.
the specification to POP already includes this.
> I wrote a program to convert the message into commands using a simple
> text file but dont know howto retrieve the message from mail server.
"telnet is your friend"
Sven
--
Sven Guckes usenet-sig-mail-notification @guckes.net
http://www.guckes.net/mail/notification.html Mail Notification FAQ
ls, tail, shell (bash,ksh, tcsh, zsh); biff, newmail, nfrm, xbuffy.
clients: elm, mutt, pine (startup flags). Sample setups welcome!
|
|
0
|
|
|
|
Reply
|
Sven
|
11/10/2003 9:09:19 AM
|
|
Alan Connor <zzzzzz@xxx.yyy> wrote in message news:<g5Arb.6963$6c3.1844@newsread1.news.pas.earthlink.net>...
> On 9 Nov 2003 10:35:20 -0800, haydar <haydargokmen@hotmail.com> wrote:
> >
> >
> > Hi Folks,
> > I am trying to develop an application in which i need to check for new
> > incoming mails on regular basis. I am using Redhat 9.0 and I was
> > wondering if anyone out there has any ideas howto do this.
> >
>
> I have a script (sh) called by a crontab that does this. It runs the
> commands to connect to the Internet and retrieve mail and upload/download
> news once every so-many minutes and is quite simple. It looks like this:
>
>
> #!/bin/sh
>
> if ! /sbin/ifconfig -a ppp0 &> /dev/null ; then
> /usr/bin/pon
> while true ; do
> sleep 1 ; if tail -1 /var/log/syslog | grep IP &> /dev/null ; then sleep 2
> fetchmail -s -t 100 ; sleep 2
> /usr/bin/slrnpull -d /boot/slrnpull -h news.abc.homespun.net
> sleep 1
> /usr/bin/poff ; exit 0
> else continue; fi ; done
> else echo "cronjob checkmail found ppp0 already up and did not run at \
> `date` " >> $HOME/dead.letter ; exit 1 ;
> fi
> exit 0
>
>
> Is that what you mean?
>
> It checks to see if the internet connection is up, and if isn't, establish
> the connection, looking for evidence that it is completed by greping the
> end of /var/log/syslog. If the connection is already up it appends a message
> to a logfile and exits.
>
>
> > Basically the aim of my project is to be able to retrieve the message
> > from mail server and convert this into some sort of commands. I wrote
> > a program to convert the message into commands using a simple text
> > file but dont know howto retrieve the message from mail server.
> >
>
> Don't have any idea what you are talking about there. Retrieving messages
> from a POP or IMAP server can be done in a variety of ways but is usually
> done by fetchmail or the same functionality built into a mail client.
>
> Alternatively, you can use a net-tool like netcat or telnet and write a
> script to do the job using the POP or IMAP protocols.
>
> > Thanks in advance for any help anyone offering.
>
> Try again and explain what you want more carefully, okay?
Hi again,
Since I posted my first message I went away and didnt have access to
the internet.
I want to check the mail server for all the new messages and if there
are new messages in inbox, i want to look for specific subject, if i
find the sebject line matching I want to store that message in text
file in /home/X directory.
I am not sure what to do there, Dont know where Linux stores incoming
messages. For now lets say I want to use yahoo mail. Telnet is an
option, what do I need to know about the server to use the telnet to
get the mesage from the server. Or if I run mailserver on my linux
machine, what is the starting point would be, where does linux stores
incoming messages. I am using redhat 9.
Haydar
|
|
0
|
|
|
|
Reply
|
haydargokmen
|
11/13/2003 6:29:01 PM
|
|
On 13 Nov 2003 10:29:01 -0800, haydar <haydargokmen@hotmail.com> wrote:
>
> Hi again,
> Since I posted my first message I went away and didnt have access to
> the internet.
>
> I want to check the mail server for all the new messages and if there
> are new messages in inbox, i want to look for specific subject, if i
> find the sebject line matching I want to store that message in text
> file in /home/X directory.
>
> I am not sure what to do there, Dont know where Linux stores incoming
> messages. For now lets say I want to use yahoo mail. Telnet is an
> option, what do I need to know about the server to use the telnet to
> get the mesage from the server. Or if I run mailserver on my linux
> machine, what is the starting point would be, where does linux stores
> incoming messages. I am using redhat 9.
>
> Haydar
To see where your incoming mail is stored, do
$ echo $MAIL
It'll be /var/spool/mail/your_login_name, or something like that. Usually.
You should generally use fetchmail to bring down the mail from your server,
unless your mail client has that functionality built into it.
If you wish to create your own "fetchmail" netcat is much easier to write
scripts for than telnet, and faster.
I am still not really clear on what you want. You can't actually read the
mail on your server with the IMAP/POP3 protocols. What you can do is
bring down the headers with as many lines of the body as you want. Or the
whole mail. Or the size of each one and its number. You can DELETE the
mail while it is still on the server...
As for scanning for a particular subject and sending that message to
a text file, procmail makes doing things like that VERY easy, although
you could certainly script the same functionality using netcat and
sed and grep and so forth.
--
Alan C this post ends with w
q
|
|
0
|
|
|
|
Reply
|
Alan
|
11/13/2003 7:58:58 PM
|
|
This is a MIME GnuPG-signed message. If you see this text, it means that
your E-mail or Usenet software does not support MIME signed messages.
--=_mimegpg-ny.email-scan.com-28767-1068767722-0006
Content-Type: text/plain; format=flowed; charset="US-ASCII"
Content-Disposition: inline
Content-Transfer-Encoding: 7bit
haydar writes:
> I am not sure what to do there, Dont know where Linux stores incoming
> messages. For now lets say I want to use yahoo mail.
Stop right there.
Yahoo uses a closed, proprietary system, that is not normally accessible via
any standard Internet protocol. The only way to access Yahoo's mail is via
their webmail interface. I do believe that they will allow you to access
your Yahoo mailboxes via POP3, but for an extra monthly fee.
End of story.
There are some enterprising individuals out there who've managed to cobble
together some scripts to suck mail out of Yahoo accounts via simulated HTTP
requests. This approach may have merit in some situations, but it is prone
to breaking each time Yahoo redesigns their webmail service, and in any case
it seems that properly using these kinds of scripts is likely to be
something that you may not be ready to tackle, just yet.
> Telnet is an
> option, what do I need to know about the server to use the telnet to
> get the mesage from the server.
telnet is not used to access any mail on any server. The two primary
protocols for accessing mail stored on a remote mail server are IMAP and
POP3.
> Or if I run mailserver on my linux
> machine, what is the starting point would be, where does linux stores
> incoming messages. I am using redhat 9.
Running a mail server is a complicated, advanced subject. If you intend to
do that, I would suggest that you go and buy a suitable book on the subject.
You will not learn everything you need to know about running a mail server
with just one or two answers to one or two questions posted on a Usenet
newsgroup.
--=_mimegpg-ny.email-scan.com-28767-1068767722-0006
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQA/tBnqx9p3GYHlUOIRAtnzAJsHHI6faqwZqFLm5tRHmgbjLj2FVQCeOXNW
7UMgSHmi3Zk17Ig7dHwq1U8=
=WbRu
-----END PGP SIGNATURE-----
--=_mimegpg-ny.email-scan.com-28767-1068767722-0006--
|
|
0
|
|
|
|
Reply
|
Sam
|
11/13/2003 11:55:18 PM
|
|
Alan Connor <zzzzzz@xxx.yyy> wrote in message news:<6oRsb.11682$6c3.7373@newsread1.news.pas.earthlink.net>...
> On 13 Nov 2003 10:29:01 -0800, haydar <haydargokmen@hotmail.com> wrote:
> >
> > Hi again,
> > Since I posted my first message I went away and didnt have access to
> > the internet.
> >
> > I want to check the mail server for all the new messages and if there
> > are new messages in inbox, i want to look for specific subject, if i
> > find the sebject line matching I want to store that message in text
> > file in /home/X directory.
> >
> > I am not sure what to do there, Dont know where Linux stores incoming
> > messages. For now lets say I want to use yahoo mail. Telnet is an
> > option, what do I need to know about the server to use the telnet to
> > get the mesage from the server. Or if I run mailserver on my linux
> > machine, what is the starting point would be, where does linux stores
> > incoming messages. I am using redhat 9.
> >
> > Haydar
>
> To see where your incoming mail is stored, do
>
> $ echo $MAIL
>
> It'll be /var/spool/mail/your_login_name, or something like that. Usually.
>
> You should generally use fetchmail to bring down the mail from your server,
> unless your mail client has that functionality built into it.
>
> If you wish to create your own "fetchmail" netcat is much easier to write
> scripts for than telnet, and faster.
>
> I am still not really clear on what you want. You can't actually read the
> mail on your server with the IMAP/POP3 protocols. What you can do is
> bring down the headers with as many lines of the body as you want. Or the
> whole mail. Or the size of each one and its number. You can DELETE the
> mail while it is still on the server...
>
> As for scanning for a particular subject and sending that message to
> a text file, procmail makes doing things like that VERY easy, although
> you could certainly script the same functionality using netcat and
> sed and grep and so forth.
Alan,
Your mail does help, thanks for the suggestions. First of all let me
explain what exactly I am after.
I am working on a Lego-Mindstorms project. The idea is: i will write
a short SMS and send it to my e-mail address (I have done this
already). So SMS will be something like "Move Forward 10". This is a
defined word in my lego robot. Once robot received this message it
will start moving forward for 10 seconds. I can do this from command
line, or put it in a text file and run it.
Now the major problem is: I will need to get the SMS sent to the
mailbox, process it (get ride of the header information and all that)
and send this as a command to the robot.
I have another program that takes the text file and looks for the
words I have defined in my lego robot. Let me put it this way, I have
the beginning and the end but not the middle.
I have no good knowledge of mailservers and protocols, so thats why I
decided to get some help from you or idea how to solve this. At the
moment I am lost with the mailserver types and protocols : SMPT, POP3,
SENDMAIL, FETCHMAIL etc. I will need to figure out howto configure a
mail server and find out where it stores the messages and get hold of
this messages.
I never installed or configured a mail server since I am using ISP's
webmail.
h
|
|
0
|
|
|
|
Reply
|
haydargokmen
|
11/14/2003 12:34:48 AM
|
|
On 13 Nov 2003 16:34:48 -0800, haydar <haydargokmen@hotmail.com> wrote:
>
<snip>
> Alan,
> Your mail does help, thanks for the suggestions. First of all let me
> explain what exactly I am after.
>
> I am working on a Lego-Mindstorms project. The idea is: i will write
> a short SMS and send it to my e-mail address (I have done this
> already). So SMS will be something like "Move Forward 10". This is a
> defined word in my lego robot. Once robot received this message it
> will start moving forward for 10 seconds. I can do this from command
> line, or put it in a text file and run it.
>
> Now the major problem is: I will need to get the SMS sent to the
> mailbox, process it (get ride of the header information and all that)
> and send this as a command to the robot.
>
> I have another program that takes the text file and looks for the
> words I have defined in my lego robot. Let me put it this way, I have
> the beginning and the end but not the middle.
>
> I have no good knowledge of mailservers and protocols, so thats why I
> decided to get some help from you or idea how to solve this. At the
> moment I am lost with the mailserver types and protocols : SMPT, POP3,
> SENDMAIL, FETCHMAIL etc. I will need to figure out howto configure a
> mail server and find out where it stores the messages and get hold of
> this messages.
>
> I never installed or configured a mail server since I am using ISP's
> webmail.
>
Usually, webmail is just another way of accessing your POP/IMAP mail
account. Same server.
Not sure what an SMS is, but I'll assume that it's composed of ascii
characters and that you can just type it in at the commandline.
#!/bin/sh
echo
echo
echo "enter your latest SMS here: "
echo
echo
read "sms"
echo "$sms" | mail address_to_send_it_to -s whatever_subject
if test $? = 0 ; then echo ; echo; echo "It's off and on it's way."
else echo "For some reason I couldn't send your sms -- please investigate"
exit 1
fi
echo
echo
exit 0
Now, because you more than likely have procmail installed, or surely can
install it in no time at all with your distro's package manager, I am
going to assume that you have or will shortly have this very useful and
easy-to-use tool.
Your ~/.procmailrc file can look like this:
------------------------------------------------
SHELL=/bin/sh
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin # make sure those are on your Path
MAILDIR=$HOME/Mail #directory where your mailboxes are
DEFAULT=$MAILDIR/ # your inbox
LOGFILE=$HOME/log #handy
# customize that for yourself
# this recipe will send any mail with XXX on the subject line, with the
#headers stripped away, to ~/smsfile. Instead of re-directing it to a file
# with a >, you can pipe it to the input of a program with |
:0
* ^Subject.*XXX
| sed '1,/^$/d' > ~/smsfile
:0:
${DEFAULT}
---------------------------------------------
We getting anywhere?
--
Alan C this post ends with w
q
|
|
0
|
|
|
|
Reply
|
Alan
|
11/14/2003 1:28:57 AM
|
|
Alan Connor <zzzzzz@xxx.yyy> wrote in message news:<tdWsb.12063$6c3.906@newsread1.news.pas.earthlink.net>...
> On 13 Nov 2003 16:34:48 -0800, haydar <haydargokmen@hotmail.com> wrote:
> >
>
> <snip>
>
> > Alan,
> > Your mail does help, thanks for the suggestions. First of all let me
> > explain what exactly I am after.
> >
> > I am working on a Lego-Mindstorms project. The idea is: i will write
> > a short SMS and send it to my e-mail address (I have done this
> > already). So SMS will be something like "Move Forward 10". This is a
> > defined word in my lego robot. Once robot received this message it
> > will start moving forward for 10 seconds. I can do this from command
> > line, or put it in a text file and run it.
> >
> > Now the major problem is: I will need to get the SMS sent to the
> > mailbox, process it (get ride of the header information and all that)
> > and send this as a command to the robot.
> >
> > I have another program that takes the text file and looks for the
> > words I have defined in my lego robot. Let me put it this way, I have
> > the beginning and the end but not the middle.
> >
> > I have no good knowledge of mailservers and protocols, so thats why I
> > decided to get some help from you or idea how to solve this. At the
> > moment I am lost with the mailserver types and protocols : SMPT, POP3,
> > SENDMAIL, FETCHMAIL etc. I will need to figure out howto configure a
> > mail server and find out where it stores the messages and get hold of
> > this messages.
> >
> > I never installed or configured a mail server since I am using ISP's
> > webmail.
> >
>
> Usually, webmail is just another way of accessing your POP/IMAP mail
> account. Same server.
>
> Not sure what an SMS is, but I'll assume that it's composed of ascii
> characters and that you can just type it in at the commandline.
>
> #!/bin/sh
>
> echo
> echo
> echo "enter your latest SMS here: "
> echo
> echo
>
> read "sms"
>
> echo "$sms" | mail address_to_send_it_to -s whatever_subject
> if test $? = 0 ; then echo ; echo; echo "It's off and on it's way."
> else echo "For some reason I couldn't send your sms -- please investigate"
> exit 1
> fi
> echo
> echo
> exit 0
>
>
> Now, because you more than likely have procmail installed, or surely can
> install it in no time at all with your distro's package manager, I am
> going to assume that you have or will shortly have this very useful and
> easy-to-use tool.
>
>
> Your ~/.procmailrc file can look like this:
>
> ------------------------------------------------
> SHELL=/bin/sh
> PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin # make sure those are on your Path
> MAILDIR=$HOME/Mail #directory where your mailboxes are
> DEFAULT=$MAILDIR/ # your inbox
> LOGFILE=$HOME/log #handy
>
> # customize that for yourself
>
>
> # this recipe will send any mail with XXX on the subject line, with the
> #headers stripped away, to ~/smsfile. Instead of re-directing it to a file
> # with a >, you can pipe it to the input of a program with |
>
>
> :0
> * ^Subject.*XXX
> | sed '1,/^$/d' > ~/smsfile
>
>
> :0:
> ${DEFAULT}
> ---------------------------------------------
>
> We getting anywhere?
you are correct about SMS, it is ascii characters sent from Mobile
phone, SMS - Short Messaging Service.
I am at work at the moment and will have to get back to home to try
it.
I will post you the result.
|
|
0
|
|
|
|
Reply
|
haydargokmen
|
11/14/2003 12:38:18 PM
|
|
|
9 Replies
119 Views
(page loaded in 0.121 seconds)
Similiar Articles: How to check if a PDF is valid? - comp.text.pdf... adding a ToUnicode entry that points to a new object ... This file is damaged but is being repaired" message. ... to repair damaged PDF files. - comp.text.pdf How to check ... Checking to see if a value exists - comp.databases.filemaker ...Is it possible to check if a field contains a certain ... my database is assigning an email address to each new ... com "Thomas Hansen" <violon@online.no> wrote in message ... Looking for an email/website validator, FM7 - comp.databases ...Check this out Fort Worth, TX, July 20, 2005 -- Comm ... You can send simple text based messages or you can send ... Three new free scripts on PSL - comp.graphics.apps ... help with non-overlapping sphere script - comp.soft-sys.matlab ...Do the check for overlap everytime you place a new sphere. If overlap occurs, generate new location ... -Timo "Archi" wrote in message <iedbni$12a$1@fred.mathworks.com ... Tar to another computer follow up: The semaphore timeout period ...The customer gave me a check for a new CentOS 5.5 x64 server. Yipee!! His parts are on ... The semaphore timeout period has expired ..... following error message: error ... error: MAPI and/or MAPI32 cannot be renamed? - comp.mail.eudora.ms ...Check for first email?]. Have you just installed/changed any anti ... Then there is the transferring of the >messages from all old mailboxes to new clones of same. How to check pdf files for errors? - comp.text.pdf... software, that try to catch up with the speed of new ... irritation with the user or viewer check a few simple ... roehle@PLEASE-REMOVE-THISuni-mainz.de> wrote in message ... how to exit gracefully - comp.lang.java.programmer... number of command line arguments.I need to check the ... String stateCode = args[3]; >>> new MyApp ... Exception messages and accompanying stack > traces are ... Checking a field for invalid chars - comp.lang.javascript ...Rgds Robbie "Dylan Parry" <usenet@dylanparry.com> wrote in message news ... Assign value based on value field in query - comp.databases.ms ... the new coumn should check ... instruction to wait all childs ? - comp.unix.programmerHi there, I'm new into UNIX programming (I'm learning ... "Emanuele Blanco" <manub@despammed.com> wrote in message ... create and: while(nrchilds--){ waitpid(..); //and check ... Check for new e-mailTo disable automatic downloading of new e‑mail, click the Tools menu, click Options, and then, on the General tab, clear the Check for new messages every X minute(s) check ... The New Messages - Facebook Messages | FacebookThe New Messages Texts, chat and email together in one simple conversation. 7/9/2012 1:06:44 PM
|