Install Sendmail on Ubuntu and send the hard disk space information to the specified mailbox

Source: Internet
Author: User
Tags squirrelmail
1. Install the sendmail function in Ubuntu to send emails conveniently. You need to install two packages for ubuntusendmail. Two packages that must be installed: sudoapt-getinstallsendmailsudoapt-getinstallsendmail-cf. the following packages are optional: squirrelmail

I. Installation

The sendmail function in Ubuntu can easily send emails. Two packages must be installed in ubuntu sendmail.

Two packages that must be installed:

Sudo apt-get install sendmail

Sudo apt-get install sendmail-cf

The following packages are optional:

Squirrelmail // provides webmail

Spamassassin // provides Email filtering.

Mailman // provides support for the mail list

Dovecot // provides the IMAP and POP receiving email server daemon process

Note:

To use the most common mail function in Ubuntu, you must install mailutils,

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

By default, sendmail only sends emails to local users. Only by extending sendmail to the Internet can it become a real mail server.

Open the configuration macro file of sendmail:/etc/mail/sendmail. mc

Vi/etc/mail/sendmail. mc

Find the following line:

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

Modifying Addr = 0.0.0.0 indicates that the server can be connected to any server.

Generate a new configuration file:

# Cd/etc/mail

# Mv sendmail. cf sendmail. cf ~ // Make a backup

# M4 sendmail. mc> sendmail. cf //> is left or right with spaces. If an error is reported, sendmail-cf is not installed.

3. test email sending

Frequently Used email sending methods are as follows:

1. How to Write a general mail: mail test@126.com Cc edit Cc object, Subject: mail Subject, enter the carriage return, 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

Installation command: sudo apt-get install mailutils

To use the function with attachments, you also need to install sharutils,

Installation command: sudo apt-get install sharutils; (yum install sharutils)

Implement a small function (send the space information of the hard disk to the specified mailbox through shell. In this case, you can use a scheduled task to send the desired server information to the mailbox every day .)

Root @ liujie-VirtualBox:/home/postgres/shell # vim SendMail. sh

#! /Bin/bash

Df-hl> data.txt

Mail-s sendMail 751247j439@qq.com <data.txt

We can use crontab for a scheduled task, which is perfect.

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

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.