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.

I have an amazon ec2 instance running ubuntu. There are only a couple of user accounts and the server is used to host a small web app. Apparently, by default, each user account has an email account. We do not use these accounts.

Recently I discovered that one of the accounts is receiving "undeliverable message" emails from spam being sent in its name. We're receiving hundreds per hour and we didn't notice until the disk filled up.

Of course we deleted all the emails and in the time it took for the delete to complete we had received 30 more.

The best solution is to disable the email for this account. We want to keep the account though. Is there a way to just remove the email account for a user without affecting the account itself. Googling didn't help me. I only found directions for deleting individual emails or deleting the entire user account.

share|improve this question
add comment

3 Answers

Those emails are handled by your MTA, in ubuntu, it ispostfix. If you don't use the accounts then disabling the service would be what i would recommend.

sudo update-rc.d stop postfix # stops the service

sudo update-rc.d disable postfix # disable the service from starting at boot


Reconfiguring postfix to only listen on the loopback address is also a option. The email spools are still there, but only other users/daemons may mail each other. Edit /etc/postfix/main.cf and change these two options to read

  • inet_interfaces = loopback-only
  • mynetworks_style = host

Then restart postfix with service postfix restart

share|improve this answer
    
Thanks! One problem though is that email is sent by cron jobs running on that server. So we do need email. None of the individual users need email though. –  dl__ Jun 28 '12 at 17:05
    
@dl__ Go with the second option: local mail only. –  Gilles Jun 28 '12 at 23:36
    
I like bahamat's answer more than mine. I think the cronjob is sending email to a remote email account. so local mail won't work for him. –  llua Jun 29 '12 at 4:33
add comment

In addition to the correct answer posted by llua you should set an SPF record for the domain. This will reduce the effectiveness of people trying to forge your return address. It does not prevent the phenomenon, but it greatly reduces the mailers that will receive such mail (all the big webmail services support SPF).

share|improve this answer
add comment

Edit /etc/aliases

Add a line like the following:

user: /dev/null

After saving run newaliases as root.

share|improve this answer
add comment

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.