# Postfix +dovecot +roundcube



## manti (Jan 26, 2012)

Hello

Send mail from roundcube to some e-mail:

[CMD=""]tail -f /var/log/maillog[/CMD]

```
Jan 26 11:06:50 xall dovecot: auth(default): client out: OK     1       user=user
Jan 26 11:06:50 xall dovecot: auth(default): master in: REQUEST 8       55611   1
Jan 26 11:06:50 xall dovecot: auth-worker(default): passwd(user,127.0.0.1): lookup
Jan 26 11:06:50 xall dovecot: auth(default): master out: USER   8       user     system_groups_user=user 
 uid=1004        gid=1004        home=/home/user
Jan 26 11:06:50 xall dovecot: imap-login: Login: user=<user>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, TLS
Jan 26 11:06:54 xall postfix/smtpd[55624]: connect from localhost[127.0.0.1]
Jan 26 11:06:54 xall dovecot: auth(default): new auth connection: pid=55624
Jan 26 11:06:54 xall postfix/smtpd[55624]: [color="Red"]lost connection after UNKNOWN from localhost[127.0.0.1][/color]
Jan 26 11:06:54 xall postfix/smtpd[55624]: disconnect from localhost[127.0.0.1]
Jan 26 11:06:54 xall dovecot: IMAP(user): Disconnected: Logged out bytes=12/336
```

Use alpine and send e-mail to some e-mail:
[CMD=""]tail -f /var/log/maillog[/CMD]

```
user 26 11:24:59 xall dovecot: imap-login: Login: user=<user>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, TLS
user 26 11:25:03 xall dovecot: IMAP(user): Disconnected: Logged out bytes=44/395
user 26 11:26:31 xall postfix/smtpd[56109]: connect from localhost[127.0.0.1]
user 26 11:26:31 xall postfix/smtpd[56109]: 9EB8D1CD7B: client=localhost[127.0.0.1]
user 26 11:26:32 xall postfix/smtpd[56109]: disconnect from localhost[127.0.0.1]
user 26 11:26:33 xall postfix/pickup[55750]: 699F81CDD2: uid=1004 from=<user@mydomain.com>
user 26 11:26:33 xall postfix/cleanup[56111]: 699F81CDD2: message-id=<alpine.BSF.2.00.1201261126140.56107@mydomain.com>
user 26 11:26:34 xall postfix/qmgr[55456]: 699F81CDD2: from=<user@mydomain.com>, size=605, nrcpt=1 (queue active)
user 26 11:32:24 xall postfix/smtpd[56181]: connect from localhost[127.0.0.1]
user 26 11:32:28 xall dovecot: auth(default): new auth connection: pid=56181
user 26 11:32:32 xall postfix/smtpd[56181]: E31E71CD7B: client=localhost[127.0.0.1]
user 26 11:32:32 xall postfix/cleanup[56184]: E31E71CD7B: message-id=<alpine.BSF.2.00.1201261131430.56107@mydomain.com>
user 26 11:32:32 xall postfix/smtpd[56181]: disconnect from localhost[127.0.0.1]
user 26 11:32:36 xall postfix/qmgr[55456]: E31E71CD7B: from=<user@mydomain.com>, size=573, nrcpt=1 (queue active)
user 26 11:34:43 xall postfix/smtpd[56201]: connect from localhost.mydomain.com[127.0.0.1]
user 26 11:34:45 xall postfix/smtpd[56201]: A0DC91CDDF: client=localhost.mydomain.com[127.0.0.1]
user 26 11:34:45 xall dovecot: auth(default): new auth connection: pid=56201
user 26 11:34:46 xall postfix/cleanup[56203]: A0DC91CDDF: message-id=<alpine.BSF.2.00.1201261126140.56107@mydomain.com>
user 26 11:34:46 xall postfix/smtpd[56201]: disconnect from localhost.mydomain.com[127.0.0.1]
user 26 11:34:47 xall postfix/qmgr[55456]: A0DC91CDDF: from=<user@mydomain.com>, size=1052, nrcpt=1 (queue active)
user 26 11:34:53 xall amavis[38171]: (38171-09) Passed CLEAN {RelayedOpenRelay}, <user@mydomain.com> -> <name.lastname@gmail.com>,
 Message-ID: <alpine.BSF.2.00.1201261126140.56107@mydomain.com>, mail_id: kQhHQSvYYiIO, Hits: -1, size: 605, queued_as: A0DC91CDDF,
 480857 ms
user 26 11:34:54 xall postfix/smtp[56113]: 699F81CDD2: to=<name.lastname@gmail.com>, relay=127.0.0.1[127.0.0.1]:10024, delay=503,
 delays=3/2.5/34/464, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as A0DC91CDDF)
user 26 11:34:55 xall postfix/qmgr[55456]: 699F81CDD2: removed
user 26 11:34:57 xall postfix/smtp[56204]: certificate verification failed for gmail-smtp-in.l.google.com[173.194.65.26]:25: untrusted issuer
 /C=US/O=Equifax/OU=Equifax Secure Certificate Authority
user 26 11:35:01 xall postfix/smtpd[56201]: connect from localhost.mydomain.com[127.0.0.1]
user 26 11:35:01 xall postfix/smtpd[56201]: 2E8771CE1F: client=localhost.mydomain.com[127.0.0.1]
user 26 11:35:01 xall postfix/cleanup[56203]: 2E8771CE1F: message-id=<alpine.BSF.2.00.1201261131430.56107@mydomain.com>
user 26 11:35:01 xall postfix/smtpd[56201]: disconnect from localhost.mydomain.com[127.0.0.1]
user 26 11:35:01 xall postfix/qmgr[55456]: 2E8771CE1F: from=<user@mydomain.com>, size=992, nrcpt=1 (queue active)
user 26 11:35:03 xall amavis[38493]: (38493-06) Passed CLEAN {RelayedOpenRelay}, [127.0.0.1] <user@mydomain.com> -> <manti@somedomain.com>,
 Message-ID: <alpine.BSF.2.00.1201261131430.56107@mydomain.com>, mail_id: JwaUs_M3nRS9, Hits: -1, size: 573, queued_as: 2E8771CE1F, 127734 ms
user 26 11:35:03 xall postfix/smtp[56185]: E31E71CD7B: to=<manti@somedomain.com>, relay=127.0.0.1[127.0.0.1]:10024, delay=153, delays=4.9/2.4/38/107,
 dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 2E8771CE1F)
user 26 11:35:03 xall postfix/qmgr[55456]: E31E71CD7B: removed
user 26 11:35:07 xall postfix/smtp[56204]: A0DC91CDDF: to=<name.lastname@gmail.com>, relay=gmail-smtp-in.l.google.com[173.194.65.26]:25, 
delay=22, delays=2.1/1.4/12/6.6, dsn=2.0.0, status=sent (250 2.0.0 OK 1327575499 z18si2414533eeh.205)
user 26 11:35:07 xall postfix/qmgr[55456]: A0DC91CDDF: removed
user 26 11:35:17 xall postfix/smtp[56206]: 2E8771CE1F: to=<manti@somedomain.com>, relay=somedomain.com[10.20.30.40]:25, delay=17, 
delays=0.19/0.84/8.5/7.2, dsn=2.0.0, status=sent (250 OK queued as QzECbK)
user 26 11:35:17 xall postfix/qmgr[55456]: 2E8771CE1F: removed
```

Mail is sent.

Next.
 RE: from some domain to mydomain:

[CMD=""]tail -f /var/log/maillog[/CMD]

```
user 26 11:36:06 xall postfix/smtpd[56235]: connect from somedomain.com[10.20.30.40]
user 26 11:36:06 xall dovecot: auth(default): new auth connection: pid=56235
user 26 11:36:09 xall postfix/smtpd[56235]: A078B1CD7B: client=somedomain.com[10.20.30.40]
user 26 11:36:10 xall postfix/cleanup[56203]: A078B1CD7B: message-id=<1c01e22.7a9b15a2.4f2131f7.a9629@o2.pl>
user 26 11:36:10 xall postfix/qmgr[55456]: A078B1CD7B: from=<manti@somedomain.com>, size=1114, nrcpt=1 (queue active)
user 26 11:36:10 xall postfix/smtpd[56235]: disconnect from somedomain.com[10.20.30.40]
user 26 11:37:14 xall postfix/smtpd[56263]: connect from localhost.mydomain.com[127.0.0.1]
user 26 11:37:14 xall dovecot: auth(default): new auth connection: pid=56263
user 26 11:37:14 xall postfix/smtpd[56263]: 96DBA1CDD2: client=localhost.mydomain.com[127.0.0.1]
user 26 11:37:14 xall postfix/cleanup[56203]: 96DBA1CDD2: message-id=<1c01e22.7a9b15a2.4f2131f7.a9629@o2.pl>
user 26 11:37:14 xall postfix/smtpd[56263]: disconnect from localhost.mydomain.com[127.0.0.1]
user 26 11:37:14 xall postfix/qmgr[55456]: 96DBA1CDD2: from=<manti@somedomain.com>, size=1541, nrcpt=1 (queue active)
user 26 11:37:15 xall amavis[38171]: (38171-10) Passed CLEAN {RelayedOpenRelay}, [10.20.30.40] <manti@somedomain.com> -> <user@mydomain.com>,
 Message-ID: <1c01e22.7a9b15a2.4f2131f7.a9629@o2.pl>, mail_id: UNiRo3yxmqhw, Hits: 0.001, size: 1114, queued_as: 96DBA1CDD2, 63968 ms
user 26 11:37:15 xall postfix/local[56264]: 96DBA1CDD2: to=<user@mydomain.com>, relay=local, delay=1.4, delays=0.44/0.44/0/0.51, dsn=2.0.0,
 status=sent (delivered to mailbox)
user 26 11:37:16 xall postfix/qmgr[55456]: 96DBA1CDD2: removed
user 26 11:37:16 xall postfix/smtp[56113]: A078B1CD7B: to=<user@mydomain.com>, relay=127.0.0.1[127.0.0.1]:10024, delay=68, delays=2/0.03/0.85/65,
 dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 96DBA1CDD2)
user 26 11:37:16 xall postfix/qmgr[55456]: A078B1CD7B: removed
```

It's work. 

But why Roundcube does not work? 

[CMD=""]tail -f /var/log/maillog[/CMD]

```
Jan 26 11:48:13 xall postfix/smtpd[56389]:
 lost connection after UNKNOWN from localhost[127.0.0.1]
```

Please help.

[CMD=""]postconf -n[/CMD]

```
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
broken_sasl_auth_clients = yes
command_directory = /usr/local/sbin
config_directory = /usr/local/etc/postfix
content_filter = amavis:[127.0.0.1]:10024
daemon_directory = /usr/local/libexec/postfix
data_directory = /var/db/postfix
debug_peer_level = 2
html_directory = /usr/local/share/doc/postfix
mail_owner = postfix
mail_spool_directory = /var/mail
mailq_path = /usr/local/bin/mailq
manpage_directory = /usr/local/man
max_use = 10
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mydomain.com, www.mydomain.com
myhostname = mydomain.com
mynetworks_style = host
newaliases_path = /usr/local/bin/newaliases
queue_directory = /var/spool/postfix
readme_directory = /usr/local/share/doc/postfix
sample_directory = /usr/local/etc/postfix
sendmail_path = /usr/local/sbin/sendmail
setgid_group = maildrop
smtp_tls_note_starttls_offer = yes
smtp_use_tls = yes
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination,reject_non_fqdn_hostname,
reject_non_fqdn_sender,
reject_non_fqdn_recipient,reject_unauth_pipelining,reject_invalid_hostname,reject_unknown_sender_domain
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain =
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_tls_CAfile = /etc/ssl/certs/dovecot.pem
smtpd_tls_cert_file = /etc/ssl/certs/dovecot.pem
smtpd_tls_key_file = /etc/ssl/private/dovecot.pem
smtpd_tls_loglevel = 0
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
tls_random_source = dev:/dev/urandom
unknown_local_recipient_reject_code = 550
```


----------



## manti (Jan 26, 2012)

/usr/local/etc/postfix/master.cf


```
smtps     inet  n       -       n       -       -       smtpd
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  -o message_size_limit=26214400
amavis  unix    -       -       y       -       2       smtp
    -o smtp_data_done_timeout=1200
    -o disable_dns_lookups=yes
127.0.0.1:10025 inet    n       -       y       -       -       smtpd
    -o content_filter=
    -o local_recipient_maps=
    -o relay_recipient_maps=
    -o smtpd_restriction_classes=
    -o smtpd_client_restrictions=
    -o smtpd_helo_restrictions=
    -o smtpd_sender_restrictions=
    -o smtpd_recipient_restrictions=permit_mynetworks,reject
    -o mynetworks=127.0.0.0/8
    -o strict_rfc821_envelopes=yes
    -o smtpd_error_sleep_time=0
    -o smtpd_soft_error_limit=1001
    -o smtpd_hard_error_limit=1000
    -o smtpd_client_connection_count_limit=0
    -o smtpd_soft_error_limit=1001
    -o smtpd_hard_error_limit=1000
    -o smtpd_client_connection_count_limit=0
    -o smtpd_client_connection_rate_limit=0
    -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks
```

[CMD=""]dovecot -n[/CMD]


```
# 1.2.17: [FILE]/usr/local/etc/dovecot.conf[/FILE]
# OS: FreeBSD 8.2-STABLE i386
protocols: imap pop3 imaps pop3s
disable_plaintext_auth: no
login_dir: /var/run/dovecot/login
login_executable(default): /usr/local/libexec/dovecot/imap-login
login_executable(imap): /usr/local/libexec/dovecot/imap-login
login_executable(pop3): /usr/local/libexec/dovecot/pop3-login
verbose_proctitle: yes
first_valid_uid: 1000
first_valid_gid: 1000
mail_location: maildir:~/Maildir
mail_executable(default): /usr/local/libexec/dovecot/imap
mail_executable(imap): /usr/local/libexec/dovecot/imap
mail_executable(pop3): /usr/local/libexec/dovecot/pop3
mail_plugin_dir(default): /usr/local/lib/dovecot/imap
mail_plugin_dir(imap): /usr/local/lib/dovecot/imap
mail_plugin_dir(pop3): /usr/local/lib/dovecot/pop3
imap_client_workarounds(default): delay-newmail netscape-eoh tb-extra-mailbox-sep
imap_client_workarounds(imap): delay-newmail netscape-eoh tb-extra-mailbox-sep
imap_client_workarounds(pop3):
pop3_client_workarounds(default):
pop3_client_workarounds(imap):
pop3_client_workarounds(pop3): outlook-no-nuls oe-ns-eoh
lda:
  sendmail_path: /usr/sbin/sendmail
auth default:
  mechanisms: plain login
  username_format: %Lu
  debug: yes
  passdb:
    driver: pam
    args: session=yes dovecot
  userdb:
    driver: passwd
    args: blocking=yes
  socket:
    type: listen
    client:
      path: /var/spool/postfix/private/auth
      mode: 432
      user: postfix
      group: postfix
```


/usr/local/www/roundcube/main.inc.php


```
$rcmail_config['default_host'] = 'localhost';
$rcmail_config['default_port'] = 143;
$rcmail_config['imap_auth_type'] = null;
$rcmail_config['smtp_server'] = 'localhost';
$rcmail_config['smtp_port'] = 25; or 465
```


----------



## redw0lfx (Jan 26, 2012)

Are you sending email from mail/roundcube as the user you are logged in as?  Are you mail/roundcoube smtp values defined correctly to pass in the username and password that was provided by the user?

/usr/local/www/roundcube/main.inc.php

```
$rcmail_config['smtp_user'] = '%u';
$rcmail_config['smtp_pass'] = '%p';
$rcmail_config['smtp_helo_host'] = 'localhost.localdomain';
```


----------



## manti (Jan 26, 2012)

No, I have empty this options:

/usr/local/www/roundcube/main.inc.php


```
$rcmail_config['smtp_user'] = '';
$rcmail_config['smtp_pass'] = '';
$rcmail_config['smtp_helo_host'] = '';
```

I log in successful http://mydomain/roundcube/ and tries to send e-mail to user@somedomain.com.


----------



## redw0lfx (Jan 27, 2012)

A quick google resulted in the following closed bug report #1486130 for RoundCube


```
PEAR::Mail_SMTP does not support tls:// prefix. Don't use it. If server responds with STARTTLS capability, tls is used by default.
```

It looks like you might be using TLS

```
Jan 26 11:06:50 xall dovecot: imap-login: Login: user=<user>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, TLS
Jan 26 11:06:54 xall postfix/smtpd[55624]: connect from localhost[127.0.0.1]
```


----------



## manti (Jan 27, 2012)

redw0lfx said:
			
		

> A quick google resulted in the following closed bug report #1486130 for RoundCube
> 
> 
> ```
> ...



Yes I have TLS, but this bug was 2 years ago..


----------



## Abriel (Jan 27, 2012)

Did you try with 
	
	



```
// if left blank, the PHP mail() function is used
$rcmail_config['smtp_server'] = '';
```
but mail() is not safe.

In my case, I have

```
$rcmail_config['smtp_server'] = 'ssl://mydomain.com';
$rcmail_config['smtp_port'] = 465;
$rcmail_config['smtp_user'] = '%u';
$rcmail_config['smtp_pass'] = '%p';
$rcmail_config['smtp_auth_type'] = 'PLAIN';
```


----------



## manti (Jan 27, 2012)

ok

1.

Config roundcube is:


```
/usr/local/www/roundcube/config/*.php
```

Not this:


```
[color="Red"]/usr/local/www/roundcube/main.inc.php[/color]
```
x(

2. 

/usr/local/www/roundcube/config/main.inc.php


```
$rcmail_config['default_host'] = 'ssl://localhost';
$rcmail_config['default_port'] = 993;
$rcmail_config['imap_auth_type'] = null;
$rcmail_config['smtp_server'] = 'ssl://localhost';
$rcmail_config['smtp_port'] = 465;
```


Everything works.


----------



## manti (Jan 27, 2012)

Abriel said:
			
		

> Did you try with
> 
> 
> 
> ...



OK, Thanks I change it.


----------

