Mail command1. directly use shell as the editor
mail -s "Dreamhj Test Mail" xxxxxxxx@qq.comhello i m xxwelcome to www.dreamhj.com
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
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 FilteringThe 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