Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SMTP on Linux 2

Status
Not open for further replies.

Noip

IS-IT--Management
Apr 25, 2002
240
0
0
MU
Hi,

My clients used to use my win2k server in the past as a SMTP server which takes care of sending all mails. The POP server for the clients was outside the LAN.

Now my server is running RH8.0. I would like to know if there is an easy step (like in w2k) to use the Linux server to send the emails from my clients.

 
Sure. Install package named Postfix. Or Sendmail, if you are brave.
 
Using Sendmail is Easy.
---This bit is optional
If you want to make technical changes to the sendmail.cf file you modify the sendmail.mc file then re-compile it using the m4 macro compiler, this is only needed if you want to add stuff like spamcop, masquerading etc.
You need to have the sendmail-cf RPM installed to use the M4 compiler, you can check what (sendmail) rpms you have installed with this command:
rpm -q -a | grep sendmail

get sendmail.cf from your redhat 8 disks or from rpmfind.net.

see for details on M4
--------------
Set the ip address range of your LAN in /etc/mail/access
eg if your lan is 192.168.5.0/255.255.255.0 and domain is mydomain.com
add
192.168.5 RELAY
mydomain.com RELAY

Edit the sendmail.cf file /etc/mail/sendmail.cf and find the line
O DaemonPortOptions=Port=smtp,Addr=127.0.0.1, Name=MTA

insert a "#" at the beginning to comment it out, note if
you use the M4 macro compiler you can take out the loopback restriction by removing the macro defination before recompiling sendmail.cf, this way short circuits that process though.

If you want the mail for mydomain.com to be delivered to local users, add it to /etc/mail/local-host-names. Once a domain is listed in /etc/mail/local-host-names then you can use the virtualusrtable in /etc/mail to map email addresses to users or aliases.
The virtusrtable has the format:
joebloggs@mydomain.com joeb

where joebloggs@mydomain.com maps to user or alias joeb,

a line like
@mydomain.com joec

maps all mail not included in other mappings in the virtusrtable to joec .

if joec is in /etc/aliases like this:

joec: joec@aol.com, joed, joef

Then email to joec goes to joec@aol.com, local user joed and local user joef, if the alias line looked like this:
joec: joec, joec@aol.com

mail would go to a local user called joec (who has the same name as the alias) and to joec@aol.com

After modifying these settings you can do a service sendmail restart to apply changes, if you want to just update the virtusrtable settings or access settings, just go to /etc/mail dir and type "make" an ls -lrt will show you which .db files were recreated (last in the list). A newaliases command rebuilds the just aliases file.

If mail for mydomain.com is to beforwarded to an internal mailserver call internal.mydomain.com and not delivered to the localmachine, make sure mydomain.com is not in /etc/mail/local-host-names and add an entry in the /etc/mail/mailertable like this:

mydomain.com relay:internal.mydomain.com

don't forget to do a "make" from /etc/mail or a service sendmail restart after this.

you can test where mail is actually going to go by using the command

sendmail -bv username@mydomain.com sendmail will reply telling you if the mail is going to a local user, or being relayed on for example - a very useful debugging tool.

In summary:

If the domain is in local-host-names, mail is processed via the virtusrtable and aliases files.
If its not, then it is process via the mailertable etc.
the access file controls how mail is relayed.

Use the M4 macro compiler to create custom sendmail.cf files (advanced use)

If you have any questions about sendmail just ask, and I'll answer if I can.

Postfix in my opinion is not an entreprise mail mta, use of exmim or sendmail is by far the best choices (thats why most people use them)

regard

PEte
 
PEte, I have not tried it yet but I am sure I will be able to implement an SMTP server on Linux very easily with all your detailed explanations. It seems to be very clear and I think all linux newbies like me will be able to migrate to Linux very easily with this kind of answer.

Thank you.
 
Thanks again Pete,

I am actually using sendmail as SMTP to send mail to the internet world. But how do I set sendmail to advice me in case the mails are undelivered. Thanx
 
error messages usually go to the postmaster which is aliased to root. You can in turn, alias root to your regular user name.
 
Thanks for your input!

But like I'm telling you, I am not using sendmail for internal purpose. I am using an Internet POP3 server. I am a bit confused when you are talking about aliasing root to that user. Is it really possible? If so, can you specity how?

If not I think there should be a conf file where I could mention for ex: BAD MAILS: myacount@domain.com
 
No you may not be but the mails will still come back and get delivered to the default account on that server
 
All servers on your system keep logs. By default RedHat has setup a script called logwatch that reads all your server logs at midnight (cron job) and e-mails the most important stuff to root. If you looked in /var/spool/mail/, you would see a file with each of your user's names in there, including root. If you don't see a file for a person, that means they never received any mail. All mail for each user gets put into one file so when you look in /var/spool/mail/root, your gonna see a lot of e-mails in there if ya never checked the mail yet. The mails sits there until it is popped. RedHat comes with a pop3 server that runs as a daemon under xinetd. There is no configuration. You just have it start at boot up. You can create a second account in Outlook for root@yourdomain.com or you can alias it to your regular user account. To do that you would open /etc/aliases with your favorite text editor. Way near the bottom you will see a line that looks like this:

root: marc

This means that marc will get all roots mail. If your name ain't marc, the change it to something like this:

root: noip

after you are done and have closed the file, you need to type "newaliases" at the command line so sendmail will know ya made some changes to that file. There is an even better way to do things if ya got a minute. It works a lot like aliases but you can redirect entire domains to another domain or e-mail address. It's called the virtusertable. It allows you to do stuff like the following:

webmaster@mydomain.com noip
admin@mydomain.com noip@my-isp.net
noip@mydomain.com noip
@mydomain.com error:nouser User Not Found

The first two are virtual users because they don't actually have user accounts on your system. Webmaster will go to your regular user account. Mail for admin will go to you at your hotmail account. I added this so all users will be defined - see the last example. This is a good one. If mail comes in that does not match anything defined so far, an error message will be sent back to the sender with the message "User Not Found". If you use that one make sure all your users are listed. Before sendmail can use the virtusertable, it must be compiled:

makemap hash /etc/mail/virtusertable.db < /etc/mail/virtusertable

If you want to see the raw mail logs, you can find them in /var/log/maillog.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top