Qmail allow email from my own domain (particular domain) only

h‮t‬tps://www.lautturi.com
Qmail allow email from my own domain (particular domain) only

To configure Qmail to allow email from your own domain only, you can use the check_rcpt feature of Qmail. The check_rcpt feature allows you to specify rules for checking the recipient address of incoming email, and you can use it to reject email from domains other than your own.

To use the check_rcpt feature, you will need to create a check_rcpt script and configure Qmail to use it. Here's an example of a simple check_rcpt script that allows email from your own domain only:

#!/bin/bash

# Get the recipient domain
recipient_domain=$(echo $1 | cut -d @ -f 2)

# Check if the recipient domain is your own
if [ "$recipient_domain" == "yourdomain.com" ]; then
    exit 0
else
    exit 111
fi

This script uses the cut command to extract the recipient domain from the email address, and then it checks if the recipient domain is your own. If the recipient domain is your own, the script exits with a status code of 0, which indicates that the recipient is allowed. If the recipient domain is not your own, the script exits with a status code of 111, which indicates that the recipient is not allowed.

To configure Qmail to use this check_rcpt script, you will need to edit the qmail-smtpd/run file and add the -R flag followed by the path to the check_rcpt script. For example:

#!/bin/sh
QMAILQUEUE="${QMAILQUEUE:-qmail-queue}"
exec /usr/local/bin/tcpserver -v -R /path/to/check_rcpt 0 smtp /var/qmail/bin/qmail-smtpd 2>&1

This will configure Qmail to use the check_rcpt script to check the recipient address of incoming email, and it will allow email from your own domain only.

It's important to note that you will need to set the correct permissions on the check_rcpt script and make sure that it is executable by Qmail. You may also need to make additional configuration changes to Qmail to use the check_rcpt feature. Consult the Qmail documentation and online resources for more information on how to use the check_rcpt feature to allow email from your own domain only.

Created Time:2017-10-30 14:27:12  Author:lautturi