Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Suppose I run -

mail goldfish

There is no such account on the system and no such aliases defined, where would the mail go?

How do I see a list of such mails?

share|improve this question
    
Is there a mail server running on this system? Your inclusion of dovecot is an imap server, implying that the mail might be on another system, I don't think it's needed for this Q. –  slm Jan 3 at 4:15
    
@slm dovecot removed. I have GNU mailutils package on my system. –  Kshitiz Sharma Jan 3 at 4:28
    
Are you using sendmail or postfix? What's the underlying distro? –  slm Jan 3 at 4:36
    
@slm I think it is postfix. I am on Ubuntu 13.10 –  Kshitiz Sharma Jan 3 at 4:39

2 Answers 2

up vote 2 down vote accepted

The email would be returned to the sender as undeliverable due to lack of a destination address by the mail daemon on the destination server.

share|improve this answer
    
What destination server? This is local email, from one unix account to another. –  Kshitiz Sharma Jan 3 at 4:09
2  
Then the local server is the destination server, and the bounce email will be sent to the originating account. –  DopeGhoti Jan 3 at 4:34
    
As the admin should I be logging into the accounts of every user to see bounced emails? How do I get them redirected to my account? –  Kshitiz Sharma Jan 3 at 4:36
1  
If I, as user@example.com, send an email to no.such.user@example.com (which does not exist), an email will be sent from the mail daemon to the sender (user@example.com) explaining why the message could not be sent using one of these codes to identify the cause. If you want to see the status of all emails handled by your server, grep the mail daemon log in /var/log for the status code in each message handled by the server. –  DopeGhoti Jan 3 at 4:40
    
@KshitizSharma: just look into /var/spool/mail/* , or locate | egrep 'some_user_name|mbox|dead\.letter' or do a test and look new files: touch /tmp/NOW ; mail goldfish ; find / -newer /tmp/NOW -ls [in case you use "exotic" mail systems... timdowtdi] –  Olivier Dulac Jan 3 at 9:08

No mail server running

When I attempt to construct a bogus email on my Fedora 19 system I get the following entry in my system's /var/log/maillog.

$ mail blah@localhost
Subject: test
test
.
EOT

Contents of /var/log/maillog:

$ more maillog
Jan  2 23:16:45 greeneggs sendmail[21847]: s034Gi1W021847: from=saml, size=209, class=0, nrcpts=1, msgid=<201401030416.s034Gi1W021847@gree
neggs.bubba.net>, relay=root@localhost
Jan  2 23:16:45 greeneggs sendmail[21847]: s034Gi1W021847: to=blah@localhost, ctladdr=saml (1000/1000), delay=00:00:01, xdelay=00:00:00, m
ailer=relay, pri=30209, relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]

This would imply to me that the mail sever never accepted the email to begin with, so it's likely being kicked back to the sender or ignored all together, going no where.

Mail server running

With sendmail running.

$ service sendmail start
Redirecting to /bin/systemctl start  sendmail.service

Confirming its started:

$ ps -eaf | grep [s]endmail
root     22157     1  0 23:20 ?        00:00:00 sendmail: accepting connections
smmsp    22173     1  0 23:20 ?        00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue

Repeating the same test:

$ mail blah@localhost
Subject: test2
test
.
EOT

We now get a bounced receipt from the mail server that the address doesn't exist.

...
The original message was received at Thu, 2 Jan 2014 23:28:37 -0500
from root@localhost

   ----- The following addresses had permanent fatal errors -----
blah@localhost
    (reason: 550 5.1.1 <blah@greeneggs.bubba.net>... User unknown)
    (expanded from: blah@localhost)

   ----- Transcript of session follows -----
... while talking to [127.0.0.1]:
>>> DATA
<<< 550 5.1.1 <blah@greeneggs.bubba.net>... User unknown
550 5.1.1 blah@localhost... User unknown
<<< 503 5.0.0 Need RCPT (recipient)
...

This showed up in my user's email spool here: /var/spool/mail/saml.

share|improve this answer
    
That answers my first question. Second was - How do I see a list of such mails? Is it possible to configure postfix to direct all such mails to a given account? –  Kshitiz Sharma Jan 3 at 4:24
    
There is no "list" as you're asking for, you'd have to configure the underlying mail server to keep a copy of any bounces, or grep through the mail server's logs for these incidents. –  slm Jan 3 at 4:37
    
configure the underlying mail server to keep a copy of any bounces is what I'm after. But I think that one deserves a questions of its own. This one is answered. –  Kshitiz Sharma Jan 3 at 4:40
1  
    
You may have answered my question. I get a lot of "User unknown" in sendmail maillog from outside the system but now getting a response from Google like, "stat=Deferred: 421-4.7.0 [107.XXX.XX.XXX 15] Our system has detected a n unusual rate of", which is cut off. Is Google sending that to me or the original mailer? Am I getting myself into trouble with this (the risk of being blocked)? –  Rob Apr 12 at 13:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.