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? I do not need to register public... information & n how does linux send emails to external mailboxes when using linux? sometimes we want to send emails to friends or colleagues. can I 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. Use wget http://sourceforge.net/projects/heirloom/files/latest/download?source=files Download 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.
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.