Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a flag to mailbox table for enable/disable smtp protocol #796

Merged
merged 3 commits into from
Jan 10, 2024

Conversation

johnfawcett
Copy link
Contributor

Add a flag to mailbox table for enable/disbale of smtp protocol. the name of the flag is "smtp_active". This enables use of this flag instead of active flag for postfix mysql queries. There is a new configuration parameter $CONF['smtp_active_flag'] = YES or NO, which defaults to NO, providing the existing behaviour. When set to YES the active_smtp field is displayed in the edit mode and can be modified. For simplicity the flag is not shown in the table view, but this could be added. The commit includes update to the language files and documentation. The commit does not include the code to add the field to existing installs, which I presume can be added during the release
cycle in upgrade.php along the lines of:

_db_add_field('mailbox', 'smtp_active', 'int DEFAULT 1');

@DavidGoodwin
Copy link
Member

DavidGoodwin commented Jan 7, 2024

Just to be clear - this would allow you to control whether a specific mailbox can send out mail through a postfix server ?

So, if the flag was disabled for my mailbox, I'd be able to receive email from third parties fine, but I wouldn't be able to reply?

Would it be better if this wasn't behind a feature flag/config setting (smtp_active_flag = yes) , and the smtp_active value just defaults to 1 ?

@johnfawcett
Copy link
Contributor Author

Yes, it's a flag that indicates whether a mailbox is allowed to send email or not. In the as-is where this flag does not exist, postfix would typically be configured to use the active flag. Configuring the query in postfix to use the smtp_active flag allows enabling of mail sending separately from mail reading/reception.

I agree the default value of the flag should be 1. The idea behind the configuration option to turn the feature on is for better backwards compatibility. Since in order to use this flag you need to change the postfix query, having the feature turned off will prevent existing installations from seeing the flag in the GUI and being misled into thinking it was being automatically used.

@johnfawcett
Copy link
Contributor Author

johnfawcett commented Jan 7, 2024

I have simplified the documentation with a changed approach. It is possible (and arguably better and certainly simpler) to configure entirely on dovecot if using dovecot sasl in postfix. I reverted the changes on the postfix file and added some comments to the dovecot one. Only changes are documentation. The code changes in postfixadmin remain valid.

@DavidGoodwin
Copy link
Member

It might be worth rebasing your changes onto the upstream master; although I've done that myself locally and the diff seems fine.

I assume for this flag to work, the administrator must have configured the mail server to use a dovecot delivery thingy (listening on port 587 or whatever) instead of using postfix ? Could you re-add the postfix submission 'stuff' - as that might be relevant for others?

(I don't know what advantage there is to using dovecot for submission/smtp stuff over postfix, I've only ever used postfix)

@DavidGoodwin
Copy link
Member

(Sorry if I sound ungrateful - Thank You for all your work so far)

@johnfawcett
Copy link
Contributor Author

johnfawcett commented Jan 8, 2024

I'll take a look at rebasing, but I'm pretty sure the existing commits are ok. Only doubt I have is about the list view modifications, which I tested against the released version. I'll have to see if I can test against the current HEAD since I've merged with other changes.

Regarding submission, I confirm that I'm not using dovecot submission, but postfix submission. With the simplification I did on my configuration, the only change needed to use this flag is on the dovecot side. This is because postfix submission was already configured to use dovecot sasl.

If it is useful I can write something about postfix submission configuration, but it would not be related to the flag as such. Nothing in my postfix configuration now makes use of the new flag, since the task of authentication is handed off to dovecot sasl and I have configured dovecot to give a differentiated response according to the service name (smtp or not).

The preivous dovecot queries for password_query and user_query (as they were in DOVECOT.txt) have this is the WHERE condition: "AND active = '1'.

With the new flag this becomes:

AND (('%s' = 'smtp' AND smtp_active = '1') OR ('%s' <> 'smtp' AND active = '1'))

so active='1' continues to be used for everything other than smtp which now uses smtp_active = '1' instead.

…le column name

is "smtp_active". This enables use of this flag instead of active flag for postfix
mysql queries. There is a new configuration parameter $CONF['smtp_active_flag'] =
YES or NO, which defaults to NO, providing the existing behaviour. When set to YES
the active_smtp field is displayed in the edit mode and can be modified.
The commit includes update to the language files and documentation.

The commit does not include the code to add the field to existing installs,
which I presume can be added during the release cycle in upgrade.php along the
lines of:

_db_add_field('mailbox',  'smtp_active', 'int DEFAULT 1');
@johnfawcett
Copy link
Contributor Author

I rebased and squashed the previous commits into one 668960c

dovecot sasl and configuration of Postfix submission service
@johnfawcett
Copy link
Contributor Author

Commit 8a31407 contains the documentation changes to POSTFIX_CONF.txt for configuration of dovecot sasl and submission - these are valid configurations regardless of use of smtp_active flag or existing active flag in the dovecot authentication query

@DavidGoodwin
Copy link
Member

Nice work!

@DavidGoodwin DavidGoodwin merged commit 78bf7b7 into postfixadmin:master Jan 10, 2024
DavidGoodwin added a commit that referenced this pull request Jan 11, 2024
…ocal domains) and #796 (mailbox.smtp_active / controlling outbound mail etc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants