|
|
In this tutorial I'll show you how you can do email piping with qmail.
Email piping means in fact redirecting email that are coming to an email address to a php/cgi script.
You can done this using .forward, .qmail-default, .procmailrc maildroprc, etc.
In order to do this you must relay on two things
1. POP3 account should NOT be there for that email address from which you piping email to autoresponder script. Because POP3 catches the email before it will redirected to autoresponder script.
2. You need to set up other POP3 accounts for your regular correspondence like This email address is being protected from spambots. You need JavaScript enabled to view it. or This email address is being protected from spambots. You need JavaScript enabled to view it. etc., so these regular email won't be redirected to autoresponder.
Ask your host this question: 'Can I redirect(pipe) email from my catch-all email account to a php script?'
AutoResponders
An auto-responder is similar to a mailing list, but it simply responds with a pre-defined message to the person who sent the mail. The most common program for this purpose is vacation. However, this program may not be sufficient for most purposes. I will begin with an annoying trait of system e-mail configuration. Many people in their attempts to block unwanted mail have implemented routines that analyze the envelope sender of a message. For instance, if the sender's domain has no entry, then it will not accept the message. Another thing they will try to do is block all mail from <>. This is a foolhardy thing to do. Not only will user's not be able to get bounce messages, it makes it more difficult to send auto-responses. The next step would be to create a bit-bucket address for the envelope sender and do some trickery with the "From:" header. In my situation, I would like "From:" to point to the autoresponder that sent the response. If you rely on this situation, you can potentially create a mail loop because some (albeit ignorant) mail systems will respond to the "From:" header and not the envelope sender. The only sure-fire solution is to set the "From:" header and the envelope sender the same as the autoresponder, and then check for mail received from the same address over n times over some period of time. You can check for certain addresses, such as <>, #@[], postmaster@, mailer-daemon@, etc. to crack down on some of the more worthless mail you don't want to autorespond to.
Double Bounces
A double bounce is created when a bounce bounces on its way back. This normally indicates a configuration error (you should always have your envelope sender set up as a valid address, or <> or #@[]). If a bounce bounces and the envelope sender is <> or #@[] then it is ignored. But if it is an address, then the bounce will be sent to that address. If the address fails, then the double bounce situation occurs. Qmail will then send a QSBMF message to the doublebounce address (by default this is postmaster). Note that SMTP prevents envelope senders to be #@[], and thus it is only used in the internals of a qmail system.
Bounce Handling in Qmail Configuration
Qmail has several configuration items that can help you control bounce messages. Here are several for the control directory.
qmail-send
bouncefrom
The user name of a bounce message. Default is MAILER-DAEMON
bouncehost
The host of a bounce message. By default it is me. If that is not supplied, then it is bouncehost.
doublebouncehost
The host of a bounce message. By default it is me. If that is not supplied, then it is doublebouncehost.
doublebounceto
The user to receive double bounce messages. By default it is postmaster.
queuelifetime
The lifetime in seconds a message can stay in the queue. By default it is 604800 (one week). If a message temporarily fails over and over again, after it has been in the queue for this period of time and receives another temporary failure, then it will permanently fail and a bounce will be generated.
qmail-smtpd
badmailfrom
Unacceptable envelope sender addresses. qmail-smtpd will reject every recipient address for a message if the envelope sender address is listed in badmailfrom. A line in badmailfrom may be of the form @host, meaning every address at host.
Some further things you can do to control the bounce behavior:
To have an address automatically bounce a message, put the following into a .qmail file:
|exit 100
Read the qmail-command man page for other exit codes.
If a message is sitting in the queue, and you would like it to bounce right now, touch the appropriate info file with a time sufficiently in the past (beyond queuelifetime) and give qmail-send an ALRM signal. Note that qmail-send will try to send it one more time before it will bounce it. Is there a better way to do this?
Qmail
If you are a normal user, you can create an alias by saving a file called .qmail-foo in your home directory. Email sent to This email address is being protected from spambots. You need JavaScript enabled to view it. is then sent as specified in this file.
If you want to create just an alias, without being a user, eg. This email address is being protected from spambots. You need JavaScript enabled to view it., you create a .qmail file in the /var/qmail/alias directory. .qmail-myscript should do it.
Add the following to your .qmail file and save it.
|/path/to/tt/admin/cron/pipe.php
I have set up qmail to pass bounced emails to a php script
To Do this I created an email address called bounce
I add |/usr/bin/php -f /var/www/vhosts/domain.com/httpdocs/qbounce.php
to /var/qmail/mailnames/domain.com/.qmail
Hi,
I have email piping working for all the email addresses in the mster domain where Kayako sits.
e.g.
Master Domain = example.com
Email Address = This email address is being protected from spambots. You need JavaScript enabled to view it. (Works fine)
Email Address 2 = This email address is being protected from spambots. You need JavaScript enabled to view it. (Works fine)
Kayako Sits at: example.com/support
However I have setup email piping for a domain other than the master domain.
e.g. This email address is being protected from spambots. You need JavaScript enabled to view it.
This email address is piped as file name qmail-user1 with content:
|/usr/bin/php /home/example/public_html/support/cli/index.php
The wierd thing is that external email works but internal wont?!
Could it be the user behind this email address resides in another home directory?
|
|
Note:
We use Hosting and VPS Hosting, from:
www.star-host.org
We like and trust them.
Good prices, high security.
|