Use the mail command in CentOS to send emails

Source: Internet
Author: User
Tags reverse dns sender policy framework

Use the mail command in CentOS to send emails
Concepts

Email user proxy (MUA, Mail User Agent)
Email sending proxy (MTA, Mail Transport Agent)
Mail Distribution agent (MDA, Mail Deliver Agent)
Mail commands andThe mailx command is used to view, write, and send emails to the MTA. Mailx is an enhanced version of mail.
Sendmail is the MTA responsible for transmitting mails over the network. It transfers mails from one MTA to another.

I use CentOS 6.6 With the mail and sendmail commands. After testing, qq mail can receive emails, which may be intercepted and put into Spam. After several attempts, it can be received several times later. It is estimated that it is recognized as trusted by the firewall.
163 email addresses are intercepted directly, and nothing is displayed, and no spam is displayed.

Mail command

1. directly use shell as the editor

mail -s "Dreamhj Test Mail" xxxxxxxx@qq.comhello i m xxwelcome to www.dreamhj.com
  • 1
  • 2
  • 3

The first line is the input command,-s indicates the subject of the mail, followed by the admin@mzone.cc is the recipient of the mail, enter this line of command and press enter, will enter the body of the mail writing, we can enter any text, such as the above two lines. After entering the body of the email, press CTRL + D to complete the input. At this time, you will be prompted to enter the Cc address, that is, the Cc address. If you do not press enter, the email will be sent. The recipient is in the root@hjcentos.localdomain format

2. Send echo "hello I m xx" via MPs pipeline | mail-s "Dreamhj Test Mail" xxxxxxxx@qq.com

3. Use a file to send mail-s "Hello from mzone. cc by file" xxxxxxxx@qq.com <mail.txt

Because the mail program itself is to call sendmail to send mail, sendmail will use the hostname of the local server to enter the sender, generally in root@xxxx.localdomain format, but the mainstream mail service providers will intercept this mail.

Solution: We can configure the mail command to use the external SMTP service. The following uses the 163 mailbox as an example: vim/etc/mail. rc Add the following configuration at the end:

Set from = Email username @ 163. comset smtp = smtp.163.comset smtp-auth-user = Email username set smtp-auth-password = password set smtp-auth = login
  • 1
  • 2
  • 3
  • 4
  • 5

Mail-s "Dreamhj" xxxxxxxx@qq.com to check the inbox, found that the mail sender changed to: xxx@163.com

Send the attachment, directly add the-a parameter to mail-s "Dreamhj"-a/root/test.txt xxxx@qq.com <test.txt

Email Filtering

The email service provider may passSPF, DKIM, DMARC, Reverse Address Resolution, and other technologies are used to filter spam.

  • SPF (Sender Policy Framework) Sender Policy Framework. The SPF record is a DNS record of the server. Principle: The Mail Server received an email, ip 112.112.112.112, domain name for the test@test.com. The email server will query the SPF record of test.com to confirm that the email is not forged. If the SPF record under this domain name allows hosts with IP address 112.112.112.112 to send emails, this email is valid. If it does not comply with the rules, the email will be returned.

  • DKIM (DomainKeys Identified Mail) domain name key recognition email standard. The basic working principle of DKIM is also based on the traditional key authentication method, which generates two sets of keys, public key and private key ), the Public Key is stored in DNS, and the private key is stored in the sender server. The digital signature is automatically generated and attached to the mail header and sent to the sender's server. The Public Key is placed on the DNS server for automatic access. The receiving server will receive the signature in the mail header and obtain the public key on the DNS, and then compare it to compare whether the sender's domain name is legal. If it is illegal, it is determined as spam.

  • DMARC (Domain-based Message Authentication, Reporting and Conformance) Domain name-based email Authentication, Reporting, and consistency. DMARC is mainly used to set "policies ". This policy contains what actions should be performed when an email from this domain is not authenticated. Option: do not perform the operation ("NONE"), put the email in the "Quarantine Area" or "reject" the email. The domain can be fully protected only when the "deny" policy is used. The second function of DMARC is to allow the ISP to send a report about the successful or failed domain authentication. These reports will be sent to addresses defined in "rua" (Summary Report) and "ruf" (forensic report.

  • Reverse Domain name resolution System (Reverse DNS ):. The A Record is resolved by the domain name to get the address, and the PTR (Point Record) Record is resolved by the address to get the Domain Name

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.