5

I have recently set up a mail server that consists of postfix and dovecot. Yesterday I added nginx and roundcube to the mix. SPF, DKIM, DMARC, rDNS records are all done. Gmail treats my mail as valid and delivers it to my inbox. Everything is working. Except one little annoying thing.

When I use Android's built-in MUA or other MUA's, everything is still fine. The problem begins when I want to send mail using roundcube. The mail is still verified and delivered correctly, but without subject. Somehow roundcube is losing the subject field and sending my e-mails without the subject.

I have been searching for an answer for 7 hours straight, however it seems like I am the only person in the world that is experiencing this problem. This makes me think that something is wrong with my server or configs or something, but I quadruple-checked all of my configs and I am still clueless.

Any help will be highly useful. Thanks in advance for your time.

My mail server is on an OpenVZ box with 768MB RAM, running CentOS 7 Minimal. Postfix version: 2.10.1 Dovecot version: 2.2.10 Roundcube version: 1.1.0

My postconf -n output:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
disable_vrfy_command = yes
html_directory = no
inet_interfaces = all
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = localhost
myhostname = mail.example.com
newaliases_path = /usr/bin/newaliases.postfix
non_smtpd_milters = unix:/var/run/opendkim/opendkim.sock
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
sample_directory = /usr/share/doc/postfix-2.10.1/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtpd_data_restrictions = reject_unauth_pipelining
smtpd_delay_reject = no
smtpd_helo_required = yes
smtpd_helo_restrictions = reject_unknown_helo_hostname, reject_non_fqdn_helo_hostname, reject_invalid_helo_hostname
smtpd_milters = unix:/var/run/opendkim/opendkim.sock
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = private/auth
smtpd_sasl_type = dovecot
smtpd_sender_restrictions = reject_unknown_sender_domain
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/pki/dovecot/certs/dovecot.pem
smtpd_tls_key_file = /etc/pki/dovecot/private/dovecot.pem
smtpd_use_tls = yes
strict_rfc821_envelopes = yes
unknown_local_recipient_reject_code = 550
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_transport = lmtp:unix:private/dovecot-lmtp

My Roundcube config excerpt at config/config.inc.php:

$config['debug_level'] = 5;
$config['db_dsnw'] = 'mysql://user:pass@localhost/database';
$config['default_host'] = 'tls://localhost';
$config['default_port'] = 993;
$config['smtp_server'] = 'tls://localhost';
$config['smtp_port'] = 587;
$config['ip_check'] = true;
$config['identities_level'] = 3;
$config['des_key'] = 'some key';
$config['mime_types'] = '/usr/share/nginx/html/roundcube/mime.types';
$config['preview_pane'] = true;
Bugra Koc
  • 121
  • 7
  • Any error in php log? – masegaloeh Feb 27 '15 at 07:40
  • Also, you can compare the email in **sent Folder** and **email received in other inbox** – masegaloeh Feb 27 '15 at 07:45
  • Not even a single php error. error_reporting is set to E_ALL and display_errors is on, and only php-fpm start/stop NOTICEs are in the log. And when I compare the email in the sent folder and the email that is received in other inbox, none of them has a subject. I tried sending to different providers (i.e. gmail, yahoo) and no subject is delivered. – Bugra Koc Feb 27 '15 at 12:44
  • 2
    Sorry, I can't reproduce your case. Anyway the code who responsible to generate the **Subject header** was lied in `program/steps/mail/sendmail.inc` line 196. You can insert the debug line like `$headers['Subject'] .= 'mycustomstring';` in line 197. – masegaloeh Feb 28 '15 at 03:34
  • Thanks for the heads up! I will tinker with the sendmail.inc. – Bugra Koc Feb 28 '15 at 09:03

1 Answers1

1

I have found the solution to my own question.

Below are the lines 507-513 from program/steps/mail/sendmail.inc.

// encoding subject header with mb_encode provides better results with asian characters
if (function_exists('mb_encode_mimeheader')) {
    mb_internal_encoding($message_charset);
    $headers['Subject'] = mb_encode_mimeheader($headers['Subject'],
        $message_charset, 'Q', "\r\n", 8);
    mb_internal_encoding(RCUBE_CHARSET);
}

This is one of the two places that mentions $headers['Subject'] variable. The other one is line 196 which sets the variable.

Since neither me nor my clients have nothing to do with asian characters, I decided to comment this code block out and see what happens, and voila! Subjects started working. It seems roundcube has a weird bug. I hope this will help someone someday.

Bugra Koc
  • 121
  • 7