Author Topic: [SOLVED] Remote SMTP connection not working  (Read 17113 times)

Offline Connor0308

  • Newbie
  • *
  • Posts: 3
[SOLVED] Remote SMTP connection not working
« on: January 12, 2016, 03:41:49 PM »
Dear all,

I set up a roundcube installation on my server. The installation is running smoothly when using the serverside mailserver via IMAP and SMTP.
As I also have an external email account with mail.de, I also tried to get it served by roundcube via IMAP and SMTP.
I can see the emails in my inbox, but when I am trying to send mails via SMTP (both SSL using port 465 and TLS using port 587), I receive an error in ~/logs/errors saying

Quote
ERROR: fsockopen(): unable to connect to ssl://smtp.mail.de:465 (Unknown error) (0)
ERROR: Failed to connect socket: fsockopen(): unable to connect to ssl://smtp.mail.de:465 (Unknown error) ()

After changing the connection to port 25 without encryption, the error changes to

Quote
[12-Jan-2016 18:37:57 +0000]: <8a31c240> SMTP Error: Authentication failure: Invalid response code received from server (Code: 535) in ~/program/lib/Roundcube/rcube.php on line 1712 (POST /?_task=mail&_unlock=loading1452623885938&_lang=de_DE&_framed=1?_task=mail&_action=send)
[12-Jan-2016 18:38:38 UTC] ERROR: Invalid response code received from server (535)

In no other logfile on my system I can see any entry that is related to the connection attempt.
So from my point of view, there has to be a configuration problem.
Thank you for your help,
best regards,

Philip

Quote
Roundcube:           1.1.4

Installed PlugIns:

acl
carddav
emoticons   
filesystem_attachments   
identity_select   
identity_smtp
jqueryui   
markasjunk   
newmail_notifier   
password   
rc_smime
show_pgp_mime
twofactor_gauthenticator   dev-master
userinfo
vcard_attachments   
zipdownload   

Server: vServer CentOS 6.7 with cPanel and WHM access

Quote
config file:
<?php

/* Local configuration for Roundcube Webmail */

// ----------------------------------
// SQL DATABASE
// ----------------------------------
// Database connection string (DSN) for read+write operations
// Format (compatible with PEAR MDB2): db_provider://user:password@host/database
// Currently supported db_providers: mysql, pgsql, sqlite, mssql or sqlsrv
// For examples see http://pear.php.net/manual/en/package.database.mdb2.intro-dsn.php
// NOTE: for SQLite use absolute path: 'sqlite:////full/path/to/sqlite.db?mode=0646'
$config['db_dsnw'] = 'mysql://user, password, host';

// ----------------------------------
// IMAP
// ----------------------------------
// The mail host chosen to perform the log-in.
// Leave blank to show a textbox at login, give a list of hosts
// to display a pulldown menu or set one host as string.
// To use SSL/TLS connection, enter hostname with prefix ssl:// or tls://
// Supported replacement variables:
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %s - domain name after the '@' from e-mail address provided at login screen
// For example %n = mail.domain.tld, %t = domain.tld
// WARNING: After hostname change update of mail_host column in users table is
//          required to match old user data records with the new host.
$config['default_host'] = array('ssl://mail.domain1'=>'domain1',
            'ssl://imap.mail.de'=>'mail.de'
            );

// TCP port used for IMAP connections
$config['default_port'] = 993;

// ----------------------------------
// SMTP
// ----------------------------------
// SMTP server host (for sending mails).
// To use SSL/TLS connection, enter hostname with prefix ssl:// or tls://
// If left blank, the PHP mail() function is used
// Supported replacement variables:
// %h - user's IMAP hostname
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %z - IMAP domain (IMAP hostname without the first part)
// For example %n = mail.domain.tld, %t = domain.tld
$config['smtp_server'] = 'tls://mail.domain1';

// SMTP port (default is 25; use 587 for STARTTLS or 465 for the
// deprecated SSL over SMTP (aka SMTPS))
$config['smtp_port'] = 587;

// SMTP username (if required) if you use %u as the username Roundcube
// will use the current username for login
$config['smtp_user'] = '%u';

// SMTP password (if required) if you use %p as the password Roundcube
// will use the current user's password for login
$config['smtp_pass'] = '%p';

// provide an URL where a user can get support for this Roundcube installation
// PLEASE DO NOT LINK TO THE ROUNDCUBE.NET WEBSITE HERE!
$config['support_url'] = '';

// automatically create a new Roundcube user when log-in the first time.
// a new user will be created once the IMAP login succeeds.
// set to false if only registered users can use this service
$config['auto_create_user'] = true;

// use this folder to store temp files
// must be writeable for the user who runs PHP process (Apache user if mod_php is being used)
$config['temp_dir'] = 'location';

// this key is used to encrypt the users imap password which is stored
// in the session record (and the client cookie if remember password is enabled).
// please provide a string of exactly 24 chars.
$config['des_key'] = 'key';

// Automatically add this domain to user names for login
// Only for IMAP servers that require full e-mail addresses for login
// Specify an array with 'host' => 'domain' values to support multiple hosts
// Supported replacement variables:
// %h - user's IMAP hostname
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %z - IMAP domain (IMAP hostname without the first part)
// For example %n = mail.domain.tld, %t = domain.tld
$config['username_domain'] = 'domain1';

// ----------------------------------
// PLUGINS
// ----------------------------------
// List of active plugins (in plugins/ directory)
$config['plugins'] = array(
   'acl',
   'emoticons',
   'identity_select',
   'markasjunk',
   'newmail_notifier',
   'password',
   'userinfo',
   'vcard_attachments',
   'zipdownload',
   'show_pgp_mime',
   'carddav',
   'twofactor_gauthenticator',
   'identity_smtp',
   'jqueryui',
   'rc_smime',
);

// the default locale setting (leave empty for auto-detection)
// RFC1766 formatted language name like en_US, de_DE, de_CH, fr_FR, pt_BR
$config['language'] = 'de_DE';

// store spam messages in this mailbox
// NOTE: Use folder names with namespace prefix (INBOX. on Courier-IMAP)
$config['junk_mbox'] = 'SPAM';
« Last Edit: January 13, 2016, 12:24:35 PM by Connor0308 »

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Re: Remote SMTP connection not working
« Reply #1 on: January 12, 2016, 04:27:32 PM »
Does it work with all of the plugins disabled? Have you checked to see if the firewall is allowing the connection?

Offline Connor0308

  • Newbie
  • *
  • Posts: 3
Re: Remote SMTP connection not working
« Reply #2 on: January 13, 2016, 09:25:24 AM »
Thank you for your swift feedback.
I checked it with a fresh installation and found the same issues as with the existing installation.
To track down the issue a little more, I enabled "full" SMTP-logs.
Within this one, I can see that the SMTP-configuration used with the "identity_smtp" plugin isn't called at all, so the remote SMTP server isn't contacted.
Which is the best option to have multiple (let's say a handfull) SMTP configurations done (tls://%h isn't working for me, as my provider has different subdomains for imap and smtp access)?

Thank you for your feedback,
best regards,

Connor

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Re: Remote SMTP connection not working
« Reply #3 on: January 13, 2016, 11:28:54 AM »
Maybe you could try using the multidomains setup: http://trac.roundcube.net/wiki/Howto_Config/Multidomains

Offline Connor0308

  • Newbie
  • *
  • Posts: 3
Re: Remote SMTP connection not working
« Reply #4 on: January 13, 2016, 12:23:36 PM »
That did it for me - plugin uninstalled and working with the mentioned multidomain configuration now.
Just as a hint for noobs like me that might be looking for a solution here:

Remember that you need to have a default host array defined ($config['default_host'] = array('ssl://host.domain1'=>'domain1', 'ssl://host.domain2'=>'domain2');) before you can switch to host config ($config['include_host_config'] = array) as described.

Thank you for your support,
best regards,

Connor