Install and configure sendmail in Ubuntu, using tusendmail

Source: Internet
Author: User

Install and configure sendmail in Ubuntu, using tusendmail

Because the project requires an email server function and there are various restrictions on using the existing enterprise mailbox, it is a great deal of related things. Generally, there are several options, such as Postfix, sendmail, and qmail. I used the first one before, but the project only needs to send emails, and somehow I chose sendmail. It turns out that I still don't want to do it, I will summarize some of my experiences and hope that you will be able to step down.

I. Installation

Required:

  1. Sudo apt-get install sendmail
  2. Sudo apt-get install sendmail-cf
  3. Sudo apt-get install mailutils

Optional:

  1. Squirrelmail // provides webmail
  2. Spamassassin // provides Email filtering.
  3. Mailman // provides support for the mail list
  4. Dovecot // provides the IMAP and POP receiving email server daemon process
  5. Sharutils // provides the function with attachments

Terminal input command: ps aux | grep sendmail
The output is as follows:

Root 20978 0.0 0.3 8300 1940? Ss sendmail: MTA: accepting connections
Root 21711 0.0 0.1 3008 776 pts/0 S + grep sendmail

It indicates that sendmail has been installed successfully and started.

Ii. Configuration

(1)/etc/mail/sendmail. mc

(A) configure sendmail to connect to any server

DAEMON_OPTIONS ('family = inet, Name = MTA-v4, Port = smtp, Addr = 127.0.0.1 ') dnl modify Addr = 0.0.0.0

(B) Add auth configuration (note that the character string is not a single quotation mark, but a symbol on the wave key in the keyboard)

TRUST_AUTH_MECH ('external DIGEST-MD5 CRAM-MD5 login plain ') dnl
Define ('confauth _ MECHANISMS ', 'external GSSAPI DIGEST-MD5 CRAM-MD5 login plain') dnl

(C) Enable access_db and trust_users

Add FEATURE (use_ct_file)

Modify FEATURE ('Access _ db', 'skip') dnl to FEATURE ('Access _ db') dnl

(2)/etc/mail/access

Add the IP address of the email server to the file in the following format: Connect: your_ip RELAY

Then update access_db: makemap hash/etc/mail/access. db </etc/mail/access

(3)/etc/mail/trusted-users

Add the IP address of the email server to the file in the following format:

Finally, a new configuration file is generated:

  1. Cd/etc/mail
  2. Mv sendmail. cf sendmail. cf ~ // Make a backup
  3. M4 sendmail. mc> sendmail. cf //> is left or right with a space. The system prompts that the sendm is not installed due to an error.
To prevent other email servers from putting emails into Spam, you can add an spf record by adding a TXT record in the domain name DNS management. The content is similar

"V = spf1 ip4: 67.202.107.106-all", modify/etc/host at the same time, add the mail server domain name and host name after 127.0.0.1 localhost

Iii. Test

(1) local test

1. General mail: mail test@126.com Cc edit Cc object, Subject: mail Subject, Enter, mail body, press Ctrl-D to end

2. Fast sending method: echo mail body | mail-s mail subject test@126.com

3. Send the mail as the body of the mail: mail-s test test@126.com <test.txt

4. send an email with an attachment: uuencode attachment name: attachment display name | mail-s mail subject sending Address

Example: uuencode test.txt | mail-s Test test@126.com

(2) Other machine tests

#-*-Coding: UTF-8 -*-

Import smtplib

From email. mime. text import MIMEText

From email. mime. multipart import MIMEMultipart

If _ name _ = "_ main __":

To = "to email addr"

Me = "your email addr"

Content = "test"

Msg = MIMEMultipart ('alternative ')

Msg ['subobject'] = "test"

Msg ['from'] = me

Msg ['to'] =

Part2 = MIMEText (content, 'html', _ charset = 'utf-8 ')

Msg. attach (part2)

Try:

Server = smtplib. SMTP (your email server)

Server. sendmail (me, to, msg. as_string ())

Server. quit ()

Except t Exception, e:

Print e

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.