### MySQL Database Setup Example Source: https://github.com/roundcube/roundcubemail/blob/master/docs/INSTALL.md Example SQL commands to create a database, user, and grant privileges for Roundcube. ```sql CREATE DATABASE roundcubemail CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER roundcube@localhost IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON roundcubemail.* TO roundcube@localhost; quit ``` -------------------------------- ### MySQL Database Setup Source: https://github.com/roundcube/roundcubemail/wiki/Installation SQL commands to create a database and user for Roundcube with MySQL. ```sql CREATE DATABASE roundcubemail CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER username@localhost IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON roundcubemail.* TO username@localhost; ``` -------------------------------- ### PostgreSQL Database Setup Source: https://github.com/roundcube/roundcubemail/blob/master/docs/INSTALL.md Commands to create a PostgreSQL user and database for Roundcube. ```bash $ createuser -P roundcube $ createdb -O roundcube -E UNICODE roundcubemail ``` -------------------------------- ### Host-name mapping configuration example Source: https://github.com/roundcube/roundcubemail/wiki/Configuration:-Multi-Domain-Setup Example of configuring 'include_host_config' with a hash array to map host names to specific configuration files. ```php $config['include_host_config'] = array( 'mail.roundcube.net' => 'net_config.inc.php', 'mail.roundcube.com' => 'com_config.inc.php', ); ``` -------------------------------- ### Composer Configuration for LDAP Source: https://github.com/roundcube/roundcubemail/wiki/Installation Example of how to modify composer.json to include LDAP libraries for Roundcube installations. ```json { "require": { ... "pear-pear.php.net/net_ldap2": ">=2.0.12", "kolab/Net_LDAP3": "dev-master" } } ``` -------------------------------- ### Host-specific configuration example Source: https://github.com/roundcube/roundcubemail/wiki/Configuration:-Multi-Domain-Setup Example of a host-specific configuration file for Roundcube, setting IMAP host and username domain. ```php '; $config['username_domain'] = ''; ``` -------------------------------- ### Database Initialization Script Source: https://github.com/roundcube/roundcubemail/blob/master/docs/INSTALL.md Command to initialize the database using a script after manual configuration. ```bash ./bin/initdb.sh --dir=SQL ``` -------------------------------- ### SELinux Configuration for Logs and Temp Folders Source: https://github.com/roundcube/roundcubemail/blob/master/docs/INSTALL.md Sample commands to configure SELinux for Roundcube's logs and temp directories. ```bash $ semanage fcontext -a -t httpd_sys_rw_content_t "/path_to_roundcube/logs(/.*)?" $ semanage fcontext -a -t httpd_sys_rw_content_t "/path_to_roundcube/temp(/.*)?" $ restorecon -Rv /path_to_roundcube/ ``` -------------------------------- ### Build Dependencies and Update Composer Source: https://github.com/roundcube/roundcubemail/blob/master/docs/INSTALL.md Commands to build dependencies and update composer packages if not using the complete release package. ```bash make -B build ``` ```bash make -B composer-update ``` -------------------------------- ### Install Laravel Dusk Source: https://github.com/roundcube/roundcubemail/blob/master/tests/Browser/README.md Command to install Laravel Dusk with all dependencies using Composer. ```bash composer require "laravel/dusk:^7.9" ``` -------------------------------- ### Good PHP Code Example Source: https://github.com/roundcube/roundcubemail/wiki/Dev-Guidelines An example of well-formatted PHP code adhering to the specified guidelines. ```php function foo_bar($aa, $bb) { $out = ''; if ($aa == 1 || $aa > 10) { $out .= "Case one\n"; write_log("Foo: $aa"); } else { alert('Bar'); } for ($i=0; $i < $bb; $i++) { $out .= $i . 'a'; } return $out; } ``` -------------------------------- ### Addressbook Setup Script Execution Source: https://github.com/roundcube/roundcubemail/wiki/Configuration:-LDAP-Address-Books Example output from executing the rcabook-setup.sh script, which prepares the OpenLDAP server for Roundcube address book functionality. It shows the creation of base directories, an addressbook user, and subdirectories for public and private contacts. ```bash $ sudo bash rcabook-setup.sh This script prepares an openLDAP server for a simple addressbook, working "out of the box" with Roundcube: server: ldap://localhost:389 org : LDAP Addressbook Server config: /etc/ldap/slapd.conf suffix: dc=localhost rootdn: cn=admin,dc=localhost -create the openLDAP base directory: dc=localhost (as LDAP administator: cn=admin,dc=localhost) Enter LDAP Password: adding new entry "dc=localhost" -create addressbook base directory: ou=rcabook,dc=localhost (as LDAP administator: cn=admin,dc=localhost) Enter LDAP Password: adding new entry "ou=rcabook,dc=localhost" -create the addressbook user: cn=rcuser,ou=rcabook,dc=localhost (as LDAP administator: cn=admin,dc=localhost) Enter LDAP Password: adding new entry "cn=rcuser,ou=rcabook,dc=localhost" -create subdirectory for public contacts: ou=public,ou=rcabook,dc=localhost (as Roundcube user: cn=rcuser,ou=rcabook,dc=localhost) adding new entry "ou=public,ou=rcabook,dc=localhost" -create subdirectory for private addressbooks: ou=private,ou=rcabook,dc=localhost (as Roundcube user: cn=rcuser,ou=rcabook,dc=localhost) adding new entry "ou=private,ou=rcabook,dc=localhost" The LDAP addressbook is ready now for using: base_dn: ou=rcabook,dc=localhost bind_dn: cn=rcuser,ou=rcabook,dc=localhost Use the following command for reading and checking your setup: ldapsearch -xLLL -H ldap://localhost:389 -D cn=rcuser,ou=rcabook,dc=localhost -w rcpass -b ou=rcabook,dc=localhost ``` -------------------------------- ### Download and configure Composer Source: https://github.com/roundcube/roundcubemail/wiki/Build-from-source Downloads the Composer installer and sets up the composer.json file. ```sh curl -sS https://getcomposer.org/installer | php -- --install-dir=/tmp/ cp composer.json-dist composer.json ``` -------------------------------- ### Install developer tools Source: https://github.com/roundcube/roundcubemail/blob/master/docs/UPGRADING.md Command to install developer tools using npm. ```bash npm install ``` -------------------------------- ### Install Xdebug using PECL Source: https://github.com/roundcube/roundcubemail/wiki/Howto-Report-Issues Commands to install Xdebug using PECL and configure PHP to load the extension. ```bash pecl install xdebug echo "zend_extension=xdebug.so" >> /etc/php/php.ini ``` -------------------------------- ### Install JavaScript dependencies Source: https://github.com/roundcube/roundcubemail/wiki/Build-from-source Installs the necessary JavaScript dependencies for Roundcube. ```sh bin/install-jsdeps.sh ``` -------------------------------- ### Import Initial MySQL Tables Source: https://github.com/roundcube/roundcubemail/wiki/Installation Command to import the initial database tables for Roundcube using MySQL. ```sql mysql roundcubemail < SQL/mysql.initial.sql ``` -------------------------------- ### Example OAuth2 Auth Parameters Source: https://github.com/roundcube/roundcubemail/wiki/Configuration:-OAuth2 Example of how to set the 'nonce' parameter for OAuth2 authentication, as required by some servers like Outlook. ```php $config['oauth_auth_parameters'] = ['nonce' => mt_rand()]; ``` -------------------------------- ### Include Tag Example Source: https://github.com/roundcube/roundcubemail/wiki/Skin-Markup Example of how to use the 'roundcube:include' tag to include another file. ```html ``` -------------------------------- ### Build and Install Dependencies Source: https://github.com/roundcube/roundcubemail/blob/master/plugins/markdown_editor/README.md Commands to install dependencies and build the plugin's required JavaScript and CSS files. ```bash npm clean-install && npm run build ``` -------------------------------- ### meta.json Example Source: https://github.com/roundcube/roundcubemail/wiki/Skins Example structure for the meta.json file, containing metadata about the skin. ```json { "name": "", "author": "", "url": "", "license": "", "license-url": "", "localization": true, "config": [], "meta": {}, "links": {} } ``` -------------------------------- ### Variable Tag Example Source: https://github.com/roundcube/roundcubemail/wiki/Skin-Markup Example of how to use the 'roundcube:var' tag to display an environment variable. ```html ``` -------------------------------- ### Button Tag Examples Source: https://github.com/roundcube/roundcubemail/wiki/Skin-Markup Examples of using the 'roundcube:button' tag to create buttons for client commands. ```html ``` ```html ``` ```html ``` -------------------------------- ### Expression Tag Examples Source: https://github.com/roundcube/roundcubemail/wiki/Skin-Markup Examples of using the 'roundcube:exp' tag to evaluate expressions. ```html ``` ```html ``` -------------------------------- ### Install PHP dependencies using Composer Source: https://github.com/roundcube/roundcubemail/wiki/Build-from-source Installs the PHP dependencies required by Roundcube using Composer. ```sh php /tmp/composer.phar install --prefer-dist --no-dev ``` -------------------------------- ### roundcube:if/elseif/else/endif example Source: https://github.com/roundcube/roundcubemail/wiki/Skin-Markup Example demonstrating conditional inclusion/exclusion of template parts using roundcube:if tags. ```html ... ... ``` -------------------------------- ### Sample composer.json for skins Source: https://github.com/roundcube/roundcubemail/wiki/Skins An example composer.json file for publishing a Roundcube skin via Composer. ```json { "name": "/", "type": "roundcube-skin", "license": "GPL-3.0+", "require": { "roundcube/plugin-installer": ">=0.3.0" } } ``` -------------------------------- ### Install JavaScript dependencies Source: https://github.com/roundcube/roundcubemail/blob/master/docs/UPGRADING.md Script to execute for updating JavaScript dependencies. ```bash ./bin/install-jsdeps.sh ``` -------------------------------- ### Test Account Configuration Source: https://github.com/roundcube/roundcubemail/blob/master/tests/Browser/README.md Example configuration for test account username and password in config-test.inc.php. ```php $config['tests_username'] = 'roundcube.test@example.org'; $config['tests_password'] = ''; ``` -------------------------------- ### Basic Framework Usage Source: https://github.com/roundcube/roundcubemail/blob/master/program/lib/Roundcube/README.md Example demonstrating how to include the bootstrap file and initialize the rcube singleton for accessing core functionalities like IMAP storage. ```php '); define('RCUBE_PLUGINS_DIR', 'get_storage(); // do cool stuff here... ?> ``` -------------------------------- ### Database Configuration for Read/Write and Read-Only Access Source: https://github.com/roundcube/roundcubemail/wiki/Configuration:-Load-balanced-Setup Example of how to configure Roundcube's database DSNs for both read/write and read-only operations in a multi-server setup with replicated slaves. ```php // PEAR database DSN for read/write operations $config['db_dsnw'] = 'mysql://roundcube:********@dbmasterhost/roundcubemail'; // PEAR database DSN for read only operations (if empty write database will be used) $config['db_dsnr'] = 'mysql://roundcube:********@localhost/roundcubemail'; ``` -------------------------------- ### Loading distribution and local configuration files Source: https://github.com/roundcube/roundcubemail/wiki/Plugin-API This snippet demonstrates loading a distribution configuration file and then merging a local configuration file, allowing local settings to override distribution settings. ```php $this->load_config('config.inc.php.dist'); $this->load_config('config.inc.php'); ``` -------------------------------- ### Database Cleaning Script Source: https://github.com/roundcube/roundcubemail/blob/master/docs/INSTALL.md Command to clean the Roundcube database by removing deleted records. ```bash ./bin/cleandb.sh ``` -------------------------------- ### NGINX Server Configuration Source: https://github.com/roundcube/roundcubemail/wiki/Installation A sample NGINX configuration file for setting up a web server to host Roundcube, including SSL, PHP-FPM, and gzip settings. ```nginx server { listen 443 ssl; listen [::]:443 ssl; server_name roundcube.test; root /var/www/roundcubemail/public_html; ssl_certificate "/etc/ssl/certs/ssl-cert-snakeoil.pem"; ssl_certificate_key "/etc/ssl/certs/ssl-cert-snakeoil.key"; ssl_session_cache shared:SSL:1m; ssl_session_timeout 10m; ssl_ciphers PROFILE=SYSTEM; ssl_prefer_server_ciphers on;.test gzip on; gzip_types text/plain text/css text/javascript text/less image/svg+xml image/x-icon; index index.php; location / { # this block is required when using use_secure_urls=true rewrite "^/[a-zA-Z0-9]{16}/(.*)$" /$1; } location ~ \.php { # this line is required when using use_secure_urls=true rewrite "^/[a-zA-Z0-9]{16}/(.*)$" /$1; include fastcgi_params; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(/.+); fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_pass php-fpm; } } ``` -------------------------------- ### Bad PHP Code Example Source: https://github.com/roundcube/roundcubemail/wiki/Dev-Guidelines An example of PHP code that does not adhere to the specified guidelines. ```php function fooBar($aa,$bb) { if ($aa==1 || $aa>10){ $out.="Case one\n"; write_log("Foo: $aa"); } else { alert("Bar"); } for ($i=0;$i<$bb;$i++) $out.=$i."a"; return $out; } ``` -------------------------------- ### Install Chrome WebDriver Source: https://github.com/roundcube/roundcubemail/blob/master/tests/Browser/README.md Script to install Chrome WebDriver for a specified Chrome/Chromium version. ```bash php tests/Browser/install.php [version] ``` -------------------------------- ### Sample plugin client script Source: https://github.com/roundcube/roundcubemail/wiki/Plugin-API A JavaScript example demonstrating how to add a custom button to the toolbar, register it, and link it to a command handler. ```javascript rcmail.addEventListener('init', function(evt) { // create custom button var button = $('').attr('id', 'rcmSampleButton').html(rcmail.gettext('buttontitle', 'sampleplugin')); button.bind('click', function(e){ return rcmail.command('plugin.samplecmd', this); }); // add and register rcmail.add_element(button, 'toolbar'); rcmail.register_button('plugin.samplecmd', 'rcmSampleButton', 'link'); rcmail.register_command('plugin.samplecmd', sample_handler, true); }); ``` -------------------------------- ### meta.json links example Source: https://github.com/roundcube/roundcubemail/wiki/Skins Example of defining link tags within the meta.json file. ```json ... "links": { "": "", "apple-touch-icon": {"sizes": "180x180", "href": "/apple-touch-icon.png"}, "icon": [ {"type": "image/png", "sizes": "32x32", "href": "/favicon-32x32.png"}, {"type": "image/png", "sizes": "16x16", "href": "/favicon-16x16.png"} ], "manifest": "/site.webmanifest", "mask-icon": {"href": "/safari-pinned-tab.svg", "color": "#5bbad5"}, "stylesheet": [ "/branding.css", "/layout.css" ] } ... ``` -------------------------------- ### roundcube:object examples Source: https://github.com/roundcube/roundcubemail/wiki/Skin-Markup Examples of using the roundcube:object tag for dynamic content. ```html ``` -------------------------------- ### Sample Plugin Class Source: https://github.com/roundcube/roundcubemail/wiki/Plugin-API An example of a plugin class extending rcube_plugin, demonstrating the init() method for hook registration and a replace() method for message modification. ```php /** * Fancy Emoticons * * Sample plugin to replace emoticons in plain text message body with real icons * * @version 1.0 * @author Thomas Bruederli * @url http://roundcube.net/plugins/fancy_emoticons */ class fancy_emoticons extends rcube_plugin { public $task = 'mail'; private $map; function init() { $this->add_hook('message_part_after', array($this, 'replace')); $this->map = array( ':)' => html::img(array('src' => $this->urlbase.'media/smile.gif', 'alt' => ':)')), ':-)' => html::img(array('src' => $this->urlbase.'media/smile.gif', 'alt' => ':-)')), ':(' => html::img(array('src' => $this->urlbase.'media/cry.gif', 'alt' => ':(')), ':-(' => html::img(array('src' => $this->urlbase.'media/cry.gif', 'alt' => ':-(')), ); } function replace($args) { if ($args['type'] == 'plain') return array('body' => strtr($args['body'], $this->map)); return null; } } ``` -------------------------------- ### Label Tag Examples Source: https://github.com/roundcube/roundcubemail/wiki/Skin-Markup Examples of using the 'roundcube:label' tag for localized text. ```html ``` ```html ``` ```html ``` -------------------------------- ### Enabling Plugins Source: https://github.com/roundcube/roundcubemail/wiki/Plugins Example of how to enable plugins by adding their directory names to the 'plugins' configuration option in config/config.inc.php. ```php $config['plugins'] = array('additional_message_headers', 'archive'); ``` -------------------------------- ### Example: Enabling HTTPS for Secure Redirects Source: https://github.com/roundcube/roundcubemail/wiki/Configuration:-OAuth2 Configuration setting to resolve 'insecure protocol' errors when Roundcube is run behind a reverse proxy and uses HTTPS. ```php $config['use_https'] = true; ``` -------------------------------- ### Loading a plugin configuration file Source: https://github.com/roundcube/roundcubemail/wiki/Plugin-API This snippet shows how to load a plugin's configuration file using the API. ```php $this->load_config(); ``` -------------------------------- ### JavaScript Dependencies Installation Source: https://github.com/roundcube/roundcubemail/blob/master/skins/elastic/README.md Command to install required JavaScript dependencies for the skin. ```bash $ bin/install-jsdeps.sh ``` -------------------------------- ### Switch to the according branch Source: https://github.com/roundcube/roundcubemail/wiki/Build-from-source Navigates into the cloned directory and checks out a specific Roundcube version tag. ```sh cd roundcubemail-git git checkout tags/ ``` -------------------------------- ### Optionally compress CSS files Source: https://github.com/roundcube/roundcubemail/wiki/Build-from-source An optional step to compress CSS files. ```sh bin/cssshrink.sh ``` -------------------------------- ### meta.json multiple meta tags example Source: https://github.com/roundcube/roundcubemail/wiki/Skins Example of defining multiple meta tags with the same name in meta.json. ```json ... "": [{"content": "", "id": ""}, ""], ... ``` -------------------------------- ### meta.json meta tag with attributes example Source: https://github.com/roundcube/roundcubemail/wiki/Skins Example of defining meta tags with additional attributes in meta.json. ```json ... "": {"content": "", "id": ""}, ... ``` -------------------------------- ### Mailto Link Source: https://github.com/roundcube/roundcubemail/blob/master/tests/src/mailto.txt An example of an HTML anchor tag creating a mailto link with subject and body parameters. ```html e-mail ``` -------------------------------- ### Configure slapd.conf for Ubuntu Source: https://github.com/roundcube/roundcubemail/wiki/Configuration:-LDAP-Address-Books Modifies the slapd startup configuration to use a static config file instead of the dynamic config directory. ```bash SLAPD_CONF=/etc/ldap/slapd.conf SLAPD_USER="openldap" SLAPD_GROUP="openldap" ``` -------------------------------- ### Container Tag Example Source: https://github.com/roundcube/roundcubemail/wiki/Skin-Markup Example of using the 'roundcube:container' tag to define a content area for plugins. ```html
...
``` -------------------------------- ### Configure Xdebug profiler Source: https://github.com/roundcube/roundcubemail/wiki/Howto-Report-Issues Settings to enable Xdebug profiling and specify the output directory. ```ini xdebug.profiler_enable=1 xdebug.profiler_output_dir=/tmp ```