# Fix Roundcube Webmail SMTP Settings

Roundcube webmail can't send emails due to SMTP configuration issues. Users get errors when trying to send messages through the webmail interface.

Introduction

This article covers troubleshooting steps and solutions for Fix Roundcube Webmail SMTP Settings. The error typically occurs in production environments and can cause service disruptions if not addressed promptly.

Symptoms

Common error messages include:

```php <?php // config/config.inc.php

// SMTP configuration $config['smtp_server'] = 'tls://smtp.example.com'; $config['smtp_port'] = 587; $config['smtp_user'] = '%u'; // Use current username $config['smtp_pass'] = '%p'; // Use current password $config['smtp_auth_type'] = 'LOGIN'; $config['smtp_auth_cid'] = null; $config['smtp_auth_pw'] = null; $config['smtp_secure'] = 'tls'; ```

bash
SMTP Error: Could not connect to SMTP host

```php // Check SMTP server address $config['smtp_server'] = 'tls://smtp.example.com'; // Note: tls:// prefix $config['smtp_port'] = 587;

// Or for SSL $config['smtp_server'] = 'ssl://smtp.example.com'; $config['smtp_port'] = 465;

// Or for no encryption (not recommended) $config['smtp_server'] = 'smtp.example.com'; $config['smtp_port'] = 25; ```

Common Causes

  • Configuration misconfiguration
  • Missing or incorrect credentials
  • Network connectivity issues
  • Version compatibility problems
  • Resource exhaustion or limits
  • Permission or access denied

Step-by-Step Fix

  1. 1.Check logs for specific error messages
  2. 2.Verify configuration settings
  3. 3.Test network connectivity
  4. 4.Review recent changes
  5. 5.Apply corrective action
  6. 6.Verify the fix

Understanding Roundcube SMTP Configuration

  1. 1.Roundcube uses two methods for SMTP:
  2. 2.PHP mail() function - Uses local mail server
  3. 3.SMTP server - Connects to external SMTP server

Configuration File

The main configuration is in config/config.inc.php:

```php <?php // config/config.inc.php

// SMTP configuration $config['smtp_server'] = 'tls://smtp.example.com'; $config['smtp_port'] = 587; $config['smtp_user'] = '%u'; // Use current username $config['smtp_pass'] = '%p'; // Use current password $config['smtp_auth_type'] = 'LOGIN'; $config['smtp_auth_cid'] = null; $config['smtp_auth_pw'] = null; $config['smtp_secure'] = 'tls'; ```

Common Issues and Solutions

Issue 1: SMTP Connection Failed

bash
SMTP Error: Could not connect to SMTP host

Solution:

```php // Check SMTP server address $config['smtp_server'] = 'tls://smtp.example.com'; // Note: tls:// prefix $config['smtp_port'] = 587;

// Or for SSL $config['smtp_server'] = 'ssl://smtp.example.com'; $config['smtp_port'] = 465;

// Or for no encryption (not recommended) $config['smtp_server'] = 'smtp.example.com'; $config['smtp_port'] = 25; ```

Test SMTP connectivity:

```bash # Test SMTP connection telnet smtp.example.com 587

# Test with OpenSSL openssl s_client -connect smtp.example.com:587 -starttls smtp openssl s_client -connect smtp.example.com:465 ```

Issue 2: Authentication Failed

bash
SMTP Error: Authentication failed

Solution:

```php // Use user's credentials $config['smtp_user'] = '%u'; // Current username $config['smtp_pass'] = '%p'; // Current password

// Or specify fixed credentials $config['smtp_user'] = 'webmail@example.com'; $config['smtp_pass'] = 'password';

// Set authentication type $config['smtp_auth_type'] = 'LOGIN'; // or 'CRAM-MD5', 'PLAIN', 'XOAUTH2' ```

Issue 3: SSL/TLS Certificate Issues

bash
SMTP Error: Certificate verification failed

Solution:

```php // Disable certificate verification (not recommended for production) $config['smtp_conn_options'] = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true ) );

// Or specify CA certificate $config['smtp_conn_options'] = array( 'ssl' => array( 'cafile' => '/etc/ssl/certs/ca-certificates.crt', 'verify_peer' => true, 'verify_peer_name' => true ) ); ```

Issue 4: SMTP Timeout

bash
SMTP Error: Connection timed out

Solution:

```php // Increase timeout $config['smtp_timeout'] = 60; // seconds

// Check firewall allows SMTP port // Check SMTP server is reachable ```

bash
# Test connectivity
nc -zv smtp.example.com 587

Issue 5: Wrong SMTP Port

```php // Common SMTP ports: // 25 - Standard SMTP (often blocked) // 465 - SMTPS (SSL) // 587 - Submission (TLS)

// For TLS (STARTTLS) $config['smtp_server'] = 'tls://smtp.example.com'; $config['smtp_port'] = 587;

// For SSL (SMTPS) $config['smtp_server'] = 'ssl://smtp.example.com'; $config['smtp_port'] = 465; ```

Issue 6: Local Postfix Configuration

If using local Postfix:

php
// Use local mail server
$config['smtp_server'] = 'localhost';
$config['smtp_port'] = 25;
$config['smtp_user'] = '';
$config['smtp_pass'] = '';

Configure Postfix:

```bash # /etc/postfix/main.cf smtpd_sasl_auth_enable = yes smtpd_sasl_type = dovecot smtpd_sasl_path = private/auth smtpd_recipient_restrictions = permit_sasl_authenticated, reject_unauth_destination

# Restart Postfix systemctl restart postfix ```

Issue 7: From Address Not Allowed

bash
SMTP Error: Sender address rejected

Solution:

```php // Force From address to match user $config['mail_force_default'] = true;

// Or allow user to set From $config['mail_force_default'] = false;

// Set allowed domains $config['allowed_hosts'] = array('example.com', 'mail.example.com'); ```

Complete Configuration Example

```php <?php // config/config.inc.php

// Basic settings $config['db_dsnw'] = 'mysql://roundcube:password@localhost/roundcube'; $config['default_host'] = 'tls://imap.example.com'; $config['default_port'] = 993;

// SMTP settings $config['smtp_server'] = 'tls://smtp.example.com'; $config['smtp_port'] = 587; $config['smtp_user'] = '%u'; $config['smtp_pass'] = '%p'; $config['smtp_auth_type'] = 'LOGIN'; $config['smtp_timeout'] = 60;

// SMTP connection options $config['smtp_conn_options'] = array( 'ssl' => array( 'verify_peer' => true, 'verify_peer_name' => true, 'cafile' => '/etc/ssl/certs/ca-certificates.crt' ) );

// Identity settings $config['identities_level'] = 0; // Allow multiple identities $config['mail_force_default'] = false;

// Logging for debugging $config['smtp_debug'] = true; $config['debug_level'] = 4; $config['smtp_log'] = true; ```

Debugging SMTP Issues

php
// Enable SMTP debug logging
$config['smtp_debug'] = true;
$config['debug_level'] = 4;
$config['smtp_log'] = true;

Check logs:

```bash # Roundcube logs tail -f /var/log/roundcube/errors tail -f /var/log/roundcube/smtp

# Or in Roundcube logs directory tail -f /var/www/roundcube/logs/errors.log ```

Testing SMTP Configuration

```bash # Test SMTP directly swaks --to recipient@example.com \ --from sender@example.com \ --server smtp.example.com \ --port 587 \ --tls \ --auth LOGIN \ --auth-user sender@example.com \ --auth-pass password

# Or with telnet telnet smtp.example.com 587 EHLO localhost STARTTLS AUTH LOGIN # (base64 encoded username and password) MAIL FROM: <sender@example.com> RCPT TO: <recipient@example.com> DATA Subject: Test This is a test. . QUIT ```

Integration with Postfix/Dovecot

```php // For Postfix + Dovecot setup $config['default_host'] = 'localhost'; $config['default_port'] = 143; $config['smtp_server'] = 'localhost'; $config['smtp_port'] = 25;

// Use SASL authentication $config['smtp_user'] = '%u'; $config['smtp_pass'] = '%p'; $config['smtp_auth_type'] = 'PLAIN'; ```

Verification

```bash # Check Roundcube config cat /etc/roundcube/config.inc.php | grep smtp

# Test SMTP connection telnet smtp.example.com 587

# Send test email through Roundcube # Login to webmail and compose message

# Check logs tail -f /var/log/roundcube/errors ```

Prevention

  1. 1.[ ] SMTP server address is correct
  2. 2.[ ] SMTP port matches encryption method
  3. 3.[ ] TLS/SSL prefix in server address
  4. 4.[ ] Authentication credentials are correct
  5. 5.[ ] Certificate verification configured
  6. 6.[ ] Firewall allows SMTP port
  7. 7.[ ] SMTP server accepts connections
  8. 8.[ ] Enable debug logging for issues
  9. 9.[ ] Check Roundcube error logs
  10. 10.[ ] Test SMTP with swaks or telnet
  • [Technical troubleshooting: Fix Bounce Handling Verp Envelope Return Path Conf](bounce-handling-verp-envelope-return-path-configuration)
  • [Fix Email Attachment Rejected Size Exceeding Provider Limit 25mb Issue in Email](email-attachment-rejected-size-exceeding-provider-limit-25mb)
  • [Fix Email Bounce 550 Permanent Failure Recipient Address Rejected Issue in Email](email-bounce-550-permanent-failure-recipient-address-rejected)
  • [Fix Email Dkim Signature Verification Failing After Key Rotation Issue in Email](email-dkim-signature-verification-failing-after-key-rotation)
  • [Fix Email Dmarc Policy Quarantine Message In Spam Folder Issue in Email](email-dmarc-policy-quarantine-message-in-spam-folder)

<script type="application/ld+json"> { "@context": "https://schema.org", "@type": "TechArticle", "headline": "Fix Roundcube Webmail SMTP Settings", "description": "Step-by-step guide to fix Roundcube SMTP settings. Configure SMTP server, authentication, and resolve email sending issues.", "url": "https://www.fixwikihub.com/fix-roundcube-webmail-smtp-settings", "publisher": { "@type": "Organization", "name": "FixWikiHub", "url": "https://www.fixwikihub.com" }, "author": { "@type": "Person", "name": "FixWikiHub Editorial Team" }, "datePublished": "2026-04-27T10:34:00.000Z", "dateModified": "2026-04-27T10:34:00.000Z" } </script>