# mail, postfix, etc.

## jimmij

Hello all,

There were many topics about postfix configuration on this forum as well as in other places but after googling many hours I still cannot configure postfix to suit my needs. I just want to use cron and command "at" on a my notebook. I use it at different places (home, work, etc.) and sometimes I just use it offline, so I cannot fill such variables as "myhostname" or "mydomain" in /etc/postfix/main.cf, what most of postfix howtos propose.

Can anybody give an example how to configure this postfix? Or maybe I need something else (e.g. ssmtp?). I'm completely newbie in this task...

Here is how my /etc/postfix/main.cf looks so far:

```
queue_directory = /var/spool/postfix

command_directory = /usr/sbin

daemon_directory = /usr/lib/postfix

data_directory = /var/lib/postfix

mail_owner = postfix

unknown_local_recipient_reject_code = 550

debug_peer_level = 2

debugger_command =

    PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin

    ddd $daemon_directory/$process_name $process_id & sleep 5

sendmail_path = /usr/sbin/sendmail

newaliases_path = /usr/bin/newaliases

mailq_path = /usr/bin/mailq

setgid_group = postdrop

html_directory = /usr/share/doc/postfix-2.5.5/html

manpage_directory = /usr/share/man

sample_directory = /etc/postfix

readme_directory = /usr/share/doc/postfix-2.5.5/readme

home_mailbox = .maildir/

```

Thanks in advance for any help.

----------

## poly_poly-man

if you only want to forward your mail to a "real" mail server, use ssmtp.

Otherwise:

I tried to set up postfix for my network, and it was a complete PITA. 

sendmail, for my configuration at least, was much easier to get working. Start off with a good tutorial online and you'll do fine.

----------

## jimmij

 *poly_poly-man wrote:*   

> if you only want to forward your mail to a "real" mail server, use ssmtp.
> 
> Otherwise:
> 
> I tried to set up postfix for my network, and it was a complete PITA. 
> ...

 

I juar want to send all mails to /var/spool/mail/username, not to "real" mail server. Do you think sendmail is the best for that trivial (as I see it) work? AFAIK postfix developers claim that postfix is a way easier to configure than sendmail so I'm confused...

----------

## poly_poly-man

 *jimmij wrote:*   

>  *poly_poly-man wrote:*   if you only want to forward your mail to a "real" mail server, use ssmtp.
> 
> Otherwise:
> 
> I tried to set up postfix for my network, and it was a complete PITA. 
> ...

 you probably want sendmail hooked into procmail.

Postfix devs are liars  :Razz: 

----------

## jcat

 *jimmij wrote:*   

> Hello all,
> 
> There were many topics about postfix configuration on this forum as well as in other places but after googling many hours I still cannot configure postfix to suit my needs. I just want to use cron and command "at" on a my notebook. I use it at different places (home, work, etc.) and sometimes I just use it offline, so I cannot fill such variables as "myhostname" or "mydomain" in /etc/postfix/main.cf, what most of postfix howtos propose.
> 
> Can anybody give an example how to configure this postfix? Or maybe I need something else (e.g. ssmtp?). I'm completely newbie in this task...
> ...

 

Why does that mean you can't specify myhostname or mydomain?  They are just local variable.  On a laptop it's often best to set your hostname to resolve to 127.0.0.1, instead of an IP address from your NIC.

I have postfix running without issue on my laptop, just for local mail delivery.  I guess everything's relative, but it's not hard to configure  :Smile: 

Set your hostname as suggested above, make up a domain, then start postfix.  Don't forget to set the smtpd to verbose in master.cf, then you can diagnose faults better using your logs (don't forget to disable verbose logging later).

If you need assistance, post back.

BTW Don't bother with ssmpt, it's not actively developed any more as far as I know.

Cheers,

jcat

----------

## rweaver

From your description it sounds more like you should be looking into using fetchmail, msmtp/ssmtp, and procmail rather than a mail transport agent like sendmail or postfix.  Fetchmail takes care of mail delivery to your local computer from a wide variety of sources (without requiring you to have mx records pointing mail to your machine) and in combination the three programs will let you perform any operations you might want to perform on both incoming and outgoing mail from your system in a configurable and reliable manner.  If you want to get deeper into the configuration it's even possible to configure the entire system to work with spamassassin to eliminate spam too.

The fetchmail homepage has several links that should explain to you more fully what fetchmail can do and push you in the right direction towards a solution to your email problems.

http://fetchmail.berlios.de/

Hope it helps!

Ralph

----------

## Dralnu

I'm going to suggest esmtp over ssmtp. I've been using it myself on my desktop, and it works wonderfully. It is simple, and can handle local mail w/ procmail.

----------

## jimmij

OK, so I've emerged fetchmail, procmail and ssmtp. Lets try:

```

21:41:24 root@phdlap2 ~> echo test | mail -s test root

send-mail: Cannot open localhost:25

Can't send mail: sendmail process failed with error code 1

21:41:44 root@phdlap2 ~>

```

Here is how /etc/ssmtp/ssmtp.conf looks like

```

21:49:28 root@phdlap2 ~> grep -v # /etc/ssmtp/ssmtp.conf | grep -v ^$

root=postmaster

mailhub=localhost

rewriteDomain=

hostname=localhost

21:49:34 root@phdlap2 ~>

```

and /etc/hosts:

```

21:50:50 root@phdlap2 ~> grep -v # /etc/hosts | grep -v ^$

127.0.0.1   localhost phdlap2

21:50:57 root@phdlap2 ~>

```

Perhaps logs from /var/log/messages will be useful too:

 *Quote:*   

> 
> 
> Dec  6 21:41:44 phdlap2 sSMTP[1192]: Unable to connect to "localhost" port 25.
> 
> Dec  6 21:41:44 phdlap2 sSMTP[1192]: Cannot open localhost:25
> ...

 

If I change parameter "mailhub" in ssmtp.conf from localhost to phdlap2 then error change respectively. Any further suggestions?

BTW, I've put mbox into /etc/make.conf - it seems that procmail needs it to put mails into /var/spool/mail, right?

----------

## poly_poly-man

ahem... ssmtp needs an MTA... usually on another computer (I don't think it's possible to run an MTA alongside it... possibly).

There's probably a small MTA available, but ssmtp isn't it.

BTW: MTA = the daemon on port 25. It handles moving the mail to where it has to go. ssmtp is a very VERY basic one... without listening on port 25 even. It simply routes all mail given to it directly to another computer's port 25 to be handled by a REAL mta.

----------

## jimmij

Very well, so I've installed sendmail instead of ssmtp and there is some progress  :Smile: 

I can send mail via "echo foo | mail -s bar root", but sending takes veeeery long (~2 minutes) and in logs I see

```

sendmail[6971]: My unqualified host name (localhost) unknown; sleeping for retry

sendmail[6971]: unable to qualify my own domain name (localhost) -- using short name

```

How to correct this?

----------

## Dralnu

look into esmtp

----------

## jimmij

 *Dralnu wrote:*   

> look into esmtp

 

esmtp doesn't work for me (at least with default configuration):

```

2:38:05 root@phdlap2 ~> echo adsf | mail -s dfa root

Local delivery not possible without a MDA

Can't send mail: sendmail process failed

```

----------

## poly_poly-man

 *jimmij wrote:*   

> Very well, so I've installed sendmail instead of ssmtp and there is some progress 
> 
> I can send mail via "echo foo | mail -s bar root", but sending takes veeeery long (~2 minutes) and in logs I see
> 
> ```
> ...

 

fix up your /etc/hosts.conf...

...of course, you should be running bind on your system anyway  :Razz: 

----------

## Dralnu

 *jimmij wrote:*   

>  *Dralnu wrote:*   look into esmtp 
> 
> esmtp doesn't work for me (at least with default configuration):
> 
> ```
> ...

 

Set mda="usr/bin/procmail -d %T"

----------

## jimmij

 *poly_poly-man wrote:*   

>  *jimmij wrote:*   Very well, so I've installed sendmail instead of ssmtp and there is some progress 
> 
> I can send mail via "echo foo | mail -s bar root", but sending takes veeeery long (~2 minutes) and in logs I see
> 
> ```
> ...

 

Do you mean /etc/hosts (I don't have such file as /etc/hosts.conf)? 

And what exactly should I correct? I have only one line there:

```

127.0.0.1       localhost phdlap2

```

----------

## poly_poly-man

 *jimmij wrote:*   

>  *poly_poly-man wrote:*    *jimmij wrote:*   Very well, so I've installed sendmail instead of ssmtp and there is some progress 
> 
> I can send mail via "echo foo | mail -s bar root", but sending takes veeeery long (~2 minutes) and in logs I see
> 
> ```
> ...

 

oopsie.. yep,. that's what I meant (running off memory)

127.0.0.1	penguin.lan penguin localhost.localdomain localhost

is mine... try something like that (might help, probably won't).

----------

## jimmij

Yeah! I added alias localhost.localdomain in /etc/hosts and it works perfectly, thanks!

I've removed also fetchmail and ended with procmail+sendmail, I will not bother to find other solutions anymore  :Wink: 

Thank you all for help!

----------

