cypht
cypht copied to clipboard
Adding bulk-import accounts using csv sample file
Email Account Configuration for Cypht
This repository contains the account configuration settings for the Cypht. Unlike an approach based on directly storing configuration settings in the code (ex: config/account.php), we have opted to use a CSV file for configuring accounts.
Related Issue: https://github.com/cypht-org/cypht/issues/974
Data Isolation
By storing configuration settings in a CSV file, each user can have their own distinct configuration file. This allows for data isolation, ensuring that each user only has access to their own configured accounts and cannot access accounts configured by other users.
Example CSV File Structure:
This is the display
I chose a CSV file instead of, for example:
<?php
return [
/*
| -------------------------------------
| Constants used for auto configs servers and profiles
| -------------------------------------
|
| These accounts are used to automatically configure the server and profile
| When you add a new one don't forget to add env variables to .env file with the same name you are using here
| just make sure names are unique to avoid conflicts. ex: PERSONAL_JMAP_SERVER
| In case you are not putting env variables, you can set the value directly here
| ex: 'server_name' => 'Migadu'
|
*/
'support_server_accounts' => env('SUPPORT_AUTO_ACCOUNTS_CONFIG', false),
'server_accounts' => [
'Personal' => [
/*
| When this is set to true, only server_name, email_or_username, password and host are required
*/
'jmap_server' => env('PERSONAL_JMAP_SERVER', false),
/*
| This is the server name
| ex: Migadu, Gandi, Postale, etc...
*/
'server_name' => env('PERSONAL_SERVER_NAME', ''),
/*
| This is the server username or email
*/
'email_or_username' => env('PERSONAL_SERVER_USERNAME', ''),
/*
| This is the server password
*/
'password' => env('PERSONAL_SERVER_PWD', ''),
/*
| This is the port to used to connect to the server
*/
'port' => env('PERSONAL_SERVER_PORT', 993),
/*
| Flag to enable or disable TLS connections
*/
'tls' => env('PERSONAL_SERVER_TLS', true),
/*
| This is the host to connect to (the imap host address)
*/
'host' => env('PERSONAL_SERVER_HOST', ''),
/*
| This is used to enable or disable the smtp support for this server
*/
'support_smtp' => env('PERSONAL_SERVER_SUPPORT_SMTP', true),
/*
| if support_smtp is set to true, this is the smtp server to connect to
*/
'smtp' => [
/*
| This is the smtp server to connect to
*/
'server' => env('PERSONAL_SMTP_SERVER_HOST', ''),
/*
| This is the port to connect to the smtp server
*/
'port' => env('PERSONAL_SMTP_SERVER_PORT', 465),
/*
| Flag to enable or disable TLS connections
*/
'tls'=> env('PERSONAL_SMTP_SERVER_TLS', true)
]
],
],
];
@Shadow243 thanks for this but that's not a declarative config. You still need UI to import the csv. It also has problems with storing passwords in plain text. However, if it opens use-cases when people want to bulk-import accounts, then it is fine.
@Shadow243 thanks for this but that's not a declarative config. You still need UI to import the csv. It also has problems with storing passwords in plain text. However, if it opens use-cases when people want to bulk-import accounts, then it is fine.
Most definitely @kroky, in this case I will keep the config way too. this will be a bit tricky though for multiple users in one instance.
Any suggestions about that ?
As I suggested in #974 - user can copy either the file system settings or the db settings to another machine to make it easier to transfer multiple accounts that are already setup. I don't think we need any config updates in that case.
My 2¢, if such a plain-text file were to be introduced for this, I'd suggest using something like YAML which gives a richer structure and helps to avoid the "endless horizontal field list" that is prevalent in the world of using 2-dimensional tables (which we see with sprawling SQL tables, for example).
Just to show a snippet of the benefits of a format like YAML:
Migadu:
servers:
jmap:
hostname: jmap.abc.com
imap:
hostname: imap.abc.com
smtp:
hostname: smtp.abc.com
port: 485
tls: true
It's human-readable while offering a richer structure that is future-proofed for growth.
But I agree with the concerns around storing credentials in a plaintext file. That's a no-no.
Please also see https://wiki.mozilla.org/Thunderbird:Autoconfiguration:ConfigFileFormat and https://github.com/cypht-org/cypht/issues/470
I'm looking for a good way to parse XML file.
@josaphatim anything to change here ?
@kroky can you check please ?