Send mail with mail under Linux __linux

Source: Internet
Author: User
Tags auth dovecot

ways to send mail using external mailboxes

Bin/mail will use the local sendmail to send mail by default, which requires local machines to install and start the SendMail service, is cumbersome to configure, and can cause unnecessary

Resource occupancy. By modifying the configuration file, you can use an external SMTP server to send mail with an external SMTP server without using SendMail:

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

Set from=fromuser@domain.com smtp=smtp.domain.comset smtp-auth-user=username smtp-auth-password=passwordset Smtp-auth=login
Description

From is the mailing address sent

SMTP is the address of the external SMTP server that occurred

Smtp-auth-user is the user name authenticated by the external SMTP server

Smtp-auth-password is an external SMTP server authenticated user password

Smtp-auth is the way of email authentication

Once the configuration is successful, you can use the

You can send an e-mail to test:

Mail-s "Test" user@sohu.com <content.txt where the-S is the message header, User@sohu.com is the recipient's address, Content.txt is the message body

The above is transferred from: http://www.diybl.com/course/6_system/linux/Linuxjs/20091119/182839.html

I tried a, 2006 before the registered 163 mailbox can be, Tom Mail can be

postfix

Postfix is the MTA (Mail transfer agent) software developed by Wietse Venema under the IBM GPL protocol, and wants to be a sendmail replacement, trying to be a faster, easier to manage, 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 Logging Tool

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

First check to see if the Postfix service has been installed, using RPM–QA |grep postfix,

  

I am here to be loaded, here first remove the postfix with Rpm–e postfix, and then install

  

Similarly, need to see if there is a pop, this service is Dovecot server, I also installed here, remove and reinstall can

  

  

Is it possible to run it directly after installation?

  

Obviously not, some of its necessary parameters are not valid and cannot be run, and here are some common options to modify:

Hostname the FQDN of the mail host

Mydomain the domain where the mail host is located

Myorigin the domain name when local mail is sent

Mydestinatin Local mail reception is a domain name

Inet_interface the port number on which the mail host listens

Mynetworks a trusted network of local mail servers

Relay_domain the domain that the local mail server passes

Smtpd_banner the title displayed when you log in, it is best to hide the specific version number (increase security)

  

  

  

  

  

  

  

  

This completes a basic SMTP server, of course, there are many things to do, such as restricting the collection, sender, alias, virtual domain, and so on, the following restart to see how the effect

  

Of course do not forget to modify our Pop service settings, directly modify/etc/dovecot.conf, #protocols = IMAP imaps POP3 pop3s front of the # can be removed, restart to see:

  

  

And then log in with our most familiar Outlook,

  

It's weird, isn't it postfix set wrong? Look at the log first:

Tail–f/var/log/maillog

  

This error is the Dovecot configuration problem? Clearly before the direct modification of the Dovecot support mail reception method on the line, why not this time? Try Telnet wudionline.com 25 and Telnet wudionline.com 110 see

  

  

There are no problems ah, think about the last two days when this configuration is clearly can be logged in Outlook Ah, but the first two days is this situation:

You can log in with Outlook, but Outlook can not receive the mail, mail, e-mail can be seen in the/var/spool/mail, is not receiving local outlook, online reference, the best to #mail_location = mbox:~/ Mail:inbox=/var/mail/%u before the # removed, you can receive mail in the local, after analysis there because Dovecot set the message to receive the path is not correct, so change a bit OK, but this is not go up ah, online looking for a half-day also have no answer, so try to put #mail_ Location = Mbox:~/mail:inbox=/var/mail/%u, before the # removed,

  

Reboot, look.

  

The real login was successful. Try to collect and send the mail is no problem.

Usually because the root account defaults to receive system various error log, but with root login personally feel not very convenient, so want to use an ordinary user also receive to root mail, look at the configuration help document, in such a format can be aliased way to receive other users of the message:

Root:wuzh

Of course, to write/etc/aliases file, so when the system error or other event log, will attach a copy of the log to Wuzh the ordinary user this is not a screenshot:, after the change directly sent an email to root, And then you can see the original message in the Wuzh account.

There is also a function: The virtual domain uses a virtual domain name to represent the actual domain to send and receive mail (at my low level, I feel that I do not use, it can only be used for internal communication, if with the outside world to send and receive mail when the virtual domain can not be implemented in the WAN resolution, that is, do not receive mail, As shown in figure: I changed my domain wudionline.com into a wudionline.net letter to my other mailbox

  

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

  

His advantage is to hide his domain name, so that other people can not find him (if you are worried about someone else to find him ...), of course, there are other benefits, my level food is still not known how to use. 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 the file in the format:

Wudionline.net anything

Wuzh@wudionline.net Wuzh

Then, use the Postmap command to generate the virtual domain database:

Postmap/etc/postfix/virtual

The front is a virtual user, followed by the system users, in fact, mail or system users send and receive, but only allow virtual users to operate it

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

scripts for automatically sending messages

Remember when in school, there was a discussion with the teacher, there are some do not understand the place, he said, you can be programmed to verify. I almost didn't faint. Because then I was very afraid of programming. But fortunately, there are many things we do not need to program to achieve.

For example, recently, I began to tire of the two computers on the table, so I decided to write a small shell script, when the Linux/unix under the completion of the work, the system automatically sent a message to Windwos below notify me.

Sending mail under Linux and Unix is handy, and if you're just sending a message, the commands you need are simpler, except that different system mail server commands are slightly different. For me, the computer that I work with is HP's C8000 workstation, it has HP-UX, and it's also a Hewlett-Packard, which installs the Redhat as system.

HP-UX mail programs need to enter under Terminal: Mail command, and then go in to write a letter, and Redhat Mail sending program is more convenient, as long as a command can specify the subject, attachment, content: echo "content:the work are Done" | Mail-s "This is subject" mwang@veryword.com

The following script is judged by whether a file has been generated and sends a notification message to the specified mailbox if it is generated. Otherwise, check every 30 seconds, have completed on the Send notification mail, there is no completed on the sleep after the cycle, until all finished and then quit.


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 mwang@veryword.com <<!
Subject: ' ${arraya[$i]} is finished '
' ${arraya[$i]} is finished '
.
!
Else
echo "${arraya[$i]} is finished" | Mail-s "${arraya[$i]} is finished" mwang@veryword.com
endif
echo "${arraya[$i]} is finished, a mail are sent to Mwang"
Else
Set Arrayb = ($arrayB $arrayA [$i])
endif

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

End
Transferred 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.