Friday, May 13, 2011

How To Use Gmail Account To Relay Email From a Shell Prompt

SkyHi @ Friday, May 13, 2011
Usually, you do not need to setup an email server under Linux desktop operating system. Most GUI email clients (such as Thunderbird) supports Gmail POP3 and IMAP configurations. But, how do you send mail via the standard or /usr/bin/mail user agents or a shell script? Programs such as sendmail / postfix / exim can be configured as a gmail smarthost but they are largely overkill for this use.

You can use gmail as a smart host to send all messages from your Linux / UNIX desktop systems. You need to use a simple program called ssmtp. It accepts a mail stream on standard input with recipients specified on the command line and synchronously forwards the message to the mail transfer agent of a mailhub for the mailhub MTA to process. Failed messages are placed in dead.letter in the sender's home directory.

Install ssmtp

Type the following command under CentOS / RHEL / Red Hat / Fedora Linux:
# yum install ssmtp
Type the following command under Debian / Ubuntu Linux:
# apt-get update && apt-get install ssmtp

Configure gmail as a smarthost

Open /etc/ssmtp/ssmtp.conf, enter:
# vi /etc/ssmtp/ssmtp.conf
Update file with the following settings:
 
AuthUser=vivek@gmail.com
AuthPass=Your-Gmail-Password
FromLineOverride=YES
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES
 
Also, make sure you disable Sendmail:
# service sendmail stop
# chkconfig sendmail off
# mkdir /root/.bakup
# mv /usr/sbin/sendmail /root/.bakup
# ln -s /usr/local/ssmtp/sbin/ssmtp /usr/sbin/sendmail

Now, you can use mail / mailx command to send email messages. You can also write a shell script to backup your files and email to somewhere else (see below). You can test settings using following syntax:
$ echo "This is a test" | mail -s "Test" vivek@nixcraft.co.in

A note about sSMTP

sSMTP works well for desktop systems, but it is not a replacement for Sendmail / Postfix / Exim / Qmail for email server environment. This software is perfect for a single user system.

For the sake of others wondering.
# vim /etc/ssmtp/ssmtp.conf
# service sendmail stop
# chkconfig sendmail off
# mkdir /root/.backup
# mv /usr/sbin/sendmail /root/.backup/
# whereis ssmtp
ssmtp: /usr/sbin/ssmtp /etc/ssmtp /usr/share/man/man8/ssmtp.8.gz
# ln -s /usr/sbin/ssmtp /usr/sbin/sendmail
# echo “This is a test email” | mail -s “Test” adriyas@gmail.com

 

Further readings:


REFERENCES
http://www.cyberciti.biz/tips/linux-use-gmail-as-a-smarthost.html

Windows VBScript To Send Email Using CDO

SkyHi @ Friday, May 13, 2011
Windows 2000 and Windows XP use CDO messaging as a replacement for CDONTS.

Sending email with CDO is a simple task. First we create a reference to the CDO component

 

Set objMessage = CreateObject("CDO.Message")
then fill-in Sender, Subject and Recipient (To) fields of the headers and the body text which can be either plain text or HTML. You can also add a file attachment. You then use the Send method to send the email.

Below I'll show all three types of emails, and how to send an email using a remote SMTP server in the event you are not running your own. I've added and example to illustrate how to request a return receipt and delivery status notifications.

Please note, when using the AddAttachment method in your scripts you must use a fully qualified pathname as the argument to the method.  Using just a file name or a relative path will produce the error The specified protocol is unknown.
If you receive an error message related to objMessage.From then you should try replacing it with objMessage.Sender
I've added sample code to illustrate how to load the body of the email from a text file on your disk.
I've added a sample of how to load recipient data from a database.
I've added a sample illustrating how to use data from Excel in an email.
If you are looking for an ASP based email form processor then please look here.
If you are interested in a mass mailer using CDO and VBScript, look here.




This sample sends a simple text email that can be viewed in any email client.  
 
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "me@my.com"
objMessage.To = "test@paulsadowski.com"
objMessage.TextBody = "This is some sample message text."
objMessage.Send

Sending an HTML email.

Note the use of the Cc & Bcc properties to send using Blind Carbon Copy (Bcc) and Carbon Copy (Cc).
These properties can be used with either text or HTML email.

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "me@my.com"
objMessage.To = "test@paulsadowski.com"
'The line below shows how to send using HTML included directly in your script
objMessage.HTMLBody = "

This is some sample message html.

"

'The line below shows how to send a webpage from a remote site
'objMessage.CreateMHTMLBody "http://www.paulsadowski.com/wsh/"

'The line below shows how to send a webpage from a file on your machine
'objMessage.CreateMHTMLBody "file://c|/temp/test.htm"

objMessage.Bcc = "you@your.com"
objMessage.Cc = "you2@your.com"
objMessage.Send


Sending a text email with an attached file. By repeating the .AddAttachment method you can attach more than one file.
When attaching files keep in mind that your recipient may be limited in their
ability to receive files above a certain size. Many ISPs limit emails to 8 or 10MB each.
You should not send large files to anyone before obtaining their permission.
 
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "me@my.com"
objMessage.To = "test@paulsadowski.com"
objMessage.TextBody = "This is some sample message text."
objMessage.AddAttachment "c:\temp\readme.txt"
objMessage.Send

Sending a text email using a remote server. Sometimes you need to send email using another server. It may be required by your
company, or your ISP may be blocking the SMTP port, or your dynamic IP may be
blacklisted for being in a dynamic pool.

This code shows you how to use a remotes server rather than the SMTP server
on your own machine.
 
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "me@my.com"
objMessage.To = "test@paulsadowski.com"
objMessage.TextBody = "This is some sample message text."

'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.myserver.com"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send


Sending a text email using authentication against a remote SMTP server. More and more administrators are restricting access to their servers to control spam or limit
which users may utilize the server. This example shows you how to use basic authentication,
the most commonly used authentication method, when the SMTP server you are using requires it.

This code is slightly more complex but not very difficult to understand or work with.
 
Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).

Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = """Me"" "
objMessage.To = "test@paulsadowski.com"
objMessage.TextBody = "This is some sample message text.." & vbCRLF & "It was sent using SMTP authentication."

'==This section provides the configuration information for the remote SMTP server.

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.your.com"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "youruserid"

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourpassword"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send

Send using authentication against a remote server with a file attachment and return receipt and
delivery disposition notification requests.
In order to use the Delivery Status Notifications (Return
Receipt and Delivery Disposition requests) we need to create a reference to the CDO Configuration
object in addition to the CDO Message object and set a small number of properties. You must
use cdoSendUsingPort (network connection) and not the SMTP server's pickup directory
(cdoSendUsingPickup).
 

Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2 'Must use this to use Delivery Notification
Const cdoAnonymous = 0
Const cdoBasic = 1 ' clear text
Const cdoNTLM = 2 'NTLM
'Delivery Status Notifications
Const cdoDSNDefault = 0 'None
Const cdoDSNNever = 1 'None
Const cdoDSNFailure = 2 'Failure
Const cdoDSNSuccess = 4 'Success
Const cdoDSNDelay = 8 'Delay
Const cdoDSNSuccessFailOrDelay = 14 'Success, failure or delay

set objMsg = CreateObject("CDO.Message")
set objConf = CreateObject("CDO.Configuration")

Set objFlds = objConf.Fields
With objFlds
  .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
  .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.yourhost.com"
  .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
  .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "your-username"
  .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "your-password"
  .Update
End With

strBody = "This is a sample message." & vbCRLF
strBody = strBody & "It was sent using CDO." & vbCRLF

With objMsg
  Set .Configuration = objConf
  .To = "test@paulsadowski.com"
  .From = "me@my.com"
  .Subject = "This is a CDO test message"
  .TextBody = strBody
   'use .HTMLBody to send HTML email.
  .Addattachment "c:\temp\Scripty.zip"
  .Fields("urn:schemas:mailheader:disposition-notification-to") = "me@my.com"
  .Fields("urn:schemas:mailheader:return-receipt-to") = "me@my.com"
  .DSNOptions = cdoDSNSuccessFailOrDelay
  .Fields.update
  .Send
End With

In real world usage you'll most likely want to load the text of the email from a file on your
computer. The sample code below shows you how to do this. The text can be either
plain text or HTML as needed.Our example assumes your text is in the file
C:\Temp\MyEmail.txt. This code loads the entire content of that file into a variable,
here named BodyText which you can then reference in your CDO code. We
assume BodyText is in the scope of your CDO code.
 

'These constants are defined to make the code more readable
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
'Open the file for reading
Set f = fso.OpenTextFile("c:\temp\MyEmail.txt", ForReading)
'The ReadAll method reads the entire file into the variable BodyText
BodyText = f.ReadAll
'Close the file
f.Close
Set f = Nothing
Set fso = Nothing
Once the text is loaded you can use it in your CDO code something like this...

objMessage.TextBody = BodyText
or
objMessage.HTMLBody = BodyText


Load Recipients from a Database As is the case with most thing in Windows there are many ways to accomplish a task. This is one method of many.
Our database is an Access format database that resides on the local disk. The table in our database that we are     interested in is called Customers and each record consists of 4 fields named "ID", "Name", "Email", and "Customer", where ID is an autogenerated index, Name is the full name of our customer, Email is the customer's email address and Customer is their customer identification number.
We are only interested here in two fields, Name and Email.
ID Name Email Customer
1 Bob Jones bjones@test.com 12345
2 Jane Smith jsmith@test.net 12346

Set OBJdbConnection = CreateObject("ADODB.Connection")
OBJdbConnection.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=c:\Acme Inc\Databases\Customers.mdb"
SQLQuery = "SELECT Name, Email FROM Customers"
Set Result = OBJdbConnection.Execute(SQLQuery)
if Not Result.EOF then
  Do While Not Result.EOF
    SendMail Result("Name"), Result("Email")
    Result.MoveNext
  Loop
end if
OBJdbConnection.Close
As you can see the code is simple. We create a database connection object then open the database and query it for the Name and Email fields of each customer. Those values are passed for each customer to a subroutine that sends the customer an email.
Sub SendMail(TheName, TheAddress)
Dim objMessage, Rcpt

Rcpt = Chr(34) & TheName & Chr(34) & "<" & TheAddress & ">"
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "This Month's Sales" objMessage.From = """Acme Sales"" "
objMessage.To = Rcpt
objMessage.HTMLBody = TextBody
objMessage.Send

End
Sub

If you are not accustomed to working with databases then this may have seemed a daunting task but as you can see from the code above, it's really quite simple.

We've already covered sending email so I'll just mention that this subroutine assumes the HTML body text is a variable called TextBody (see Loading email body text from a file)
Also we format the recipient's address in the standard format of "Name" for a more professional look to the recipient..

Remarks

As previously stated there are many ways to do this. I've presented one simple method here. Your own use may be with an ODBC connection; it may use mySQL or SQL Server; it may include personalization of the email body text and more. My intent here was to provide you with the basics to get you started.
Load data from an Excel Worksheet
 
There may be times when you want to generate an email using data from an application such as Excel. This is one simple illustration of how that could be done. In our example we will be using a Workbook with three columns starting at column A row 1. Each row represents one product in our inventory and the three columns contains the following data about each item: Part Number, Name of Part, Number of Items in Inventory. Graphically our Workbook looks like this:
Part Name Stock
4583586 Fliggalhopper 452
5898547 Looplonger 293
This particular script works by walking down each cell of column 1 till it finds an empty cell which it assumes is the end of the list of entries. If your file may contain empty cells then you can use the Worksheet's UsedRange.Rows.Count property to find the last row in which an entry is made. Your code would then use a for loop something like this:
 
rowLast = objSheet.UsedRange.Rows.Count
for x = rowStart to rowLast
' do stuff
next

Function GetData()
Dim x, strTemp, objExcel, objWB

Set
objExcel = Wscript.CreateObject("Excel.Application")
Set
objWB = objExcel.Workbooks.Open("c:\Acme Inc\Workbooks\Test.xls")
Set
objSheet = objExcel.ActiveWorkbook.Worksheets(1)

' Make Excel visible while debugging

objExcel.Visible = True

' This is the row of our first cell.

x = 1

do
while objExcel.Cells(x, 1).Value <> ""
  strTemp = strTemp & objExcel.Cells(x, 1).Value & _
    Space
(10 - Len(objExcel.Cells(x, 1).Value))
  strTemp = strTemp & objExcel.Cells(x, 2).Value & _
    Space
(50 - Len(objExcel.Cells(x, 2).Value))
  strTemp = strTemp & objExcel.Cells(x, 3).Value & vbCRLF
  x = x + 1
loop

' This will prevent Excel from prompting us to save the workbook.

objExcel.ActiveWorkbook.Saved = True

' Close the workbook and exit the application.

objWB.Close
objExcel.Quit

set
objWB = Nothing
set
objExcel = Nothing

GetData
= strTemp
End
Function

' This is our main function.
Dim
strBody

Set
objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Inventory report for " & Date
objMessage.From = "me@my.com"
objMessage.To = "bossman@my.com"
strBody = "Part" & Space(6) & "Item" & Space(46) & "Stock" & vbCRLF

' Here we call the function GetData to populate the body text.

strBody = strBody & GetData

objMessage.TextBody = strBody
objMessage.Send

The code above will produce an email that looks something like this:

To: bossman@my.com
From: me@my.com
Subject: Inventory report for 3/19/2005

Part      Item                                              Stock
4583586   Fliggalhopper                                     452
5898547   Looplonger                                        293

This sample sends a simple text email via GMail servers.  

It's like any other mail but requires that you set the SMTP Port to 465 and tell CDO to use SSL
 
Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).

Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = """Me"" "
objMessage.To = "me@my.com"
objMessage.TextBody = "This is some sample message text.." & vbCRLF & "It was sent using SMTP authentication and SSL."

'==This section provides the configuration information for the remote SMTP server.

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "You@gmail.com"

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "YourPassword"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send



REFERENCES
http://www.paulsadowski.com/wsh/cdo.htm

Wednesday, May 11, 2011

Log All Email for Sendmail in CentOS 5

SkyHi @ Wednesday, May 11, 2011
Do you ever wanted to copy each and every incoming and outgoing email in Sendmail automatically to a single email acccount transparently? Thanks to Axel Reinhold’s logall.c module. Now, we can do it. In the below HOWTO, we will configure Sendmail to copy each and every incoming and outgoing email to an email account called “logall”.
Requirement: Sendmail, logall.c and CentOS 5

1. Please make sure the following are installed: -
cpp-4.1.1-52.el5.i386.rpm
elfutils-0.125-3.el5.i386.rpm
elfutils-libs-0.125-3.el5.i386.rpm
gcc-4.1.1-52.el5.i386.rpm
libgomp-4.1.1-52.el5.i386.rpm
rpm-build-4.4.2-37.el5.i386.rpm


2. Download the sendmail source rpm using the link below: -
http://mirrors.kernel.org/centos/5/os/SRPMS/sendmail-8.13.8-2.el5.src.rpm

3. Go to “Subject: Q4.20 — How can I automatically copy messages based on sender or recipient addresses?” in Sendmail.org website using the link below: -
http://www.sendmail.org/faq/section4.html#4.20

4. Download the Axel Reinhold’s logall.c module using the link below: -
http://www.freakout.de/logall.c

5. Install the sendmail source rpm using the command below: -
rpm -ivh sendmail-8.13.8-2.el5.src.rpm

6. Extract the sendmail source file using the command below: -
tar xvfz /usr/src/redhat/SOURCES/sendmail.8.13.8.tar.gz -C /tmp

7. Add the following line into this file /tmp/sendmail-8.13.8/sendmail/conf.c at line 1312 as below: -
#include "/tmp/logall.c"

8. Below is the partial content of /tmp/sendmail-8.13.8/sendmail/conf.c file: -
if (tTd(49, 1))
sm_dprintf("checkcompat(to=%s, from=%s)\n",
to->q_paddr, e->e_from.q_paddr);
#include "/tmp/logall.c"


9. Save the file and create a new sendmail archive using the command below: -
cd /tmp
tar cvfz sendmail.8.13.8.tar.gz sendmail-8.13.8


10. Backup the original sendmail archive using the following command below: -
cd /usr/src/redhat/SOURCES
mv sendmail.8.13.8.tar.gz /tmp/sendmail.8.13.8.tar.gz-ori

11. Copy the new sendmail archive into the installed source sendmail rpm using the following command below: -
cp sendmail.8.13.8.tar.gz /usr/src/redhat/SOURCES

12. Let’s build the sendmail binary package only from the spec file using the command below: -
cd /usr/src/redhat/SPECS/
rpmbuild -bb sendmail.spec


13. Let’s install the new sendmail binary package using the following command below: -
cd /usr/src/redhat/RPMS/i386
rpm --force -Uvh sendmail-8.13.8-2%{dist}.i386.rpm sendmail-cf-8.13.8-2%{dist}.i386.rpm


14. Edit the sendmail config file /etc/mail/sendmail.cf and add the following line below before this line “# level 10 config file format”: -
# logall.c
D{LogAll}/var/spool/mail/logall


15. Below is the partial content of /etc/mail/sendmail.cf file: -
# logall.c
D{LogAll}/var/spool/mail/logall

# level 10 config file format
V10/Berkeley


16. Restart the sendmail service using the following command below: -
service sendmail restart

17. Create the email accout called “logall” using the following command below: -
useradd logall
passwd logall
touch /var/spool/mail/logall
chown logall:logall /var/spool/mail/logall


18. Let’s send an email to a user using the following command below: -
echo "Test" | mail -s "TEST" wlsiew

19. Let’s check the content of the file /var/spool/mail/logall using the following command below: -
cat /var/spool/mail/logall

20. Below is the content of /var/spool/mail/logall file: -
From root Wed Sep 12 20:37:13 2007
Return-Path:
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by localhost.localdomain (8.13.8/8.13.8) with ESMTP id l8CDbDAV008813
for ; Wed, 12 Sep 2007 20:37:13 +0800
Full-Name: root
Received: (from root@localhost)
by localhost.localdomain (8.13.8/8.13.8/Submit) id l8CDbDR2008812
for wlsiew; Wed, 12 Sep 2007 20:37:13 +0800
Date: Wed, 12 Sep 2007 20:37:13 +0800
From: root
Message-Id: <200709121337.l8CDbDR2008812@localhost.localdomain>
To: wlsiew@localhost.localdomain
Subject: TEST
X-Logged: Logged by localhost.localdomain as l8CDbDAV008813 at Wed Sep 12 20:37:13 2007



REFERENCES
http://wingloon.com/2007/09/12/log-all-email-for-sendmail-in-centos-5/
http://serverfault.com/questions/131730/configure-sendmail-to-clone-all-outgoing-email

How to send a copy of every email to a given email address in Postfix

SkyHi @ Wednesday, May 11, 2011
Recently, I wanted to send a copy of every email of particular person to a given email address using postfix. I was looking for solution in Postfix documents and i found simple way to do this using – Automatic BCC recipients.
To achieve this Postfix provides three mechanisms:

1. always_bcc = address
Deliver a copy of all mail to the specified address. If you want to deliver a copy of all emails to the specified email address then just you can add below config in main.cf and reload the postfix config. always_bcc=xyz@domain.com

2. sender_bcc_maps = type:table
Search the specified “type:table” lookup table with the envelope sender address for an automatic BCC address.

3. recipient_bcc_maps = type:table
Search the specified “type:table” lookup table with the envelope recipient address for an automatic BCC address.

1. create recipient_bcc mapping hash tables
# vi /etc/postfix/recipient_bcc

2. Add emails you want to apply this to:
#recipient_bcc mapping
abc@domain.com xyz@domain.com


3. Now you create the hash mapping database
# /usr/sbin/postmap /etc/postfix/recipient_bcc

4. Add this configuration in main.cf
# vi /etc/postfix/main.cf
recipient_bcc_maps = hash:/etc/postfix/recipient_bcc


5. Reload the postfix configuration
#/etc/init.d/postfix reload

REFERENCES
http://www.techiepark.com/tutorials/how-to-send-a-copy-of-every-email-to-a-given-email-address-in-postfix/
http://www.postfix.org/ADDRESS_REWRITING_README.html#auto_bcc
http://www.freebsdonline.com/content/view/570/520/

Tuesday, May 10, 2011

Disable the Overlay Scrollbars in Ubuntu 11.04

SkyHi @ Tuesday, May 10, 2011

Ubuntu 11.04 is here, along with some interesting changes.
One of these changes is overlay scrollbars.
This means your scrollbar will not be visible until you move your mouse over to the side where the scrollbar would normally be.
If you’re really annoyed with this “enhancement”, here’s how to put it back into the “old fashion” way of doing things (with a scroll-bar always present).
Open a terminal and drop this line:
sudo su
echo”export LIBOVERLAY_SCROLLBAR=0″ > /etc/X11/Xsession.d/80overlayscrollbars
Then, restart.

REFERENCES
http://churchit.com/disable-the-overlay-scrollbars-in-ubuntu-11-04/

Linux stat Command Access Modify Change Time

SkyHi @ Tuesday, May 10, 2011
stat
The stat utility allows you to see all information about either a file or a directory.  You can use wildcards if you want to see info for more than one object at a time.
stat process.sh
File: `process.sh'
Size: 158           Blocks: 16         IO Block: 4096   regular file
Device: 305h/773d    Inode: 98134       Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2010-08-18 11:16:37.000000000 -0600
Modify: 2010-08-16 09:44:57.000000000 -0600
Change: 2010-08-16 09:44:57.000000000 -0600



Most of this should be self-explanatory, but a few items bear explaining.
* Blocks–Each file occupies a certain number of filesystem blocks on the harddrive.  Here, we see that this file occupies eight blocks.
* IO Block–This is the size of the IO block.
* Device–The number of your storage device (harddrive, etc.)
* Inode–The inode number that the file or directory is linked to.
* Times–Note that the timestamps also include which time zone that accesses or modifications took place in. 
The “-0500″ signifies the Eastern Standard  time zone.
You can use the “-c” switch, along with the appropriate option, if you only want to look at one particular piece of information.  For example, if you only want to look at the file’s permissions setting, you can enter:
stat -c%A process.sh
-rw-r--r--



If you want to see information on a particular directory, use the “-f” switch.
stat -f /etc
File: "/etc"
ID: 0        Namelen: 255     Type: reiserfs
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 1977922    Free: 1272318    Available: 1272318
Inodes: Total: 0          Free: 0


Here, you see the size of the filesystem blocks in bytes, and how many blocks are free.  Don’t worry about having zero inodes, since this drive is formatted with reiserfs filesystem.  That’s just how reiserfs reports things.  In reality, there are plenty of inodes left for use.  For comparison, here’s how it would look on an ext3 filesystem.

stat -f /etc
File: "/etc"
ID: 0        Namelen: 255     Type: ext2/ext3
Blocks: Total: 9466244    Free: 7530719    Available: 7049849    Size: 4096
Inodes: Total: 4816896    Free: 4586664


With ext2 or ext3, you can see both the total and the available number of inodes.  Since Linux uses an inode for each file, it appears that we can place 4,586,664 more files on this harddrive.


REFERENCES:
http://bashshell.net/commands/linux-stat-command/