How configure roundcube to work with imaps? - email

I recently installed Postfix, Dovecot to setup a mail server on my own VPS ( using this tutorial: Email with Postfix, Dovecot, Mysql)
Imaps server uses port 993 for Authentication, and Postfix uses port 25 to send mails.
In this tutorial, users stored in a Database ( so imaps use mysql to authenticate users).
i'm sure every thing works fine with imaps and postfix , because few days ago i installed Kmail client (on my linux) and receive mails from my server. sending mails also works fine, i sent a mail to Gmail and google received it without a problem (in my "Gmail inbox" not spam folder)
So to get to my Emails from a web mail client, i installed Roundcube on /var/www/mail directory.
I configured Roundcube many times. but each time it gives me this Error:
IMAP Error: Login failed for [me#mydomain] from X.x.X.x . Empty
startup greeting (localhost:993) in
/var/www/mm/program/lib/Roundcube/rcube_imap.php on line 184 (POST
/mm/?_task=login?_task=login&_action=login)
When i do log in from roundcube, imap server says ( in /var/log/mail.log ):
May 20 07:05:16 my-server dovecot: imap-login: Disconnected (no auth
attempts): rip=::1, lip=::1, TLS handshaking: Disconnected
Here is my roundcube config file :
$config['db_dsnw'] = 'mysql://roundcubeuser:myPassword#localhost/roundcubemail';
// ----------------------------------
// IMAP
// ----------------------------------
$config['debug_level'] = 13;
$config['default_host'] = 'ssl://127.0.0.1';
$config['default_port'] = 993;
// ----------------------------------
// SMTP
// ----------------------------------
$config['smtp_server'] = 'ssl://localhost';
What's the problem? i really have no idea what is happening !
Thank you.

I'm using postfix + dovecot + roundcube a few months now and it's working for me. In my configuration, postfix rejects plaintext sessions, so roundcube has to connect with ssl - and it's working.
This is from my main.inc.php. I don't remember editing anything here, it's just the initial config created during the installation.
Now that I'm looking at it, default_port doesn't make any sense, I think it's just ignored.
// To use SSL/TLS connection, enter hostname with prefix ssl:// or tls://
// Supported replacement variables:
// %n - http hostname ($_SERVER['SERVER_NAME'])
// %d - domain (http hostname without the first part)
// %s - domain name after the '#' from e-mail address provided at login screen
// For example %n = mail.domain.tld, %d = domain.tld
// TCP port used for IMAP connections
$rcmail_config['default_port'] = 143;
$rcmail_config['default_host'] = array("ssl://localhost:993");
// TCP port used for IMAP connections
$rcmail_config['default_port'] = 143;

In case the other answer does not work, this is what worked for me. My config.inc.php now contains:
$config['default_host'] = 'ssl://localhost';
$config['default_port'] = 993;
NOTE: using tls://localhost did not work for me. I had to specify ssl:// as the URI scheme.
Via PhpMyAdmin, I also ran this SQL command (all my user accounts are on the same machine that runs RoundCube):
UPDATE `rc_users` SET `mail_host`='ssl://localhost'
I got the port number 993 from running sudo netstat -tulnp in order to determine the port on which Dovecot was listening.

Related

How to configure postfix client on port 465?

I installed postfix on a server, but port 25 was blocked by ISP. I followed http://www.postfix.org/TLS_README.html#client_smtps to configure smtps on port 465.
I follow the configuration as Postfix ≥ 3.0: Sending only mail for a specific destination via SMTPS,
But I have to add mail domain to /etc/postfix/transport.
a.com relay-smtps:mx.a.com:465
b.com relay-smtps:mx.b.com:465
part of /etc/postfix/main.cf:
smtp_tls_session_cache_database = btree:/var/lib/postfix/smtp_scache
smtp_tls_security_level = may
tls_random_source = dev:/dev/urandom
smtp_tls_loglevel = 1
transport_maps = hash:/etc/postfix/transport
part of /etc/postfix/master.cf:
relay-smtps unix - - n - - smtp
# Client-side SMTPS requires "encrypt" or stronger.
-o smtp_tls_security_level=encrypt
-o smtp_tls_wrappermode=yes
For destination not in transport, postfix tries connect to port 25.
I can only send email to destination listed in transport.
How do I change the postfix so that it tries send all emails to [their own DNS MX record]:465 ?
I have tried Postfix ≥ 3.0: Sending all remote mail to an SMTPS server:
relayhost = [mx.a.com]:465
But it was regarded as spam.
If I do like:
mydomain.com :
* relay-smtps:how can use DNS MX recode auto:465
How can I specify port 465 and use DNS MX record?
Thanks!

openbsd pf : how to allow/pass out smtp traffic?

OpenBsd 6.2 - pf
I'm trying to set up an smtp relay to gmail.
since my connections are ok, i thought "ok... add smtp"... Bin non ! :/
Everything works fine if I empty /etc/pf.conf (so gmail connector is ok, /etc/mail/smtpd.conf and secrets.db too).
# OpenBSD 6.2 : pf.conf,v 1.54
int_if = "alc0"
tcp_ok = "{domain,ssh,smtp,auth,ntp,https,mysql}"
udp_ok = "{domain,ntp}"
set skip on lo
block all
pass proto tcp to any port $tcp_ok keep state
pass proto udp to any port $udp_ok keep state
Can't figure out what is wrong adding smtp port knowing that everything is ok without this service.
Thanks.
Ok...
Re-examining the logs /var/log/maillog I saw :
[...]mta event=connecting address=tls://108.177.15.16:587
So
grep -w 587 /etc/services
to get...
submission 587/tcp ... # mail message submission
submission 587/udp ... # mail message submission
Updated :
tcp_ok = "{domain,ssh,smtp,submission,auth,ntp,https,mysql}"
udp_ok = "{domain,ntp,submission}"
Reloaded pf rules :
pfctl -f /etc/pf.conf
Ok... :D

exim Timing Out to Gmail

I have a Centos server with exim installed. I am trying to send en email from the command line like this:
exim -v account#gmail.com
From: email#mydomain.com
To: account#gmail.com
Subject: test email
this is a test
^D
I have also tried:
echo 'test message' | mail -s Test1 account#gmail.com
as well as sending from a PHP script.
The result is the email times out. The logs indicate exim is timing out:
H=alt2.gmail-smtp-in.l.google.com [173.194.219.26] Connection timed out
I believe iptables are correct. I have scanned the server from an external IP and ports 25, 265 and 587 are open. (Not sure 587 needs to be since this will be a send-only situation most likely.)
I have also telnet'd to port 25 successfully. (Most of the successful resolutions I have found involved port 25 being blocked. I don't think that is the case here. I have also called my provider and checked. They claim port 25 connections are not blocked.)
I would appreciate some ideas.
Thank you.

Postfix transport: deliver different domains via different relayhosts

Postfix version 2.11.0
What I'm trying to accomplish is to have mail destined for a particular domain to be relayed through SendGrid but all other outgoing mail to be sent from my local server directly. I have this configuration in /etc/postfix/transport:
example.com smtp:[smtp.sendgrid.net]:587
.example.com smtp:[smtp.sendgrid.net]:587
* :
My understanding from all the searches I've done and reading the Postfix docs is that this should work but if I send to any other domain, for example gmail.com it's still getting relayed through SendGrid.
An example from /var/log/mail.log:
Oct 26 16:15:46 myhost postfix/smtp[25783]: A75F0C04F9: to=<PRIVACY_MASKED#gmail.com>, relay=smtp.sendgrid.net[108.168.190.108]:587, delay=11, delays=11/0.02/0.22/0.03, dsn=2.0.0, status=sent (250 Ok: queued as iTwf5zmCQQSgz_I6sVpSSA)
Is there some other configuration I'm missing?
Ok, now I see the error of my ways. In sasl_passwd I had this:
smtp.sendgrid.net USERNAME:PASSWD
But in transport I had this:
example.com smtp:[smtp.sendgrid.com]:587
The difference is .net versus .com.
Changed it to .net and works!

SMTP authentication failure while using SendGrid/Gmail

I am getting SMTP Authentication Failure on the server and the mail is getting send via the server SMTP only...
It appears to be a server configuration or related problem, but I am not sure.
This is the debug details:
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
Failed to authenticate password. Error: 535 Incorrect authentication data
from: 250 OK
to: 250 Accepted
data: 354 Enter message, ending with "." on a line by itself
250 OK id=1U8Pjp-0002As-FB
quit: 221 ************** closing connection
Your message has been successfully sent using the following protocol: smtp
While testing from my local system, this works and the email is being sent via sendgrid.me
Again, This may not be a SendGrid Problem, but if you have faced similar issue, Can you please tell me what is the problem here?
I am using CentOs and I have cPanel in the server. I believe we are using EXIM for mail server.
For anyone that comes across this in future and are using cpanel/whm, you need to 'disable' this option under 'SMTP Restrictions' in WHM.
I was able to resolve this.
The issue was my server was not allowing the use of external SMTP and using its own SMTP server. I changed the settings and now it works fine.
I am using centos 7 Finally it works!
I was getting this issue(tail -f /var/log/mailog):
to=<usmanali#example.com>, relay=smtp.sendgrid.net[169.45.113.201]:587, delay=0.3, delays=0.05/0.07/0.16/0.02, dsn=5.0.0, status=bounced (host smtp.sendgrid.net[169.45.113.201] said: 550 Unauthenticated senders not allowed (in reply to MAIL FROM command))
Then i changed file /etc/postfix/main.cf in this way that added following lines into end of file
mtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
mailbox_size_limit = 256000000
# Sendgrid Settings
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = static:apikey:SG.YOUR_SENDGRID_KEY
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
header_size_limit = 4096000
relayhost = [smtp.sendgrid.net]:587
Then Installing postfix missing module dependency using:
sudo yum install cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain
Then restarting postfix
sudo systemctl restart postfix.service