Hi All,
I found that many people asking for scripts of plugins to control (enable/disable) remote SMTP access for users while allowing them to use webmail properly, and I'm one of those people. However, there doesn't seem to have such scripts or plugins around, or even there is, they don't work well from my experience (and also from other people's comments).
Luckily, I found a way to add some codes to exim.pl to achieve this, which I learnt from this forum (if I remember correctly) long long time ago but still works when I applied it on the latest version of exim.pl for my new server!
Just clarify, I'm not the one who wrote these codes, but I'm just sharing it to all of you in case you find it useful. Here we go..
(1) First, create the file “/etc/virtual/smtp_domains” to store your SMTP access list, just put those users you would like to allow SMTP access in it line by line, just like below:
domain1.com: username1
domain2.com: username2
(2) Then, backup and modify “/etc/exim.pl” file as follows:
i) INSERT:
AFTER:
ii) INSERT:
AFTER:
(3) Restart exim, and it's done!
It's pretty easy and quick. If there's someone who is familiar with making DA plugins (not me though
), he may just try to make one base on the above changes, and create an easy interface for DA admin to easily enable/disable SMTP access from within DA. I think it may not be too difficult.
I hope this post can help those in need for such needs!
Anthony.
I found that many people asking for scripts of plugins to control (enable/disable) remote SMTP access for users while allowing them to use webmail properly, and I'm one of those people. However, there doesn't seem to have such scripts or plugins around, or even there is, they don't work well from my experience (and also from other people's comments).
Luckily, I found a way to add some codes to exim.pl to achieve this, which I learnt from this forum (if I remember correctly) long long time ago but still works when I applied it on the latest version of exim.pl for my new server!

Just clarify, I'm not the one who wrote these codes, but I'm just sharing it to all of you in case you find it useful. Here we go..
(1) First, create the file “/etc/virtual/smtp_domains” to store your SMTP access list, just put those users you would like to allow SMTP access in it line by line, just like below:
domain1.com: username1
domain2.com: username2
(2) Then, backup and modify “/etc/exim.pl” file as follows:
i) INSERT:
Code:
my $smtpallowed=0;
open(SMTPDOMAINOWNERS,"/etc/virtual/smtp_domains");
while (<SMTPDOMAINOWNERS>)
{
$_ =~ s/\n//;
my ($dmn,$usr) = split(/: /, $_);
if ($usr eq $username)
{
$smtpallowed=1;
}
}
close(SMTPDOMAINOWNERS);
if ((!$smtpallowed) && ($username ne "root") && ($username ne "diradmin")) { return "no"; }
AFTER:
Code:
if ($unixuser == 1)
{
#the username passed doesn't have a domain, so its a system account
$homepath = (getpwnam($username))[7];
if ($homepath eq "") { return 0; }
open(PASSFILE, "< $homepath/.shadow") || return "no";
$crypted_pass = <PASSFILE>;
close PASSFILE;
ii) INSERT:
Code:
my $smtpallowed=0;
open(SMTPDOMAINOWNERS,"/etc/virtual/smtp_domains");
while (<SMTPDOMAINOWNERS>)
{
$_ =~ s/\n//;
my ($dmn,$usr) = split(/: /, $_);
if ($dmn eq $domain)
{
$smtpallowed=1;
}
}
close(SMTPDOMAINOWNERS);
if (!$smtpallowed) { return "no"; }
AFTER:
Code:
if ($crypted_pass eq crypt($password, $crypted_pass)) { return "yes"; }
else { return "no"; }
}
else
{
#the username contain a domain, which is now in $domain.
#this is a pure virtual pop account.
(3) Restart exim, and it's done!

It's pretty easy and quick. If there's someone who is familiar with making DA plugins (not me though

I hope this post can help those in need for such needs!
Anthony.
Last edited: