# Need help with mail

## Etal

Hi all,

I am fed up with my graphical email client. I am sick of being tied to it and not having access to my mail if some library down the line or the client itself breaks.

What I want is something simple that does its job and does it well. Here is what I need:

- Should be able to get mail from several POP3 servers and put it into an mbox or maildir in ~/.mail

- Filter the incoming mail and put it into a specific mbox/maildir based on the headers

- Send the mail through a specified SMTP server

- Being able to view/send my mail through any email client (like alpine, for example) with minimal effort

I have always used graphical clients for doing that, so I am not really sure what I should be looking for. I am guessing I would need something like Fetchmail to get the mail. For sending, I found sSMTP already installed, but it seems it can only send through only one SMTP server.

What would you recommend?

Thanks in advance!  :Smile: 

----------

## pianosaurus

1: I use net-mail/getmail for fetching to maildir, but it supports mbox too (and a few others, IIRC). Works like a charm. Edit: It's not a daemon, so stick it in cron.

2: I don't filter, but I suspect there are some choices in portage.

3: For sending, mail-mta/ssmtp does the job. It is probably already installed on any gentoo system. Configuration is in /etc/ssmtp/.

4: Most mail clients can read mbox or maildir, I believe, and I suspect at least all CLI clients can be set up to use ssmtp. I use mutt.

Addendum: Oops, didn't see your problem with ssmtp there. Hang on, I'll dig out a link I used to solve the problem.

----------

## Etal

Hey Cuber,

Thanks for the suggestions! I'm actually currently playing with msmtp, which seems to be exactly what I need for sending. I'll have a look at getmail once sending is working

Any other suggestions are still welcome  :Smile: 

----------

## pianosaurus

Here's a script I threw together you can use with ssmtp to add a server option:

```
#!/bin/bash

# A noddy that adds a mailhub option to ssmtp.

# Specify an outgoing server using the -s<mailhub> option.

ARGS=()

SERVER=""

OPTION=0

for ARG in "$@"; do

  if [ $OPTION -eq 2 ]; then

    OPTION=1

    SERVER="$ARG"

  else

    if [ "${ARG:0:2}" == "-s" ]; then

      if [ ${#ARG} -gt 2 ]; then

        SERVER="${ARG:2}"

        OPTION=1

      else

        OPTION=2

      fi

    else

      ARGS=("${ARGS[@]}" "$ARG")

    fi

  fi

done

if [ $OPTION -gt 0 ]; then

  /usr/sbin/ssmtp "${ARGS[@]}" -C<(sed -e 's/^[[:space:]]*mailhub=\(.*\)$/mailhub='"$SERVER"'/' /etc/ssmtp/ssmtp.conf)

else

  /usr/sbin/ssmtp "${ARGS[@]}"

fi
```

I haven't actually tested it (don't have ssmtp on this computer), but replacing /usr/sbin/ssmtp with echo in it seems to work as expected. Just save it as ssmtp.sh or somesuch.

----------

## Etal

Thanks for the script, but I set up msmtp and it does the job pretty well  :Smile: 

I have another question, though - all these programs want me to store the password in plaintext in their configuration files. Is there a way to somehow obfuscate them so that no one could easily find them? I really don't like having all my email passwords in one place...

----------

## ppurka

Can't you simply configure alpine, and let it run in a screen session? It can do all the things you want to do (as mentioned in your first post). alpine has support for a obfuscated password file. You need to enable the "passfile" USE flag while emerging it.

----------

## Etal

I'm pretty sure alpine does not provide a /sbin/sendmail workalike for external email clients to use...

----------

## ppurka

 *AM088 wrote:*   

> I'm pretty sure alpine does not provide a /sbin/sendmail workalike for external email clients to use...

 Hmm.. I just tried this:

```
~> echo "

This is something

in the body" | alpine my_email@somewhere.com -I "Down,Down,t,^X,y,Enter" -attach tmp/test
```

And alpine actually sent the email using my default smtp server and without any other prompts since I had my password for the default INBOX stored in the passfile (which is obfuscated). 

Now the only problem I see in this is that my subject was restricted to just "t" and I will probably have to separate *all* the characters in the subject by commas, if I want to send a longer subject.

----------

## Etal

I'd rather not resort to hacks ... I don't really let anyone onto my computer without my supervision anyway so I think I'll be fine  :Twisted Evil: 

----------

