0

My current Postfix setup allows to send emails only with the local users (like, if I logged as xyz then email will be sent as xyz@server.com). I have Courier IMAP server, with the same user xyz but with different password, from the other place.

Now I want to setup RoundCube (RC) as a webmail client but, unfortunately, it doesn't allow to use different passwords for IMAP & SMTP (when you logging in to IMAP as abc then RC will use abc and its password used for IMAP to send emails). What I need - I want to setup Postfix in the way that it has dedicated user for sending emails, so all mail users will use the same SMTP account (but emails should be sent as their own accounts, say they will use account mailer@server.com to connect to SMTP server and then email will be sent as xyz@server.com). In this case I can setup RC to use that dedicated account for sending.

How to achieve that?

Green Root
  • 133
  • 5
  • I suspect you are focusing on one particular solution, while the underlying problem could be solved without compromising your auditing capabilities by mingling those together. There is no requirement whatsoever for the SMTP login name to match the envelope and/or header address, and no requirement for mail accounts to share a credentials with local user accounts. So why do you believe you should resolve this in Roundcube, as opposed to just having the authentication match? – anx Aug 28 '22 at 23:42

1 Answers1

1

Roundcube uses the username and password of the IMAP account for authentication to the SMTP server if you have configured it that way, which is probably the default of Roundcube.

// 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';

You can also configure Roundcube to use the login data only for the login to the IMAP account, but to send all emails via a specific SMTP server. For the SMTP server you can also configure data for authentication, but in case of e.g. localhost you could do without it.

Just configure the fields smtp_host, smtp_user and smtp_pass:

// SMTP server host (for sending mails).
// See defaults.inc.php for the option description.
$config['smtp_host'] = 'localhost:587';

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

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

The configuration can be done in the file config/config.inc.php.


If you have done this configuration, all emails of all users sent through this roundcube instance will be sent through this SMTP server, with exactly this authentication.

So it is clear that this does not work if you specify the SMTP credentials e.g. from a GMail account, because Google (as well as other freemail providers) check that the sender of the mail matches the account when sending the mail.

phanaz
  • 295
  • 2
  • 8