PHP code example of bennet0496 / nextcloud_attachments
1. Go to this page and download the library: Download bennet0496/nextcloud_attachments library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bennet0496 / nextcloud_attachments example snippets
// Full URL to the Nextcloud server
// e.g. https://example.com/nextcloud if in subpath
// or https://cloud.example.com if in root
$config["nextcloud_attachment_server"] = "";
// Username resolving strategy from internal Roundcube
// username which usually is the email address e.g. [email protected] or IMAP User
// Placeholders are replaced as following
// %s => verbatim RC username as reported by rcmail->get_user_name(). Depending on config loginuser@domain or login
// %i => username used to log in to imap. usually equal to %s (since 1.3)
// %e => user email (since 1.3)
// %l, %u => email local part (%u is for backward compatibility to <1.3) (since 1.3)
// %d => email domain (since 1.3)
// %h => IMAP Host (since 1.3)
$config["nextcloud_attachment_username"] = "%u";
// Name for the sub-folder to upload to
// Defaults to "Mail Attachments"
// Can't be sub-folder of sub-folder link folder/sub
//
// The folder name can also be translated according to the users configured locale
// by setting the value to a locale-keyed array like
// ["en_US" => "Mail Attachments", "de_DE" => "E-Mail Anhänge"]
// If locale doesn't exist, en_US or first will be used
$config["nextcloud_attachment_folder"] = "Mail Attachments";
// Folder Layout
// "flat" => Flat folder layout, everything in the Folder
// "date:format" => Create folder hierarchy according to format. See https://unicode-org.github.io/icu/userguide/format_parse/datetime/
// Use "/" as the folder separator. Defaults to date:Y/LLLL
// Dateformat is localized
// "hash:algo:depth" => Use "algo"-hash of file, creating sub folder for every of the "depth" bytes
// see https://www.php.net/manual/en/function.hash-algos.php
// Defaults to hash:sha1:2
// Defaults to flat
$config["nextcloud_attachment_folder_layout"] = "flat";
// Don't try the email password at all, because we know it won't work
// e.g. due to mandatory 2FA
// Defaults to false, i.e. try the password
// Since version 1.3
$config["nextcloud_attachment_dont_try_mail_password"] = false;
// Message size limit. Note that SMTP server(s) may use a different value.
// This limit is verified when user attaches files to a composed message.
// Size in bytes (possible unit suffix: K, M, G)
$config['max_message_size'] = '25M';
// Limit to show a warning at for large attachments.
// has to be smaller than $config['max_message_size']
// set to null to disable
$config["nextcloud_attachment_softlimit"] = "12M";
// Behavior if $config['max_message_size'] is hit.
// "prompt" to show dialog a la outlook or apple
// "upload" to automatically upload without asking a la google
// Defaults to "prompt"
$config["nextcloud_attachment_behavior"] = "prompt";
// Generated password length
// Passwords will be alphanumerical strings with upper and lower case letters and numbers
// Defaults to 12
$config["nextcloud_attachment_password_length"] = 12;
// The alphabets from which to generate password
// It is guaranteed that at least one character of each set is used,
// as long as password_length > |password_alphabets|
// Default: ["123456789", "ABCDEFGHJKLMNPQRSTUVWXYZ", "abcdefghijkmnopqrstuvwxyz"]
// (Lookalikes are 0O and Il are excluded)
$config["nextcloud_attachment_password_alphabets"] = ["123456789", "ABCDEFGHJKLMNPQRSTUVWXYZ", "abcdefghijkmnopqrstuvwxyz"];
// Don't try the email password at all, because we know it won't work
// e.g. due to mandatory 2FA
// Defaults to false, i.e. try the password
// Since version 1.3
$config["nextcloud_attachment_dont_try_mail_password"] = false;