mail application for cli script admin task

To keep this short, I want my proxy server to receive email from my pop/imap email account into single files. I will write a script which parses the subject or body of the email an performs a task. In this case, allow or deny a web address. What I am visioning is a script which monitors the squid logs for web site usage, which reports new domain usage to my wife an my email address. When replied to allow/deny, I want to parse the received email.

The issue I am running into is when I setup mail via yast, it uses a single file for all mail an I am not able to parse that very well. What I think I want is 1 email / 1 file / in the user folder (probably in home dir).

Please help me understand the email solutions. I am willing to write the scrips ( I think… LOL ). I am thinking this will be the easiest solution for my wife to use to make changes to my proxy server remotely.

Thanks,
John

On Wed, 09 Nov 2011 05:56:02 +0000, Johnfm3 wrote:

> Please help me understand the email solutions.

Probably the easiest way to do this is set up a pop3 server and have your
script just poll the pop mailbox for new messages, pull the messages that
way, and process them.

ISTR that there’s also a way to process incoming mail to a specific
mailbox on a per-message basis, but I might be thinking of sendmail
functionality rather than postfix. You might look, though, at how a
mailing list server software package like mailman handles incoming
requests (subscribe/unsubscribe/info/etc.) as what you’re trying to do is
similar to those processes.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

You can run “fetchmail” to go to the pop3/imap server and retrieve the mail. I think you can configure “fetchmail” to pass the messages to “procmail”, and then you can configure “procmail” to put the mail in mh/nmh mailboxes or maildir mailboxes (mailbox is directory and a message is a file with those two mailbox styles).

On 2011-11-09 07:26, nrickert wrote:
>
> You can run “fetchmail” to go to the pop3/imap server and retrieve the
> mail. I think you can configure “fetchmail” to pass the messages to
> “procmail”, and then you can configure “procmail” to put the mail in
> mh/nmh mailboxes or maildir mailboxes (mailbox is directory and a
> message is a file with those two mailbox styles).

Absolutely.

Procmail will get the mails one by one, and if it matches a recipe the
email can be fed to a script, a single mail, the moment it is received.

How the mail is really stored doesn’t matter.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

Is the fetchmail / procmail settings configured via yast mail-server?

My command line configuration is rough at best, I will say most my successes with linux have been due to YaST ability to complete what I want.

Are you saying I should plan on processing at the time of bringing the emails down? That is a much cleaner method that I was planning. I was thinking of setting up my scripts in cron to process the the emails during set times.

John

I don’t think so. Prepare to spend some time with man pages.

On 2011-11-09 15:16, Johnfm3 wrote:
>
> Is the fetchmail / procmail settings configured via yast mail-server?

fetchmail, yes. Procmail, no. And not server, but client, I think.

> My command line configuration is rough at best, I will say most my
> successes with linux have been due to YaST ability to complete what I
> want.

For success in Linux administration you need to get your hands dirty on the
command line :slight_smile:

Both programs have good manual pages with examples, they are easy.

Fetchmail is a neat application that gets all the email from one or a
hundred remote mail accounts, on several protocols, and push them onto your
local mail stack. Traditionally they are sent to the local mail server,
which can do, for example, antispam filtering, delivering to local mail
accounts… Or they can be sent directly to procmail.

Procmail is a very powerful mail filter. The typical use is for
distribution of one or several mail sources on different mail folders.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

On Wed, 09 Nov 2011 14:16:02 +0000, Johnfm3 wrote:

> Is the fetchmail / procmail settings configured via yast mail-server?

Fetchmail is pretty easy to set up; I don’t believe there’s a yast plugin
for it.

Procmail probably doesn’t have a plugin, because it involves a fair bit
of customization. If you’re willing to write the scripts to do the
parsing, though, doing the setup of procmail should be pretty
straightforward.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

On 2011-11-09 18:49, Jim Henderson wrote:
> Fetchmail is pretty easy to set up; I don’t believe there’s a yast plugin
> for it.

Not exactly, but if you setup the standard mail setup with YaST, it will
also configure fetchmail as part of it all. A basic config, that is.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

Stupid question, do you have to use email as your means of triggering these events (allowing/denying a web address)?

On Wed, 09 Nov 2011 18:13:06 +0000, Carlos E. R. wrote:

> On 2011-11-09 18:49, Jim Henderson wrote:
>> Fetchmail is pretty easy to set up; I don’t believe there’s a yast
>> plugin for it.
>
> Not exactly, but if you setup the standard mail setup with YaST, it will
> also configure fetchmail as part of it all. A basic config, that is.

Good to know - when I set it up years ago on my system here at home, I
just set it up by hand. The configuration file was pretty
straightforward, but good to know yast has a plugin. :slight_smile:

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

Sure, my wife is not a system admin. Power user as best. We both work, an email is something we can do from our phones. The problem is while were at work, an the kids ask me to unlock the internet as the proxy is to restrictive for the site they want. My wife or I could send a email an know that within a set time the site will be added to the approved list an the proxy service reloaded. Add to that off work hours while were on the train going to or from work. No use of internet to connect via the Mac’s. So SSH is out. Again, email is the one thing we both have almost anywhere. With AT&T, I get email while in the mountains. Pretty nice.

An why might I not want to use a web page might you ask. Good question. My wife works with at Microsoft for probably the 1 group who doesn’t allow personal Internet usage… Which is rough as during my time at the big M$ I had hotmail, jeepforum, an OpenSuSE all open (Shoot, i am at amazon writing this). Further more, whats simpler than just sending a email with a subject of allow an a web domain in the body. An I should be able to set this up to only accept emails from our emails so that the kids dont just send one them self.

John

On 2011-11-09 19:21, Jim Henderson wrote:
> On Wed, 09 Nov 2011 18:13:06 +0000, Carlos E. R. wrote:

> Good to know - when I set it up years ago on my system here at home, I
> just set it up by hand. The configuration file was pretty
> straightforward, but good to know yast has a plugin. :slight_smile:

Me too.

It configures /etc/fetchmailrc, and activates a service daemon in init.d.
It must also do some trick I haven’t figured out, because fetchmail advises
against using “root” to run it, so it must be using some other user, I suppose.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

On Wed, 09 Nov 2011 18:53:06 +0000, Carlos E. R. wrote:

> On 2011-11-09 19:21, Jim Henderson wrote:
>> On Wed, 09 Nov 2011 18:13:06 +0000, Carlos E. R. wrote:
>
>
>> Good to know - when I set it up years ago on my system here at home, I
>> just set it up by hand. The configuration file was pretty
>> straightforward, but good to know yast has a plugin. :slight_smile:
>
> Me too.
>
> It configures /etc/fetchmailrc, and activates a service daemon in
> init.d.
> It must also do some trick I haven’t figured out, because fetchmail
> advises against using “root” to run it, so it must be using some other
> user, I suppose.

For my own setup, I have a .fetchmailrc file in my user home directory,
and use the user’s crontab to run it.

But as a daemon, there’s a mechanism to ‘runas’ another user that’s a
pretty standard thing IIRC.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

On 2011-11-09 19:56, Johnfm3 wrote:
> An I should be able to set this up to only accept emails from our
> emails so that the kids dont just send one them self.

They will learn to bypass those limits sooner than you think :-p


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

On 2011-11-09 20:10, Jim Henderson wrote:
> On Wed, 09 Nov 2011 18:53:06 +0000, Carlos E. R. wrote:

> But as a daemon, there’s a mechanism to ‘runas’ another user that’s a
> pretty standard thing IIRC.

I know. But I wonder which user they use, and if that user owns
/etc/fetchmailrc.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

I would be so proud. I think I have 1 admin in the group… :slight_smile:

They are right now trying to learn to bypass iptables an local (to the machine) squid server. Once they get pass that, they can deal with the squid server on the firewall which is what I am working on now. The local proxy’s were a temp solution.

John

On Wed, 09 Nov 2011 19:48:07 +0000, Carlos E. R. wrote:

> On 2011-11-09 20:10, Jim Henderson wrote:
>> On Wed, 09 Nov 2011 18:53:06 +0000, Carlos E. R. wrote:
>
>
>> But as a daemon, there’s a mechanism to ‘runas’ another user that’s a
>> pretty standard thing IIRC.
>
> I know. But I wonder which user they use, and if that user owns
> /etc/fetchmailrc.

The script uses the user ‘fetchmail’ as the user.

Oddly, the rpm shows /etc/fetchmail in the file list, but the file isn’t
actually created with the installation.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

On 2011-11-09 20:57, Jim Henderson wrote:
> Oddly, the rpm shows /etc/fetchmail in the file list, but the file isn’t
> actually created with the installation.

It is yast who fills it. The script doesn’t run fetchmail if the
configuration file doesn’t exist - but if the rpm puts an empty file that
is defeated.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)