Build your Sendmail Relay Server in your LAN

sendmail

I installed a sendmail relay server in my LAN so that other servers can use it to send emails. The following is how I did the configuration in a Ubuntu 9 machine.

1. First you need to install sendmail package.

2. After installation, you need to do the following configuration:

(1) Sendmail Master Configuration File: /etc/mail/sendmail.mc

# vi sendmail.mc

To enable relay on a specific IP, you need to change SMTP Daemon's IP address. By default, it is 127.0.0.1 which is your localhost loopback address. This setting only allows you to send email from localhost. If you want other servers to use this server as relay to send emails, you much change to a valid IP address in your LAN, for example, it can be 192.168.0.88. In order to do so, you need to change the line 57 and 59 to as below:

DAEMON_OPTIONS('Family=inet, Name=MTA-v4, Port=smtp, Addr=192.168.0.88')dnl
DAEMON_OPTIONS('Family=inet, Name=MSP-v4, Port=submission, M=Ea, Addr=192.168.0.88')dnl


Please replace 192.168.0.88 with your real IP address. You also need to change following two lines at 100 and 104:

LOCAL_DOMAIN('yourhost.yourdomain')dnl
MAILER('smtp')dnl


Next step, you need to compile the sendmail.mc file to sendmail.cf file which will be actually used by sendmail. You need to type:

# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

You need to restart the sendmail server to make the change effective:

# /etc/init.d/sendmail restart

To check if the Sendmail is listening on an IP and a specific port, you can type:

# netstat -aunt

To check if the SMTP Port is open and listening from another server, you can type:

# nmap -v -sT 192.168.10.10 (IP address of this SMTP server)

(2) Configure the Access Control file: /etc/mail/access

# vi access

If you want to allow 192.168.0.99 to relay, add the following line:

Connect:192.168.0.99 RELAY

You also need to compile the access file to access.db file.

# makemap hash /etc/mail/access.db < /etc/mail/access

You need to restart the sendmail service to make it effective.

3. Sendmail Troubleshooting


If the local domain emails can not be delivered, and if your email service is hosted by an outside ISP, like Gmail (Google App.), please make sure your DNS setting will let you to resolve the correct MX record. Usually, you can set the external DNS server as your DNS server.

For example,

# vi /etc/resolv.conf

nameserver 206.0.6.60


You need to replace 206.0.6.60 with your real DNS Server's IP address provided by your ISP.

How to Change the Hostid of a Sun Solaris Machine?

Solaris

The Hostid is a globally unique ID for a Sun Solaris Machine. Sometimes, you need to change this hostid for whatever purpose. For example, you current machine is down for hardware failure and you purchased a new machine. However, all your current running software are based on this old hostid, and you must bring the new machine up within a very short time. The quick solution is to change the new machine's hostid to be as same as the old one.

There are several ways to do so, including using a program to flush NVRAM which will change the hostid permanently. I did following experiment to change the Hostid in a Solaris 10 machine temperately. It adds several lines in the /etc/rc2.d/S20sysetup file. If you want to restore the original hostid, you just need to remove these lines and reboot the machine.

My environment is:
# uname -a
SunOS myhostname 5.10 Generic_127111-11 sun4v sparc SUNW,SPARC-Enterprise-T5120


Step 1: Calculate your new Hostid

(1) If you want to change your hostid to 800a1b2c (hexdecimal format), you need to calculate its decimal first. You can use following online calculator to do this.

http://www.easycalculation.com/hex-converter.php

Hexdecimal: 800a1b2c
Decimal: 2148145964

(2) Then, divide the decimal number to three parts:
2148
1459
64

(3) You treat the above 3 parts as string combined by ASCII Characters. Use following calculator to get the HEX value:
32 31 34 38
31 34 35 39
36 34

http://www.easycalculation.com/ascii-hex.php

You need to pad 0s to the 3rd part. So it will become:
32313438
31343539
36340000

Step 2: Save your original Hostid:
cd /etc
cat hostid > hostid.orig


Step 3: Change the /etc/rc2.d/S20sysetup file
At the bottom of this file, add following code:
# Change Host ID to Hexdecimal: 800a1b2c
# It's Decimal Value: 2148145964
# Divide to 3 parts: 2148 1459 64
# Hex value of the above ASCII Characters:
# 32 31 34 38
# 31 34 35 39
# 36 34
# After padding:
# 32313438
# 31343539
# 36340000
# The following code will apply the new Hostid
adb -w -k /dev/ksyms /dev/mem </dev/null
hw_serial/W 0x32313438
hw_serial+4/W 0x31343539
hw_serial+8/W 0x36340000
END


Step 4: If you want to make the new hostid effective without reboot the machine, just type:
#sh S20sysetup

Otherwise, you can reboot the machine. If you want restore the original factory hostid, you can just comment out the above several lines of code in S20sysetup file.

9 Must Known Websites for .NET Developers

As an .NET application developer, the following 9 websites are my most frequently visited websites.

1. ASP.net



I learned .NET and get a lot of resources from this website.

2. MSDN



MSDN's primary web presence at msdn.microsoft.com is a collection of sites for the developer community that provide information, documentation, and discussion which is authored both by Microsoft and by the community at large. Recent emphasis on and incorporation of applications such as forums, blogs, library annotations, and social bookmarking are changing the nature of the MSDN site from a one-way information service to an open dialog between Microsoft and the developer community.

3. CodeProject



I downloaded many source code from this website. There are also many very good articles.

4. DotNetNuke



5. 4GuysFromRolla.com



6. DevSource



7. DevX



8. Chanel 9



Many videos introducing very cool and latest Microsoft technologies.

9. ScottGu's Glog


The About Me Page of this blog:

My name is Scott Guthrie, and I am a Corporate Vice President in the Microsoft Developer Division. I run the development teams that build the following products/technologies:

* CLR and the core .NET Base Class Libraries
* ASP.NET
* Silverlight
* WPF
* IIS 7.0
* Visual Studio Tools for ASP.NET, WPF, Silverlight and Mobile

Add a Background Picture to a Flash Object

Flash

I added a background picture to a flash object embedded in a web page. In order to make the background picture can be displayed through the flash animation, I added oneobject parameter:


The whole html code are as follows:



The above code can work properly when a user is using Internet Explorer (IE). However, when a user is using Firefox, the background of the flash is blank. The reason is the Firefox does not recognize the


So, I need to add it to the embed src as follows:



For the Firefox browser, you also need to set align="..." to make it be displayed in the right position.

How to Burn APE to Audio CD in Linux

APE Monkey Audio

1. Using FFMpeg or JMAC to Convert ape to wav:

.ape is the file extension for Monkey's Audio Files. Monkey's Audio is a pseudo-free lossless audio codec, like flac.

If you don't have ffmpeg, you can yum (for Fedora) or apt-get (for Ubuntu) to install it.

yum install ffmpeg
or
apt-get install ffmpeg


After you installed the ffmpeg, you can do this:

ffmpeg -i CDImage.ape CDImage.wav

CDImage.ape is the APE file you want to convert.

For whatever reason, if failed to convert the APE to WAV using ffmpeg, you could use JMAC to convert it. You need to make sure the Java Runtime Environment is installed. Then, you can download the JMAC package from http://sourceforge.net/projects/jmac/files/.

Only file you need is the jmac.jar. After unzipping JMAC package, you can find the location of the jmarc.jar and use it in the following command:

java -jar /path_to_the_file/jmac.jar d CDImage.ape CDImage.wav

2. Split APE with CUE:

You need to install bchunk to split the APE files. You can install it using yum or apt-get too.

yum install bchunk
or
apt-get install bchunk


After you installed the bchunk, you can do manual splitting as follows:

bchunk -w CDImage.wav CDImage.cue result

Where:
CDImage.wav is your large wav file
CDImage.cue is the cue file
result is the prefix for your wav songs (which gives you result01.wav, result02.wav...)


3. Burn to Audio CD:

You can use Brasero Disc Burner to burn the wav songs to a Audio CD.

Reference: http://gimpel.gi.funpic.de/wiki/index.php?title=Howto:convert_ape_to_wav/mp3/ogg_on_Linux/