The below guide quickly showed how to rewrite the sender address using ssmtp
There are only two files to edit, /etc/ssmtp/ssmtp.conf and /etc/ssmtp/revaliases
in /etc/ssmtp/ssmtp.conf set
root=authenticuser
or
www-data=authenticuser
assuming other parameters correctly.
Also you need to set
FromLineOverride=NO
This is important as this will not allow users to set their from address and it will be rewritten by ssmtp.
In revaliases file add the line
root:authenticuser@domain.com
or
www-data:authenticuser@domain.com
Thats all,
for more information you can refer here http://www.scottro.net/qnd/qnd-ssmtp.html
Thursday, March 15, 2012
Setting up a Relay host with debian6 and exim
The need of the day was to set up a kind of store and forward server,
which receives mails from different applications and devices on the
network, and sends out using a smart host.
smart host is microsoft exchange, which requires authentication, and will send out if and only if the sender and authenticated users are same.
This task was achieved by setting up a exim4 SMTP server and rewriting the address. as follows:
First install package exim4
apt-get install exim4
You have to configure it
dpkg-reconfigure exim4-config
Our need is to receive mail from many clients and sent it using smart host.
screen 1 : Mail sent by smarthost/received via SMTP or fetchmail
I did not understand this but still writing domain part has worked fr me.
screen 2 : Give a mail name (domain part)
This is to notify the server on which interfaces it should be listening for incoming mails.
screen 3 : Write down the interfaces on which the system has to listen separated by semicolons (;)
This is mail receiving destination domains, and we donot need this
screen 4 : Leave blank
These are the networks on which the server accepts the incoming mails. Provide all your networks, also care has to be taken that outsiders should not be able to use these networks.
screen 5 : Add the networks to listen for separated by semicolons
Enter your smart host, which is used for sending out the mail
screen 6 : Put the outgoing mail server address with port ( ip.address.of.server:port )
This option is enabled as the smarthost sends out if and only if authenticated user and sender address are same.
screen 7 : Yes
So put your domain, from where the mail has to go out.
screen 8 : Put your domain name
If you are on a low bandwidth you can minimise DNS querries, otherwise
screen 9 : No
Remaining screens just choose default. This will include configuration in single file as "yes"
This will complete the setup of the mail server.
Now we have to give the password to authenticate againist the smart host. This taks is acheived by editing the file /etc/exim4/passwd.client to look as follows
target.mail.server.example:login:password
now edit /etc/exim4/exim4.conf.template
go to line
begin rewrite
and below you can add your configuration
example
* "someone@someaddress.com Ffs
will change
envelop From, from, sender fields
The flages are important as they do specific functions as below.
E rewrite all envelope fields
F rewrite the envelope From field
T rewrite the envelope To field
b rewrite the Bcc: header
c rewrite the Cc: header
f rewrite the From: header
h rewrite all headers
r rewrite the Reply-To: header
s rewrite the Sender: header
t rewrite the To: header
You should be particularly careful about rewriting Sender: headers, and restrict this to special known cases in your own domains.
Also it is possible to write scripts, which do more complex jobs, and use the list from a file.
you can find them from exim documentation at http://www.exim.org/exim-html-3.30/doc/html/spec_34.html
Now restart exim
/etc/init.d/exim4 restart
It is all set to go,
You can verify how redirecting is working by issuing
/etc/exim4# exim -brw dingo
sender: someone@someaddress.com
from: someone@someaddress.com
to: dingo@someaddress.com
cc: dingo@someaddress.com
bcc: dingo@someaddress.com
reply-to: dingo@someaddress.com
env-from: someone@someaddress.com
env-to: dingo@someaddress.com
Now you see which fields are actually rewritten.
Thats all, Bingo, your store and forward server is working now .
smart host is microsoft exchange, which requires authentication, and will send out if and only if the sender and authenticated users are same.
This task was achieved by setting up a exim4 SMTP server and rewriting the address. as follows:
First install package exim4
apt-get install exim4
You have to configure it
dpkg-reconfigure exim4-config
Our need is to receive mail from many clients and sent it using smart host.
screen 1 : Mail sent by smarthost/received via SMTP or fetchmail
I did not understand this but still writing domain part has worked fr me.
screen 2 : Give a mail name (domain part)
This is to notify the server on which interfaces it should be listening for incoming mails.
screen 3 : Write down the interfaces on which the system has to listen separated by semicolons (;)
This is mail receiving destination domains, and we donot need this
screen 4 : Leave blank
These are the networks on which the server accepts the incoming mails. Provide all your networks, also care has to be taken that outsiders should not be able to use these networks.
screen 5 : Add the networks to listen for separated by semicolons
Enter your smart host, which is used for sending out the mail
screen 6 : Put the outgoing mail server address with port ( ip.address.of.server:port )
This option is enabled as the smarthost sends out if and only if authenticated user and sender address are same.
screen 7 : Yes
So put your domain, from where the mail has to go out.
screen 8 : Put your domain name
If you are on a low bandwidth you can minimise DNS querries, otherwise
screen 9 : No
Remaining screens just choose default. This will include configuration in single file as "yes"
This will complete the setup of the mail server.
Now we have to give the password to authenticate againist the smart host. This taks is acheived by editing the file /etc/exim4/passwd.client to look as follows
target.mail.server.example:login:password
now edit /etc/exim4/exim4.conf.template
go to line
begin rewrite
and below you can add your configuration
example
* "someone@someaddress.com Ffs
will change
envelop From, from, sender fields
The flages are important as they do specific functions as below.
E rewrite all envelope fields
F rewrite the envelope From field
T rewrite the envelope To field
b rewrite the Bcc: header
c rewrite the Cc: header
f rewrite the From: header
h rewrite all headers
r rewrite the Reply-To: header
s rewrite the Sender: header
t rewrite the To: header
You should be particularly careful about rewriting Sender: headers, and restrict this to special known cases in your own domains.
Also it is possible to write scripts, which do more complex jobs, and use the list from a file.
you can find them from exim documentation at http://www.exim.org/exim-html-3.30/doc/html/spec_34.html
Now restart exim
/etc/init.d/exim4 restart
It is all set to go,
You can verify how redirecting is working by issuing
/etc/exim4# exim -brw dingo
sender: someone@someaddress.com
from: someone@someaddress.com
to: dingo@someaddress.com
cc: dingo@someaddress.com
bcc: dingo@someaddress.com
reply-to: dingo@someaddress.com
env-from: someone@someaddress.com
env-to: dingo@someaddress.com
Now you see which fields are actually rewritten.
Thats all, Bingo, your store and forward server is working now .
Tuesday, March 6, 2012
MailScanner Tweakings
MailScanner is a good tool, which integrates antivirus, spam control with SMTP servers,
The workflow is simple mails received will go to hold state, then Mailscanner scans through them in batch mode, and re-Que it for delivery, if everything is OK. If spam is observed suitable defined action will be taken.
This was working quite fine without any problem, but one day it is observed that we had a big que pending, and Mailscanner was taking more than 30 minutes to scan a batch of 30 mails. It is a kind of serious issue, because users started complaining that they have sent the mail, but the addressee has not received them yet. (Unfortunately no one remembers the old snail mail working days, or even the days when trunk call was taking more than couple of hours to get connected.)
We had no option but to wait till the Mailscanner runs through all that big que, so that mails will get delivered.
So I was just wondering about someways to speed up the Mailscanner, which starts from investigation on finding out what might be the things that takes up longer time. It could be I/O speed of disk, as mails are written twice into disk, big mail size as MailScanner scans the whole message, big batch, as the batch processing takes longer time, Many RBL lists, contacting each one of them, non cached Spam list, Restrictions to use resources on part of applications, DNS server non-functionality and many more.
Little googling revealed some tips and tricks to overcome quite these problems, as listed below
In Mailscanner.conf set
Clamd Use Threads = yes
This will use multiple thread from avaialble multiple cpu cores. so that scanning will become faster
log speed =yes
Will log the speed of message scanning so that you will know it, and benchmark
Reduce the number of RBL lists
Reduce the batch size from 30 to a lower number
These will speed up Mailscanner a bit. Also a speedy filesystem would help much.
The workflow is simple mails received will go to hold state, then Mailscanner scans through them in batch mode, and re-Que it for delivery, if everything is OK. If spam is observed suitable defined action will be taken.
This was working quite fine without any problem, but one day it is observed that we had a big que pending, and Mailscanner was taking more than 30 minutes to scan a batch of 30 mails. It is a kind of serious issue, because users started complaining that they have sent the mail, but the addressee has not received them yet. (Unfortunately no one remembers the old snail mail working days, or even the days when trunk call was taking more than couple of hours to get connected.)
We had no option but to wait till the Mailscanner runs through all that big que, so that mails will get delivered.
So I was just wondering about someways to speed up the Mailscanner, which starts from investigation on finding out what might be the things that takes up longer time. It could be I/O speed of disk, as mails are written twice into disk, big mail size as MailScanner scans the whole message, big batch, as the batch processing takes longer time, Many RBL lists, contacting each one of them, non cached Spam list, Restrictions to use resources on part of applications, DNS server non-functionality and many more.
Little googling revealed some tips and tricks to overcome quite these problems, as listed below
In Mailscanner.conf set
Clamd Use Threads = yes
This will use multiple thread from avaialble multiple cpu cores. so that scanning will become faster
log speed =yes
Will log the speed of message scanning so that you will know it, and benchmark
Reduce the number of RBL lists
Reduce the batch size from 30 to a lower number
These will speed up Mailscanner a bit. Also a speedy filesystem would help much.
Subscribe to:
Comments (Atom)