我已经在debian 8上安装了postfix 2.11.3 + sasl + postfixadmin + dovecot + roundcube。所有工作正常,但今天每个用户都可以用另一个电子邮件地址发送邮件。 我想添加一个限制,允许用户发送电子邮件只与他们的邮箱或与他们的邮箱相关的别名。
例子 :
1)邮箱
[email protected]
[email protected]
2)别名
[email protected]转到[email protected]
[email protected]转到[email protected]
我希望[email protected]以[email protected],只能发送电子邮件[email protected]和[email protected]。
user1不应该能够使用user2,alias2或其他。
我正在寻找使用mysql_table查找的解决scheme,因为我使用postfixadmin和mysqlpipe理邮箱和别名。 像这样的东西:
SELECT address FROM alias WHERE address = '%s' AND goto LIKE '%<login>%'
从手册页,只有参数可用:
%s This is replaced by the input key. SQL quoting is used to make sure that the input key does not add unexpected metacharacters. %u When the input key is an address of the form user@domain, %u is replaced by the SQL quoted local part of the address. Otherwise, %u is replaced by the entire search string. If the localpart is empty, the query is sup- pressed and returns no results. %d When the input key is an address of the form user@domain, %d is replaced by the SQL quoted domain part of the address. Otherwise, the query is suppressed and returns no results. %[SUD] The upper-case equivalents of the above expansions behave in the query parameter identically to their lower-case counter-parts. With the result_format parameter (see below), they expand the input key rather than the result value. %[1-9] The patterns %1, %2, ... %9 are replaced by the corre- sponding most significant component of the input key's domain. If the input key is [email protected], then %1 is com, %2 is example and %3 is mail. If the input key is unqualified or does not have enough domain components to satisfy all the specified patterns, the query is sup- pressed and returns no results.
login不可用。
我知道有一个解决scheme来对roundcube进行限制,但我的用户可以直接访问他们的电子邮件,而不需要使用roundcube。
在此先感谢您的帮助。
UPDATE
我试过这个: main.cf
smtpd_sender_login_maps = mysql:/etc/postfix/mysql-virtual-sender-maps.cf smtpd_sender_restrictions = reject_authenticated_sender_login_mismatch permit_sasl_authenticated
mysql-virtual-sender-maps.cf
user = mailuser password = xxxxxxxxxxxxxxxx hosts = 127.0.0.1 dbname = postfixadmin query = SELECT address FROM alias WHERE goto LIKE '%%%s%%'
用user1login,我能够发送带有别名2的电子邮件。
数据库的内容是postfixadmin的默认值:
CREATE TABLE IF NOT EXISTS `alias` ( `address` varchar(255) NOT NULL, `goto` text NOT NULL, `domain` varchar(255) NOT NULL, `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `active` tinyint(1) NOT NULL DEFAULT '1' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Postfix Admin - Virtual Aliases'; CREATE TABLE IF NOT EXISTS `mailbox` ( `username` varchar(255) NOT NULL, `password` varchar(255) NOT NULL, `name` varchar(255) CHARACTER SET utf8 NOT NULL, `maildir` varchar(255) NOT NULL, `quota` bigint(20) NOT NULL DEFAULT '0', `local_part` varchar(255) NOT NULL, `domain` varchar(255) NOT NULL, `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `active` tinyint(1) NOT NULL DEFAULT '1' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Postfix Admin - Virtual Mailboxes';
smtpd_sender_restrictions应该包含reject_authenticated_sender_login_mismatch
然后,您将为smtpd_sender_login_maps提供一个smtpd_sender_login_maps 。
我终于find了我的问题的部分答案。 在我的config.inc.php的RoundCube,我以前从smtp_user参数和%p从smtp_password中删除%u。 因此,连接到后缀是未经validation的。 这就是为什么限制不起作用。
应该工作的查询是:
query = SELECT goto FROM alias WHERE address = '%s'
谢谢您的帮助。
仅供参考,我有完全相同的问题,并解决了与后缀。 之后,我的[email protected]进行身份validation,并可以从[email protected]或[email protected]发送电子邮件。
在master.cf中,我有一个configuration来启用我的SSL saslauthentication用户,如下所示:
smtps inet n - y - - smtpd -o syslog_name=postfix/smtps -o smtpd_tls_wrappermode=yes -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject_unauth_destination -o smtpd_sender_restrictions=reject_authenticated_sender_login_mismatch -o smtpd_sender_login_maps=mysql:/etc/postfix/mysql-smtpd-sender-login-maps.cf,mysql:/etc/postfix/mysql-virtual-sender-maps.cf
和我的mysql映射文件:
mysql-virtual-sender-maps.cf:
user = mailuser password = xxxxxxxxxxxxxxxx hosts = 127.0.0.1 dbname = postfixadmin query = SELECT goto FROM alias WHERE address='%s'
mysql-smtpd-sender-login-maps.cf
user = mailuser password = xxxxxxxxxxxxxxxx hosts = 127.0.0.1 dbname = postfixadmin query = select username from mailbox where username='%s'
请注意,我必须“翻译”表名和字段而不进行testing。 不要复制和粘贴这个解决scheme,而是尝试使用它作为起点。
诀窍是,mysql-smtpd-sender-login-maps.cf允许用户发送他的常规login和mysql-virtual-sender-maps.cf也让它作为他的别名发送。
我的别名表被设置,以便我有一个“组”。 也就是说,例如,当地址为[email protected]时,我可以在goto列中包含“user1 @ example.com,user2 @ example.com”。 这样,电子邮件被传送到多个目的地。 我刚刚使用了virtual_alias_maps =。
上述解决scheme可以使[email protected]和user2 @ example作为[email protected]发送
希望它可以帮助别人。 祝你好运!