Linux counterattack: how to use procmail to deal with spam

Source: Internet
Author: User
Article title: Linux counterattack: how to use procmail to deal with spam. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Email is the most important means and tool for communication on the Internet. Since the birth of email, boring spam has become one of the biggest headaches. It is said that the annual losses caused by spam are as high as hundreds of millions of dollars in the world. In the Windows operating system, you may have had enough trouble with spam to prevent it. However, it is very important not to think that in the Linux operating system platform, we can avoid the harassment caused by spam. it is very important to fight back and worry over the emails we don't need. This article describes in detail how to use procmail to deal with spam.
  
Useless emails usually affect our online lives. In Linux, the standard email configuration scheme is Sendmail and POP mail server. Many Linux users have installed Sendmail and POP email servers on their own Linux platforms to receive and send emails. However, Sendmail and POP mail servers serve only as tools for sending emails in Linux, and they cannot deal with more types of spam. There are a lot of software and tools to worry about spam on the Windows platform. most software determines whether an email is spam by taking the subject and name of the email into consideration. However, this approach cannot completely overwrite all the spam, because the spam recipients have long considered this point, they can write the subject of an email similar to that of an ordinary email, or use an anonymous email to send the email. this can easily fool the tool software of spam.
  
In the Linux operating system, we need to configure the procmail program for spam, so that it can overwrite the unwanted emails as much as possible. Whether you are using MTA (Mail transfer proxy, aka Sendmail) or MUA (Mail User proxy, aka Netscape Mail) in Linux ), using procmail can also overwrite spam emails. Procmail does not require additional download and installation. Procmail can be installed by default when you install the Linux system. Procmail is a powerful tool that can be customized. The system administrator can configure Procmail on the client or server to handle annoying spam.
  
  
For example, if you want to worry about all the emails from Bill Gates Microsoft bgates@microsoft.com, you can configure Procmail to make the emails from the bgates@microsoft.com directly sent to the/dev/null directory in Linux. The specific configuration can be referred to as follows:
  
: 0
* ^ From. * bgates@microsoft.com
{
: 0
/Dev/null
}
  
All procmail filters are stored in a file called procmailrc. Procmailrc is saved in the/etc directory, or the file can be found in $ HOME/. procmailrc. You only need to redefine and modify the procmailrc file to make procmail take effect. $ HOME is a variable in the HOME directory for users. The following parameters are common in typical procmailrc files:
  
#
#
# Begin/etc/procmailrc
#
#
  
ORGMAIL/var/spool/mail/$ LOGNAME
MAILDIR $ HOME/
Sendmail/usr/sbin/Sendmail
  
: 0
* ^ From. * bgates@microsoft.com
{
: 0
/Dev/null
}
  
#
# End/etc/procmailrc
#
  
If you are familiar with programming, you will know that the parameters and variables of this file can be changed as needed.
  
The ORGMAIL variable sets the global variable of the Mail directory in the system. The above list indicates that ORGMAIL has specified the user login directory as/var/spool/mail/, and $ LOGNAME is the user login name. MAILDIR specifies the directory where procmail is used and executed. The preceding list shows that MAILDIR is the HOME directory of the ROOT user.
  
As mentioned above, procmail is a powerful anti-spam program. You only need to modify its parameters, which will take effect accordingly. If we don't send all emails from the bgates@microsoft.com directly to the/dev/null Directory, we're like leaving these emails with time to carefully analyze if they're all spam, we can perform the following configuration:
  
: 0
* ^ From. * bgates@microsoft.com
{
: 0
Antitrust
}
  
In this way, the e-mail sent from the bgates@microsoft.com will be saved to a directory called antitrust, of course, it must be modified by the MAILDIR variable to take effect. In order to make the e-mail sent from the bgates@microsoft.com better saved by the Linux system, we can further modify, for example:
  
: 0
* ^ From. * bgates@microsoft.com
{
: 0
Mail/antitrust
}
  
In this way, the antitrust does not need to use the $ HOME/mail directory, and the security factor is higher than the original modification method. The spam you have thought about and your normal emails will not be placed in the same directory. It is not safe to put all the unwanted and useful emails in the/ROOT directory.
  
The above only introduces the method of worrying about the email address. now we can combine the address with the subject and other methods, so that the effect of worrying about spam is better, the following are a variety of methods to take spam into account:
  
: 0
* ^ From. * bgates@microsoft.com
* ^ Subject:. * competition
{
: 0
Mail/antitrust
}
  
From the list above we can see that this time we can not only worry about emails from the bgates@microsoft.com, but also as long as the e-mail with the word "competition" in the subject mail is also ignored. Of course, you can set the subject of an email based on your actual needs, not only to limit the word competition. Emails meeting the preceding conditions will be sent to the specified region of mail/antitrust.
  
Sometimes we need to forward some emails. at this time, we can also do this through the following configuration:
  
: 0
* ^ From. * bgates@microsoft.com
* ^ Subject:. * competition
{
: 0 c
  
! Justicedept@us.gov
  
: 0
Mail/antitrust
  
}
  
As you can see from the list above, emails from the bgates@microsoft.com with "competition" will be forwarded to the justicedept@us.gov by the Linux system, and these emails will also be sent to the mail/antitrust.
  
The following configurations are also very useful:
  
: 0
* ^ From. * bgates@microsoft.com
* ^ Subject:. * competition
{
: 0 c
  
! Justicedept@us.gov
  
: 0
Mail/antitrust
  
}
  
: 0
* ^ From. * sexcity
{
  
: 0
/Dev/null
  
}
  
The parameters in the first line are well understood, and the second line is to send emails from sexcity to/dev/null.
  
From the above configuration list, we can see that it is not difficult to configure procmail, but you still need to note that if you encounter an error when configuring procmail, then you may destroy the email configuration in the entire system. do not forget to test the system after configuring procmail.
  
Finally, we would like to remind you that procmail is a powerful anti-spam program, but we also need to follow the basic principles of Sendmail and cannot modify the procmail parameters at will, otherwise, the system that sends emails in Linux may not work normally. if you encounter any problem in configuring anti-spam, please go to the Sendmail homepage to view the FAQ, there are many solutions to this problem.
  
Reference URL:
  
Sendmail:
Http://www.sendmail.org
Procmail:
Http://www.procmail.org
  
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.