ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I wanted to create a little program that will sit on my desktop or in my taskbar and periodically check to see if I have any new messages in my school inbox.
I was wondering if there might be a library for Java or C++ that would allow me to easily interface with a POP3 e-mail server to determine if there are any messages waiting?
For Java, it's in 'javax.mail' and also 'javax.activation'. You can find API Doc for it for easy, try to go and search through www.sun.com.
For C++, I dont know it has or not but you can do another way by Programming with Socket API, which actually it's used to send data between hosts but with specific Data Header.(Something like HTTP, such as => Content-Type: text/html\r\n) This make you go to look in rfc doc, http://www.ietf.org.
I wanted to create a little program that will sit on my desktop or in my taskbar and periodically check to see if I have any new messages in my school inbox.
I was wondering if there might be a library for Java or C++ that would allow me to easily interface with a POP3 e-mail server to determine if there are any messages waiting?
You can do it with a shell script:
Code:
#!/bin/bash
user=poppy
passwd=dadsepee
image=$HOME/pics/envelope.jpg
host=mail.somewhere.com
port=110
while :
do
sleep 60 &
delay=$!
CR=$'\r' ## carriage return; for removal of
exec 3<>/dev/tcp/$host/$port ## connect to POP3 server, port 110
read ok line <&3 ## get response from server
[ "${ok%$CR}" != "+OK" ] && exit 5 ## check that it succeeded
echo user "$user" >&3 ## send user name
read ok line <&3 ## get response
[ "${ok%$CR}" != "+OK" ] && exit 5 ## check that it succeeded
echo pass "$passwd" >&3 ## send password
read ok line <&3 ## get response
[ "${ok%$CR}" != "+OK" ] && exit 5 ## check that it succeeded
echo stat >&3 ## request number of messages
read ok num x <&3 ## get response
echo quit >&3 ## close connection
##echo Messages: $num ## display number of messages
display "$image" &
wait $delay
done
You can use fetchmail to check if there is new mail waiting. You should be able to write a periodic check and a pop-up message in almost any script language.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
Advertisement
Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Click Here to receive a complimentary subscription courtesy of LQ.