Friday, March 19, 2010

Misc 5

(This uses the topology found in Misc 3)
I will now focus on enabling Debian to function as an SMTP server. Natively, Debian installs exim4 as the MTA (Main Transfer Agent). MTAs such as exim4 and postfix both operate on SMTP TCP port 25. As I go through this article, I will cover both exim4 and postfix.

We'll begin with exim4. SMTP is a ASCII based protocol, so you can actually telnet into the server to perform mail sending. To access the server through telnet, use:
telnet localhost 25

I will now walk you through the basics of the SMTP protocol. At first you will receive code 220. Code 220 is the success response that notifies the application (or telnet user) that he can proceed. To proceed, type:
helo localhost

You will now be in code 250. Code 250 means that the SMTP server is ready for mail processing. First you must specify the sender:
mail from: kelvin@syraxius.ath.cx

Next, you specify the recipient:
rcpt to: syraxius@hotmail.com
rcpt to: 0800893j@student.tp.edu.sg

Finally, you tell the server that you are ready to specify the data:

At this point, you would be in code 354. In 354, the server is ready to receive the message body. Type anything you like, and end with a . on its own line. To send the mail, type:

Notice that it's troublesome to do this, so we employ a mail client such as alpine to assist us. To install alpine, use:
apt-get install alpine

When alpine is first invoked, you will need to configure the mail server manually. To do this, press S followed by C from the main menu. Use "localhost" as the SMTP server. Now quit back out to main menu and hit C to compose a mail. Notice that you can send mails only to users local on the computer by default (not even in your network). If you attempt to send to anything outside of your network, you will receive a mail delivery failure from exim4.

To fix this, type:
dpkg-reconfigure exim4-config

Simply select the "Internet" option and leave the rest as default to allow sending to the internet. However, don't expect to be able to reach severs like Hotmail as they block dynamic IPs.

To be able to receive mails from the internet, leave the listening field blank during the dpkg-reconfigure. Simply send (from Hotmail or anywhere else) the mail to your fully qualified email address, like kelvin@syraxius.ath.cx.

Postfix is similar to exim4, but it natively supports encryption through TLS. To install Postfix, use:
apt-get install postfix

If you've previously set up alpine for exim4, then you would not need to reconfigure it for postfix. Just make sure that it's postfix running instead of exim4 by stopping the exim4 daemon then starting the postfix.

If you've accidentally chosen to restrict to local sending, simply invoke:
dpkg-reconfigure postfix

Like exim4, you can select Internet to be able to send to the network.

No comments :

Post a Comment