LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-15-2009, 02:11 PM   #1
ml41782
LQ Newbie
 
Registered: May 2009
Posts: 14

Rep: Reputation: 0
Question Creating a simple mail read only program


Hello
,
I'm trying to create a small program to look at my isp and pull down the messages into individual text files. This is just a read only setup. I need to pull down the message and kill it on the server.

I'm stuck here. I have experimented with a for string but it always fails. I was trying to use date-time and the text file name and end with a .txt. I could read and delete them.

Any suggestions

#!/bin/bash
#
username="mlxxx@vabb.upn";
password="xyzpdq";
sleep 2
echo USER $username
sleep 1
echo PASS $password
sleep 2
echo STAT
sleep 1
echo QUIT
#
# cmdline string to count messages
#./getmail.sh | telnet mail.vabb.upn 110 | tail -n1 | cut -c5
 
Old 07-15-2009, 04:13 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,961

Rep: Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693
Quote:
Originally Posted by ml41782 View Post
Hello
,
I'm trying to create a small program to look at my isp and pull down the messages into individual text files. This is just a read only setup. I need to pull down the message and kill it on the server.

I'm stuck here. I have experimented with a for string but it always fails. I was trying to use date-time and the text file name and end with a .txt. I could read and delete them.

Any suggestions

#!/bin/bash
#
username="mlxxx@vabb.upn";
password="xyzpdq";
sleep 2
echo USER $username
sleep 1
echo PASS $password
sleep 2
echo STAT
sleep 1
echo QUIT
#
# cmdline string to count messages
#./getmail.sh | telnet mail.vabb.upn 110 | tail -n1 | cut -c5
Take a look at the fetchmail command ("man fetchmail")....it does what you're trying to do already...
 
Old 07-15-2009, 05:30 PM   #3
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
And make sure you use Maildir format for your mails - they are individual files.
 
Old 07-15-2009, 06:45 PM   #4
ml41782
LQ Newbie
 
Registered: May 2009
Posts: 14

Original Poster
Rep: Reputation: 0
If I use fetchmail Then I have to use postfix or dovecot or sendmail correct ? I was trying to get arround that by just running a script that I can use on any of my machines at home or work to view my outstanding messages that I may have. one of the reasons for not deleting them from the server.
I just want to create individual emails txt files for each message. I can read and then delete them. All without having to load up software on a machine.
 
Old 07-15-2009, 06:50 PM   #5
ml41782
LQ Newbie
 
Registered: May 2009
Posts: 14

Original Poster
Rep: Reputation: 0
here is the older version of the same code. This has the for statement that doesn't work. I tried mixed versions but I only seem to get one file and its all the messages in one. The other bug is trying to run a loop based on the STAT number of messages.

sleep 2
echo USER $username
sleep 1
echo PASS $password
sleep 2
echo STAT
sleep 1
#echo RETR 1
#
for i in $(seq 1 10); do echo "RETR $i">mail.txt | sleep 2 | mv mail.txt /home/otg1017/Mail/`date '+%Y%m%d-%T'`.txt ; done
sleep 2
echo QUIT


This is the command line used
# $ ./getmail.sh | telnet mail.vabb.com 110
# I have also tried this method too.
# remove everything from >mail.txt on and use it on the outside. This only seems to give me 1 file.
# $ ./getmail.sh | telnet mail.vabb.com 110 >mail.txt | sleep 2 | mv mail.txt /home/otg1017/Mail/`date '+%Y%m%d-%T'`.txt
 
Old 07-16-2009, 08:20 AM   #6
r0b0
Member
 
Registered: Aug 2004
Location: Europe
Posts: 608

Rep: Reputation: 50
Quote:
Originally Posted by ml41782 View Post
If I use fetchmail Then I have to use postfix or dovecot or sendmail correct ?
Wrong. Fetchmail is a client application which fetches e-mail from a pop3/imap account. It doesn't need any postfix or dovecot or sendmail because these are all server applications which are running on the server.

http://theos.in/news/howto-configure...-fetch-emails/

R.
 
Old 07-16-2009, 08:42 PM   #7
peonuser
Member
 
Registered: Mar 2008
Location: Where ever I am.
Distribution: Various
Posts: 177
Blog Entries: 163

Rep: Reputation: 21
alpine is a nice program also.
 
Old 07-17-2009, 07:57 AM   #8
ml41782
LQ Newbie
 
Registered: May 2009
Posts: 14

Original Poster
Rep: Reputation: 0
The idea behind this little project

The idea wqas a simple program that I could put on a system and run it to collect what mail messages I have. not to respond to them. I have linux and uniz boxes both at work and at home. If I knew I was expecting an important message I could run it real quick and look thru the messages for hopefully the one that I was expecting.

I can't get away with installing packages on all these machines. I was trying to come up with a very simple solution.
Run a batch file that creates a series of text files for me to look at and then remove. but never removing them from the server until I get home.

These machines dont have wgui's they are all CLI so I can browse my mail
 
Old 07-18-2009, 06:25 PM   #9
ml41782
LQ Newbie
 
Registered: May 2009
Posts: 14

Original Poster
Rep: Reputation: 0
What do you mean use Maildir format ?

I'm sorry I don't understand what you mean here ?

Quote:
Originally Posted by billymayday View Post
And make sure you use Maildir format for your mails - they are individual files.
 
  


Reply

Tags
commandline


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
E-Mail Read Receipt E-Mail Delivery Status E-Mail tracking number. ytd Linux - Software 3 02-14-2009 05:02 AM
Creating Mail Filter in Thunderbird mail client msivasakthi Linux - Software 1 07-14-2008 03:05 AM
simple mail program works on windows and not on linux naijaguy Linux - General 1 04-21-2005 09:45 PM
problems creating a simple bootable cd to perform a simple task czarherr Linux - Software 1 11-11-2004 06:22 AM
creating an e-mail program hyperriven Programming 2 06-30-2004 03:58 AM


All times are GMT -5. The time now is 08:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration