Roundcube Webmail: SPF, DKIM & DMARC for Self-Hosted Mail

Roundcube never authenticates mail itself. See where SPF, DKIM and DMARC live, how to set up authenticated SMTP, and the localhost trap.
4 min read
Updated 2026-11-04
Brand Specific
roundcubespfdkimdmarcwebmail

Roundcube is a PHP application that reads mail over IMAP and sends it over SMTP. It has no signing engine, no DNS records and no opinion about authentication. Every SPF, DKIM and DMARC result on a message composed there comes from the mail transfer agent behind it — Postfix, Exim or otherwise — and your DNS records.

That distinction explains most Roundcube deliverability problems: administrators hunt for a DKIM toggle that does not exist while the fault sits in the MTA or the submission path. This guide puts the configuration in the right layer.

What you need

  • A working MTA that sends for your domain, plus Dovecot or another IMAP server.
  • DNS control for the domain in your From addresses.
  • Roundcube 1.5 or 1.6 with write access to config/config.inc.php.
  • A mailbox credential that is allowed to submit mail on port 587.

Where authentication actually happens

Three layers, three owners:

  • DKIM signing happens in the MTA, usually through OpenDKIM, rspamd or an Exim ACL. Roundcube only hands over the message.
  • SPF is evaluated against the IP that opened the SMTP connection — your server's public IP, not the browser's.
  • DMARC is a DNS policy the receiver applies to the results of the other two, measured against the From header that Roundcube wrote.

So the webmail-side work is narrow: send through an authenticated path, and keep the From domain identical to the one you sign and authorize. Everything else belongs to the server; for Postfix, the milter and key setup is in the Postfix SPF, DKIM and DMARC guide.

Step 1: confirm the MTA signs

Before changing Roundcube, prove the server signs at all. Send with swaks from the server and look for a DKIM-Signature header. If it is missing, fix the milter first — no webmail setting will add it later.

swaks --to you@gmail.com --from you@yourdomain.com --server 127.0.0.1:587 --auth LOGIN --auth-user you@yourdomain.com --tls

OpenDKIM also offers opendkim-testkey -d yourdomain.com -s mail -vvv; silence means the key and DNS record agree.

Step 2: publish the DNS side

Two records matter, both per domain rather than per mailbox:

yourdomain.com         TXT  "v=spf1 ip4:203.0.113.10 a mx ~all"
mail._domainkey.yourdomain.com  TXT  "v=DKIM1; k=rsa; p=MIIBIjANBg..."
_dmarc.yourdomain.com  TXT  "v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com"

SPF must list the IP your mail actually leaves from. If Postfix hands off to a smarthost, add its include domain and make sure it preserves your envelope sender or rewrites with SRS. Verify with the SPF Checker and the DKIM Checker, using the selector your MTA uses.

Step 3: submit through authenticated SMTP, not localhost

This setting decides whether webmail mail is authenticated properly. Roundcube's defaults often point at localhost on port 25, injecting the message into the local MTA without authentication. That works until the MTA relays through another host, treats unauthenticated mail differently, or rewrites the envelope sender — then SPF fails with no obvious cause.

Configure submission on 587 with TLS and the user's own credentials:

$config['smtp_host'] = 'tls://mail.yourdomain.com';
$config['smtp_port'] = 587;
$config['smtp_user'] = '%u';
$config['smtp_pass'] = '%p';
$config['smtp_helo_host'] = 'mail.yourdomain.com';

%u and %p pass the logged-in user's credentials, so every message is authenticated as that mailbox rather than trusted by network origin. Setting the HELO host keeps it aligned with your PTR record. For implicit TLS on 465, use the ssl:// prefix and port 465.

Step 4: publish DMARC and watch alignment

With signing and SPF in place, add a monitoring policy. p=none blocks nothing and asks receivers to send aggregate reports:

v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com; fo=1

Reports show whether webmail messages align. A common finding is DKIM passing while alignment fails, because the user picked an identity at another domain or a plugin rewrote From after signing. Read the XML with the DMARC Report Analyzer, then tighten once every legitimate source passes; the DMARC Generator builds the record for you.

Verify a webmail-sent message

Send from Roundcube to your Gmail address, then open Show original. You want spf=pass, dkim=pass with your domain in the d= value, and dmarc=pass. Paste the raw headers into the Header Analyzer if the results are hard to read, and run the Email Deliverability Test for a domain-wide view.

Common mistakes

  1. Relaying through localhost without authentication. No submission checks, no per-user accountability, and SPF breaks the moment mail is relayed through a smarthost.
  2. Using port 25 for submission. Many hosts block it, and it bypasses the authenticated path entirely. Use 587 with STARTTLS.
  3. Sending as an alias on a domain you do not sign. Identities let users pick any From address; if that domain is not in the SigningTable, DMARC fails.
  4. Letting a plugin send with PHP mail(). Those messages never touch the milter and leave unsigned.
  5. Looking for DKIM settings inside Roundcube. There are none. Fix the MTA or the DNS zone.

Frequently asked questions

Does Roundcube need its own SPF record?

No. SPF authorizes sending IPs for a domain, not applications. One record at the root covers every server that sends for it, including the one running Roundcube.

Why does webmail mail fail SPF when SMTP from a mail client works?

Almost always a different egress path. The desktop client authenticates on 587 and leaves via your server; a misconfigured Roundcube injects on localhost and the MTA may relay through a smarthost not in SPF. Compare the Received headers.

Can Roundcube sign DKIM itself?

Not natively, and no plugin is worth the maintenance burden. Signing belongs where the message leaves your infrastructure, so cron jobs, mailing lists and web forms get the same treatment.

Was this guide helpful?