Send mail with mail under Linux

Source: Internet
Author: User
Tags aliases auth dovecot

Ways to send mail using an external mailbox

Bin/mail will send mail by default using local SendMail, which requires the local machine to install and start the SendMail service, which is cumbersome to configure and will cause unnecessary

Resource consumption. By altering the configuration file, the external smtpserver can be used to send the message to the external smtpserver without using SendMail:

Change/etc/nail.rc (/etc/mail.rc)

Set [email protected] Smtp=smtp.domain.comset smtp-auth-user=username smtp-auth-password=passwordset smtp-auth=login
Description

From is the e-mail address sent

SMTP is the address of the external smtpserver that occurred

The Smtp-auth-user is an external SmtpServer certified username

Smtp-auth-password is an external smtpserver authenticated user password

Smtp-auth is the way of email authentication

Once the configuration is successful, you can use the

Ability to send an e-mail test:

Mail-s "Test" [email protected] <content.txt in the back of the message header, [email protected] is the recipient address, content.txt inside the message body

Transfer from: http://www.diybl.com/course/6_system/linux/Linuxjs/20091119/182839.html

I tried it, and before 2006, 163 of the mailboxes were available, and Tom's mailbox was able.

Postfix

Postfix is an MTA (mail transfer agent) software developed by Wietse Venema under the GPL of IBM and wants to be a sendmail alternative, trying to become a faster, easier managed, more secure MTA,

Installation:

rpm-ivh/mnt/cdrom/server/postfix-2.3.3-2.i386.rpm Postfix Main Program

rpm-ivh/mnt/cdrom/server/postfix-pflogsumm-2.3.3-2.i386.rpm postfix Log Tool

RPM-IVH/MNT/CDROM/SERVER/DOVECOT-1.0-1.2.RC15.EL5.I386.RPM Pop Program

First check if the Postfix service is installed, use Rpm–qa |grep postfix,

  

I've installed it here, first use rpm–e postfix to remove Postfix, and then install

  

The same, you need to see if there is a pop installed, this service is Dovecotserver, I also installed here, after the removal of the installation can be

  

  

Is it possible to execute directly after installation?

  

Obviously not, some of its necessary parameters are not valid, and some of the following changes are frequently used options:

Hostname the FQDN of the mail host

Mydomain the domain in which the mail host resides

Myorigin domain name when local mail is sent

Mydestinatin local mail receive is a domain name

Port number of the Inet_interface mail host Listener

Mynetworks local mail server trusted network

Relay_domain domain that is passed by local mail server

Smtpd_banner the title displayed at login, it is best to hide the detailed version (add security).

  

  

  

  

  

  

  

  

This is the end of a major SMTP server, of course, to do a lot of things, such as restricted collection, senders, aliases, virtual domain, and so on, the following restart to see how the effect

  

Of course do not forget to change our pop service settings, directly change/etc/dovecot.conf, #protocols = IMAP imaps POP3 pop3s front of the # to remove it, reboot to see:

  

  

Then sign in with our most familiar Outlook,

  

That's weird, isn't it? Postfix set the wrong one? First look at the log:

Tail–f/var/log/maillog

  

This error is Dovecot configuration problem? Ming has directly changed the Dovecot support mail receive method can, why not this time? Try Telnet wudionline.com 25 and Telnet wudionline.com 110 to see

  

  

Also no problem ah, think of the two days before the installation of this configuration is clearly able to login in Outlook Ah, but the first two days is such a situation:

Be able to sign in with Outlook, but Outlook can not receive mail, e-mail, receive e-mail can be seen in the/var/spool/mail, is not receiving local outlook, by the online reference, it is best to #mail_location =mbox:~/ Mail:inbox=/var/mail/%u before the # removed, you can receive mail in the local, after the analysis there because the Dovecot set up the mail receive path is not correct, so change a bit OK, but this is login not up Ah, online search for half a day there is no answer, so try to #mail_ Location =mbox:~/mail:inbox=/var/mail/%u, before the # is removed,

  

Reboot to see

  

The login was successful. Try to collect, send e-mails are no problem.

Usually because the root account of the default receive system various error logs, but with root login personally think not very convenient, so want to use an ordinary user also receive root mail, looked at the configuration help document, in this format can be alias to receive other users ' mail:

Root:wuzh

Of course, you have to write to the/etc/aliases file, so that when the system error or other event log, you will attach a copy of the log to the ordinary user of Wuzh this is not:), changed to send a message directly to root, Then you can see the original message in the Wuzh account.

Another feature: The virtual domain uses a virtual domain name to represent the actual domain to send and receive mail (at my low level, I feel I do not use, it can only be used for internal communication, the assumption that the external mail and send the virtual domain can not be resolved on the WAN, that is, the message is not received at all) I changed my domain name wudionline.com to wudionline.net and sent me a mailbox.

  

The sender's address is changed, but it's hard to reply ... look

  

His advantage is to hide his domain name, so that others can not find him (assuming that someone else to look for his words ...), of course, there are other advantages, I do not know how to use the level of food. And so I learned to update ...

Here's a demonstration of how to set it up:

Add virtual_maps = hash:/etc/postfix/virtual in main.cf, this is the location of the virtual domain, and add content to this file in the format:

Wudionline.net anything

[Email protected] Wuzh

After that, use the Postmap command to generate the virtual domain database:

Postmap/etc/postfix/virtual

The front is the virtual user, followed by the system user, in fact, receiving mail or system users send and receive, just agree with the virtual user to its operation

Postfix part turn from: http://www.webjx.com/server/linux-14673.html

Scripts to send messages on their own initiative

Remember when in school, there was a discussion with the teacher about the problem, there are some ambiguous places, he said, you can make a program to verify. I almost didn't faint. Since then I was very afraid of programming. Just fine, there are a lot of things that we don't need to program to achieve.

For example, I started to get bored between the two computers on the table, so I'm going to write a little shell script, and when the Linux/unix is finished, the system will send an email to Windwos to notify me below.

It's convenient to send messages below Linux and UNIX, assuming that just sending a message, the commands you need are much simpler, just a few different system mail server commands. For me, the computer that often works is HP's C8000 workstation, its system is Hewlett-Packard, and the other is HP, which installs the Redhat as system.

HP-UX mail programs need to enter the following in Terminal: Mail command, then go in to write letters, and Redhat Mail sender is more convenient, just a command to be able to specify the subject, attachments, content:

echo "content:the work was done" | mail-s "the IS subject" [Email protected]

The following script is inferred from whether a file has been generated, assuming that a notification message is sent to the specified mailbox. Otherwise, every 30 seconds to check, there is an end to send notification messages, there is no complete on the sleep after continuing to cycle, until all finished before exiting.


Set Arraya = ($*)
Set I=1
Set SysInfo = ' uname '
Set Arrayb = ()
while ($i <= $ #arrayA)
if (-F ${arraya[$i]}/result_data.txt) Then
if ($SysInfo = = HP-UX) Then
mail [email protected] <<!
Subject: ' ${arraya[$i]} is finished '
' ${arraya[$i]} is finished '
.
!
Else
echo "${arraya[$i]} is finished" | Mail-s "${arraya[$i]} is finished" [email protected]
endif
echo "${arraya[$i]} is finished, a mail was sent to Mwang"
Else
Set Arrayb = ($arrayB $arrayA [$i])
endif

if (($i >= $ #arrayA) && $ #arrayB) Then
Set Arraya = ($arrayB)
echo "$arrayA is under calculation, please wait. Now: "' Date '
Set Arrayb = ()
Set i = 0
Sleep 30
endif
@ i++

End


Transfer from http://www.veryword.com/2008/11/10/auto-send-mail-script.html

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.