Sendmail บน Fedora Core 3

Sendmail บน Fedora Core 3

การทดลองนี้สามารถส่ง mail ไปยังเมล์ต่าง ๆ ได้ รวมถึง back up ข้อมูลที่ทำการส่งมาเก็บใน /etc/spool/mail/root

เริ่มกันเลยครับ.....
download file จาก http://dag.wieers.com/packages/sendmail
เลือกที่
sendmail-cf-8.12.8-9.1.rh73.dag.i386.rpm

         ติดตั้ง sendmail ด้วยคำสั่ง
[root@li8 ~]# rpm -ivh sendmail-cf-8.12.8-9.1.rh73.dag.i386.rpm
warning: sendmail-cf-8.12.8-9.1.rh73.dag.i386.rpm: V3 DSA signature: NOKEY, key ID 6b8d79e6
Preparing... ########################################### [100%]
package sendmail-cf-8.13.1-2 (which is newer than sendmail-cf-8.12.8-9.1.rh73.dag) is already installed

[root@li8 ~]# cd /
[root@li8 /]# rpm -q sendmail-cf
sendmail-cf-8.13.1-2

เข้าไปแก้ไขค่า Macro ในไฟล์ sendmail.cf
[root@li8 /]# vi /etc/mail/sendmail.cf

##################
# local info #
##################

# my LDAP cluster
# need to set this before any LDAP lookups are done (including classes)
#D{sendmailMTACluster}$m

Cwlocalhost linux linux.net linuxstep.com <-- เพิ่มส่วนนี้ด้วยครับ
# file containing names of hosts for which we receive email
Fw/etc/mail/local-host-names

# my official domain name
# ... define this only if sendmail cannot automatically determine your domain
#Dj$w.Foo.COM
linuxstep .com <-- เพิ่มส่วนนี้ด้วยครับ
CP.

# "Smart" relay host (may be null)
DSmailserver.eve.co.th<-- เพิ่มส่วนนี้ด้วยครับ

[root@li8 /]# setup
แล้วเลือกที่ System services -> sendmail [OK]

แก้ไขไฟล์ที่ /etc/mail/access
[root@li8 /]# vi /etc/mail/access

เพิ่มส่วนของ โดเมน IP Address


 

พิมพ์คำสั่งนี้เพื่ออัพเดทข้อมูล
[root@li8 /]# makemap hash /etc/mail/access < /etc/mail/access

แก้ไขไฟล์ /etc/aliases
[root@li8 /]# vi /etc/aliases

# Aliases in this file will NOT be expanded in the header from
# Mail, but WILL be visible over networks or from /bin/mail.
#
# >>>>>>>>>> The program "newaliases" must be run after
# >> NOTE >> this file is updated for any changes to
# >>>>>>>>>> show through to sendmail.
#

# Basic system aliases -- these MUST be present.
mailer-daemon: postmaster
postmaster: root
bj: linuxstep       <-- เพิ่มส่วนนี้ด้วยครับ

# General redirections for pseudo accounts.
bin: root
daemon: root
adm: root
lp: root
sync: root
shutdown: root
halt: root
mail: root

พิมพ์คำสั่งนี้เพื่ออัพเดทข้อมูล
[root@li8 /]# newaliases

[root@li8 /]# cd root
[root@li8 ~]# useradd user_1
[root@li8 ~]# echo thailinux |passwd user_1 --stdin
Changing password for user user_1.
passwd: all authentication tokens updated successfully.
[root@li8 ~]# useradd user_2
[root@li8 ~]# echo thailinux |passwd user_2 --stdin
Changing password for user user_2.
passwd: all authentication tokens updated successfully.

[root@li8 ~]# service sendmail start
Starting sendmail:
[root@li8 ~]# ps -ef |grep mail
root 2259 1 0 13:07 ? 00:00:00 sendmail: accepting connections
smmsp 2269 1 0 13:07 ? 00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root 3827 3379 0 14:30 pts/1 00:00:00 grep mail
[root@li8 ~]# netstat -na | grep 25
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
unix 3 [ ] STREAM CONNECTED 12025
unix 3 [ ] STREAM CONNECTED 11725 /tmp/.X11-unix/X0
unix 2 [ ] DGRAM 8825

ทำการทดสอบด้วย telnet
[root@li8 ~]# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 li8.evekm08.com ESMTP Sendmail 8.13.1/8.13.1; Wed, 23 Mar 2005 14:32:11 +0700
mail from: [email protected]
250 2.1.0 [email protected]... Sender ok
rcpt to: [email protected]
250 2.1.5 [email protected]... Recipient ok (will queue)
test sendmail
500 5.5.1 Command unrecognized: "test sendmail"
My name is Nattapong Prommi
500 5.5.1 Command unrecognized: "My name is Nattapong Prommi"

พิมพ์ quit เพื่อของจากการพิมพ์ข้อความ

ข้อมูลที่ทำการส่งจะถูกจัดเก็บใน /var/spool/mail/root
[root@li8 /]# cd /
You have mail in /var/spool/mail/root
[root@li8 /]# cat /var/spool/mail/root

Return-Path: <root>
Received: (from root@localhost)
by li8.evekm08.com (8.13.1/8.13.1/Submit) id j2N7dGcW003833;
Wed, 23 Mar 2005 14:39:16 +0700
Date: Wed, 23 Mar 2005 14:39:16 +0700
From: root <root>
Message-Id: <[email protected]>
To: from:, [email protected]
Subject: test sendmail
Cc: [email protected]

My name is Nattapong Prommi

--j2N7dGcX003833.1111563556/li8.evekm08.com--

 

อีกวิธีสำหรับการส่ง Sendmail ทำหลังจากการ service sendmail start
[root@li8 /]# mail from : [email protected]
Subject: test sendmail
Hello
. เมื่อพิมพ์ข้อความเสร็จเรียบร้อยแล้ว กด [ . ] ตามด้วย Enter
Cc: [email protected]
[root@li8 /]# from:... List:; syntax illegal for recipient address

ขอให้โชคดีกับการทดลองกันทุกคนครับ

เอกสารอ้างอิง

หนังสือ คัมภีร์ Redhat Enterprise Linux2