# mailq shows undesired messages

## Fred Krogh

mailq is showing things like *Quote:*   

> -Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
> 
> 540993C007B     4344 Wed Sep 14 01:11:06  MAILER-DAEMON
> 
>          (connect to uc0092.uhbgy.info[61.97.170.92]:25: Connection timed out)
> ...

 

I think I have postfix configured so that it should drop messages that are neither sent to or from my domain.  That is not the case for these messages.  Is there something I might add to the postfix configuration or my firewall, or does it look like a reinstall is necessary?  In the latter case, suggestions on how to ease the pain of doing a complete reinstall would be welcome.  Thanks,

   Fred

----------

## grimm26

Since you didn't say how you might have configured postfix to "drop messages that are neither sent to or from my domain" I'll show you my suggestion:

/etc/postfix/transports:

```

yourdomain.com :

* error:No Spam Allowed

```

/etc/postfix/main.cf:

```

transport_maps = hash:/etc/postfix/transports

```

This will bounce emails not send to or from your domain.  I you want silent discards, you need to use smtpd_recipient_restrictions.

----------

## Fred Krogh

Thanks for the suggestion, but something is missing in either my configuration or your suggestion.  With the changes you suggested I couldn't even send mail to myself.

----------

## grimm26

check your logs and use swaks to test

----------

## Fred Krogh

Sorry, this is a bit too cryptic for me.  I have of course looked at log files, but this did not illuminate anything to me.  Maybe I need to know what to look for?  I have just emerged swaks, but a look at the man page does not suggest to me how it would help with the problem I have.  Could you use a few more words?  Thanks,

 Fred

----------

## grimm26

sorry.  swaks is very helpful because it gives you a direct view into its SMTP traffic.  You can test your config by using:

```
swaks --to dude@baddomain.com --from me@gooddomain.com --server localhost

```

You'll see what it tells the server and what the server tells it.  If things are good, you *should* see the server reject the email.  If it just accepts it, then something is wrong with your config.

A view into your main.cf would be helpful, too.  Maybe post the output of

```
egrep -v '\#|^$' /etc/postfix/main.cf

```

----------

## Fred Krogh

This is starting to look very helpful!  *Quote:*   

> 

 # swaks --to dude@baddomain.com --from me@gooddomain.com --server localhost 

=== Trying localhost:25...

=== Connected to localhost.

<-  220 mathalacarte.com ESMTP Postfix

 -> EHLO mon1

<-  250-mathalacarte.com

<-  250-PIPELINING

<-  250-SIZE 50000000

<-  250-VRFY

<-  250-ETRN

<-  250-ENHANCEDSTATUSCODES

<-  250-8BITMIME

<-  250 DSN

 -> MAIL FROM:<me@gooddomain.com>

<-  250 2.1.0 Ok

 -> RCPT TO:<dude@baddomain.com>

<-  250 2.1.5 Ok

 -> DATA

<-  354 End data with <CR><LF>.<CR><LF>

 -> Date: Wed, 14 Sep 2011 12:37:10 -0700

 -> To: dude@baddomain.com

 -> From: me@gooddomain.com

 -> Subject: test Wed, 14 Sep 2011 12:37:10 -0700

 -> X-Mailer: swaks v20100211.0 jetmore.org/john/code/swaks/

 ->  *Quote:*   

> 
> 
>  -> This is a test mailing
> 
>  -> 
> ...

 So the mail was deferred rather than rejected.  So maybe main.cf tells where I've gone wrong? *Quote:*   

> # egrep -v '\#|^$' /etc/postfix/main.cf 
> 
> queue_directory = /var/spool/postfix
> 
> command_directory = /usr/sbin
> ...

 

----------

## grimm26

it didn't get deferred.  It got queued like normal mail.  There is nothing in your config to do what you described as what you want to accomplish.  My suggestion will work assuming you substitute "yourdomain.com" with your actual domain.

----------

## Fred Krogh

O.k., it got queued in the "deferred" directory.  But that mail was going to an outside domain (sort of) from another outside domain.  These are the ones that are causing the problem.  If the mail is from me I do want it to get queued.

I don't understand your reference to "yourdomain.com" as that has not appeared previously.  I think you have the answer I'm looking for, but we are not quite there.  Many thanks for your help on this.

Fred

----------

## Fred Krogh

I think I finally understand what needed to be done to do what you suggested.  I changed the name of the file from transports to transport just to align it better with documentation I found.  The missing step was to run *Quote:*   

> postmap /etc/postfix/transport

 At least after doing this I can send mail to myself which I couldn't to before.  And the example you gave no longer queues mail, thus *Quote:*   

>  # swaks --to dude@baddomain.com --from me@gooddomain.com --server localhost
> 
> === Trying localhost:25...
> 
> === Connected to localhost.
> ...

 Which seems to be doing the desired thing.  I'll just need to wait a bit and see if I'm still getting new garbage getting into the mail queue.  Thanks,

Fred

----------

## Fred Krogh

Still not fixed.  The fix suggested lets me receive mail and kills the messages going elsewhere.  But it won'd let me send mail elsewhere.  Ideally a solution would let any mail originating in mynetworks go out to any address and mail form any address to this machine be accepted.  Is this possible?  Thanks,

   Fred

----------

