How does one send emails to external mailboxes in linux?

Source: Internet
Author: User
Tags mx record

In linux, how does one send emails to external mailboxes and use linux? Sometimes, if we want to send emails to friends or colleagues, can we send them directly through the command line? How can I use a script to send an email to an external mailbox if I want to monitor the website or system status through linux and automatically trigger an alarm? You do not need to register a public domain name or MX record, that is, you do not need to set up a public email server. We can still achieve the above purpose. I solve this problem through the mailx tool that comes with linux. You only need to configure mailx to use a public email address to send emails. The mailx version of CentOS5 is 8.1. You cannot configure an external public email address. You must upgrade it to the latest version 12.4. You can use rpm-qa | grep mailx to view the built-in mailx version. Using wget http://sourceforge.net/projects/heirloom/files/latest/download? Source=filesdownload the latest mailx-12.4.tar.bz2 (271.5 kB ). # Tar jxvf mailx-12.4.tar.bz2 # cd mailx-12.4 # make install UCBINSTALL =/usr/bin/install so that the installation is complete. If the old version of mailx is not uninstalled, you cannot directly use the mailx or mail command. Otherwise, the old version of mailx is used. The new version of mailx is in the extracted mailx-12.4 folder, that is, the call path is: extract path/mailx-12.4/mailx. For example, if I decompress under/root/, then I want to use the new version of mailx and view the version number, you can view it with/root/mailx-12.4/mailx-V. To make the new mailx version easier to use, we can use alias and. bashrc directs the mail command to the new mailx: Edit. bashrc: vi/root /. bashrc add a line: alias mail = '/root/mailx-12.4/mailx' immediate effect: source/root /. bashrc then the mail command represents the new version of mailx. Next, configure the new mailx version to send emails using an external mailbox: edit/etc/nail. rc (note that it is not the old version of/etc/mail. rc): vi/etc/nail. rc adds two rows: set from = myname@qq.com smtp = smtp. qq. comset smtp-auth-user = myname smtp-auth-password = password smtp-auth = the first line of login indicates the used external mailbox and smtp server, the second line specifies the username and password used by the external mailbox. Save and restart the sendmail service (service sendmail restart ). At this point, you can directly send an email to an external email address through the command line: # echo 'Hello! '| Mail-s "hello test" ymwugui@qq.com to the external mailbox to see, the mail immediately received. The alarm script is well written on this basis.

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.