LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Cannot access email via IMAP on Ubuntu 18.04 mail server (https://www.linuxquestions.org/questions/linux-newbie-8/cannot-access-email-via-imap-on-ubuntu-18-04-mail-server-4175661007/)

redd9 09-17-2019 12:00 AM

Cannot access email via IMAP on Ubuntu 18.04 mail server
 
I've set up an email server using Postfix 3.3.0 on Ubuntu 18.04, on an EC2 instance. Sending emails to and from my server and external email services (eg gmail) is working just fine.

The only issue I've run into now is accessing my email through a mail client not on my server. I installed courier-imap so I could access my email through IMAP but it keeps failing.

I am trying to use Thunderbird in which I've entered (the equivalent of) the following settings:


Incoming: IMAP
Server hostname: mail.redd9.ca
Port: 143
SSL: None
Authentication: Normal password

Outgoing: SMTP
Server hostname: mail.redd9.ca
Port: 25
SSL: None
Authentication: Normal password

Username: Incoming: redd
Outgoing: redd

This gives me 'Thunderbird failed to find the settings for your email account. I tried tweaking the ports, authentication, etc but still got the same error, even after opening up all the ports on the EC2 firewall.

Output of postconf -n is below, would appreciate any advice.
Code:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
compatibility_level = 2
home_mailbox = Maildir/
inet_interfaces = all
inet_protocols = all
mailbox_size_limit = 0
mydestination = mail.us-east-2.compute.internal, mail.redd9.ca, redd9.ca, mail, localhost.localdomain, localhost
myhostname = mail.redd9.ca
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
virtual_alias_maps = hash:/etc/postfix/virtual

Output of /etc/courier/imapd:
Code:

ADDRESS=127.0.0.1


PORT=143



MAXDAEMONS=40


MAXPERIP=20


PIDFILE=/run/courier/imapd.pid


TCPDOPTS="-nodnslookup -noidentlookup"


IMAPACCESSFILE=/etc/courier/imapaccess


LOGGEROPTS="-name=imapd"




IMAP_CAPABILITY="IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE"


IMAP_KEYWORDS=1


IMAP_ACL=1



IMAP_CAPABILITY_ORIG="IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA AUTH=CRAM-MD5 AUTH=CRAM-SHA1 AUTH=CRAM-SHA256 IDLE"


IMAP_PROXY=0



IMAP_PROXY_FOREIGN=0


IMAP_IDLE_TIMEOUT=60


IMAP_MAILBOX_SANITY_CHECK=1


IMAP_CAPABILITY_TLS="$IMAP_CAPABILITY AUTH=PLAIN"


IMAP_CAPABILITY_TLS_ORIG="$IMAP_CAPABILITY_ORIG AUTH=PLAIN"


IMAP_DISABLETHREADSORT=0


IMAP_CHECK_ALL_FOLDERS=0


IMAP_OBSOLETE_CLIENT=0


IMAP_UMASK=022


IMAP_ULIMITD=131072


IMAP_USELOCKS=1


IMAP_SHAREDINDEXFILE=/etc/courier/shared/index


IMAP_ENHANCEDIDLE=0


IMAP_TRASHFOLDERNAME=Trash


IMAP_EMPTYTRASH=Trash:7


IMAP_MOVE_EXPUNGE_TO_TRASH=0







SENDMAIL=/usr/sbin/sendmail


HEADERFROM=X-IMAP-Sender




IMAPDSTART=YES

MAILDIRPATH=Maildir


scasey 09-17-2019 12:47 AM

Is the IMAP server running and listening on port 143?
What does
Code:

netstat -tnlp | grep 143
return?

A guess: Looks like the IMAP server is configured to listen on localhost (ADDRESS=127.0.0.1).
It needs to listen on the IP address of the mail server.

Caveat: I use qmail and dovecot, not postfix and courier...but both qmail and dovecot are configured to use the public IP address of the mail server, not localhost.

redd9 09-17-2019 12:57 AM

So that did return the localhost address.


I tried changing it to the public IP of the EC2 instance, and after restarting courier-imap,
Code:

sudo netstat -tnlp | grep 143
returns nothing at all. I even rebooted the server to no avail.

scasey 09-17-2019 01:13 AM

If that netstat command returns nothing then the imap server is not running. Check the logs to find out why.

redd9 09-17-2019 01:24 AM

So I'm getting
Code:

Sep 17 06:22:16 mail imapd[1953]: bind: Cannot assign requested address
but as far as I can tell nothing else is running on 143. This is with the public IP in my /etc/courier/imapd. Changing the address to 0 seems to have the same effect. Any ideas?

EDIT: tried binding to private IP and the service is now active! netstat gave me this output:
Code:

tcp        0      0 172.31.1.20:143        0.0.0.0:*              LISTEN      2127/couriertcpd
However, still the same error in t-bird.

scasey 09-17-2019 08:00 AM

That sounds like the IP address you gave courier is not on the server, but it's hard to know from one log line.

Did you use the same IP address that postfix uses?


All times are GMT -5. The time now is 03:03 AM.