# Postfix mail bounce backs to linux hosts

## humbletech99

All my servers use mailx with ssmtp to send email messages via my Postfix mail server for events and scripts. 

I've noticed quite a lot of bounce back messages going from the mail server "MAILER DAEMON" back to each root@host.mydomain.com which of course doesn't get through since there is nothing to receive it on the hosts.

This leaves stuff stuck in the queue until it is dropped by Postfix, the MTA on the mail server. Snort then alerts on these failed connection attempts as port scans which is also annoying.

Is there a way to tell Postfix to not do bounce backs to *.mydomain.com so that the messages are immediately dropped if failed with a notifications to postmaster (which is aliased to me).

I'd also like to know why they are being bounced, is there a way to look inside the emails in the queue?

----------

## mstockin

Look in the file /etc/mail/aliases:

    # Well-known aliases -- these should be filled in!

    root: 

    operator: 

You should fill in aliases for root and operator.

Marv

----------

## humbletech99

they are filled in, it's the bounce backs that are going to root@host.domain.com. If they were going to root@domain.com they would be delivered to me, but the sender's address is root@host.domain.com so if the email bounces for any reason then it is sent back to root@host.domain.com which doesn't exist and just continually tries to smtp the host.domain.com for delivery.

----------

## mstockin

You should set "myorigin = domain.com" in /etc/postfix/main.cf. The default value

of myorigin is '$myhostname'.

You can do this with:  postconf -e 'myorigin = domain.com'

Marv

----------

## humbletech99

it'a already set to that (well $mydomain which defaults to $myhostname minus the first host part which is the same thing)

----------

## magic919

Why not fix this at source.  If you can make sure you only send emails with a valid From address then they'll have somewhere to bounce.

You should be able to check the mail log and see why Postfix is bouncing them.

----------

## mstockin

Do you have tried to set "rewriteDomain" in the ssmtp config file?

----------

## bunder

i did this the hard way.

```
# in main.cf

mydestination = /etc/postfix/networks

```

```
# in file networks

domain.com

internal.domain.com

server.domain.com

server2.domain.com

etc etc etc

```

cheers

edit:  if the ssmtp fix works, use that instead.  i figured this problem was postfix related.   :Laughing: 

----------

## humbletech99

 *mstockin wrote:*   

> Do you have tried to set "rewriteDomain" in the ssmtp config file?

 

I did try the ssmtp config change earlier. I have few servers not running gentoo which I think use stuff like sendmail instead so I'll have to change those separately.

I'll see how it goes.

Thanks

----------

