跳到正文
Email Servers

Brand Roundcube Webmail per Domain on a Shared Mail Server

Put one PNG per webmail hostname in a branding folder, then set skin_logo in config.inc.php from $_SERVER['SERVER_NAME'] with a placeholder fallback.

测试环境 Roundcube 1.6, Elastic skin

When one server hosts mail for several businesses, each customer should see their own brand on the webmail login page – not yours. Roundcube can switch the logo automatically based on the hostname the user visits, such as webmail.customer-a.com or mail.customer-b.com.

Step 1 – Create a branding folder

Terminal
sudo mkdir -p /var/www/roundcube/branding

Adjust the path if Roundcube is installed elsewhere.

Step 2 – Add one logo per webmail hostname

Upload a PNG for each domain, named exactly after the hostname users visit, plus a default:

Files
/var/www/roundcube/branding/webmail.customer-a.com.pngn/var/www/roundcube/branding/mail.customer-b.com.pngn/var/www/roundcube/branding/placeholder.png

Step 3 – Choose the logo in config.inc.php

Terminal
sudo nano /var/www/roundcube/config/config.inc.php

Add:

config.inc.php
// Per-domain logo: branding/u003chostnameu003e.png, else placeholder.pngn$host = preg_replace( '/[^a-z0-9.-]/', '', strtolower( $_SERVER['SERVER_NAME'] ?? '' ) );n$logo = $host . '.png';nif ( $host u0026u0026 file_exists( __DIR__ . '/../branding/' . $logo ) ) {n    $config['skin_logo'] = '../../branding/' . $logo;n} else {n    $config['skin_logo'] = '../../branding/placeholder.png';n}

The hostname is sanitised before it is used in a file path, so a crafted Host header can’t point Roundcube at other files.

Step 4 – Test

Open each webmail address in a private window – the login page shows that customer’s logo, and unknown hostnames fall back to the placeholder.

Recent Roundcube versions

Roundcube 1.5+ also accepts per-skin and per-template logos as an array, e.g. $config['skin_logo'] = [ 'elastic:login' => '…', '*' => '…' ];. Combine it with the hostname logic above if you want a different login-page logo.

Inder Kochar

作者

Inder Kochar

系统与网络工程师 – 我把为客户使用的解决方案整理成文,并在真实系统上测试过。遇到类似问题了吗?

继续阅读

提出问题或分享您的解决方法

您的邮箱不会公开。评论需经审核——请围绕主题发言。