0

First i just want to say that im a total noob when it comes to mail servers, and it might be something obvious wrong that just make me look stupid posting this.

I have been trying to setup a mail server on my azure ubuntu server for the first time and have been struggling now for alot of hours. Im running Apache2, php7, mysql, phpmyadmin for my webserver and that is working.

Over the last day I've installed: Postfix, Dovecot, SpamAssassin, ClamAV, Sieve and Roundcube. And then followed numberous of guides to get it all configured. Everything is up and running.

I've now gotten to the point where im logged in to Roundcube to test everything. But, i cant send or receive any mail. I can't even send a mail to the same mail address im logged in to. The only error message in the log files are

SMTP Error (553): Failed to add recipient "mail@rajohan.no" (5.7.1 : Sender address rejected: not logged in)

So my guess is that there is a problem with the firewall. Either in UFW or the one on the azure portal. Maybe bought. They should have the same ports opened. Ive included some outputs underneath that show which ports that are open. Or maybe theres a problem with my DNS records.

Do i have to open more ports then 25 to get the email server to work? And do i have to set it open in tcp and udp? And if i do have to open more ports, which should i open?

The mailserver is also set up with a SSL sertificate that's paid for. Some outputs are added below that might help.

Ufw Status

Apache Full                ALLOW       Anywhere 
Postfix                    ALLOW       Anywhere 
22/tcp                     ALLOW       Anywhere
25/tcp                     ALLOW       Anywhere 
3389/tcp                   ALLOW       Anywhere 
Apache Full (v6)           ALLOW       Anywhere (v6) 
Postfix (v6)               ALLOW       Anywhere (v6) 
22/tcp (v6)                ALLOW       Anywhere (v6) 
25/tcp (v6)                ALLOW       Anywhere (v6) 
3389/tcp (v6)              ALLOW       Anywhere (v6)

Net Stat

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address    Foreign Address  State    PID/Program name
tcp        0      0 127.0.0.1:5910   0.0.0.0:*        LISTEN   2782/Xvnc
tcp        0      0 127.0.0.1:3350   0.0.0.0:*        LISTEN   1823/xrdp-sesman
tcp        0      0 0.0.0.0:22       0.0.0.0:*        LISTEN   1537/sshd
tcp        0      0 0.0.0.0:25       0.0.0.0:*        LISTEN   2155/master
tcp        0      0 0.0.0.0:3389     0.0.0.0:*        LISTEN   1814/xrdp
tcp        0      0 0.0.0.0:4190     0.0.0.0:*        LISTEN   1439/dovecot
tcp        0      0 0.0.0.0:993      0.0.0.0:*        LISTEN   1439/dovecot
tcp        0      0 127.0.0.1:3306   0.0.0.0:*        LISTEN   1562/mysqld
tcp        0      0 0.0.0.0:587      0.0.0.0:*        LISTEN   2155/master
tcp        0      0 0.0.0.0:25324    0.0.0.0:*        LISTEN   1978/ruby
tcp        0      0 0.0.0.0:143      0.0.0.0:*        LISTEN   1439/dovecot
tcp6       0      0 :::22            :::*             LISTEN   1537/sshd
tcp6       0      0 :::25            :::*             LISTEN   2155/master
tcp6       0      0 :::443           :::*             LISTEN   2196/apache2
tcp6       0      0 :::4190          :::*             LISTEN   1439/dovecot
tcp6       0      0 :::993           :::*             LISTEN   1439/dovecot
tcp6       0      0 :::587           :::*             LISTEN   2155/master
tcp6       0      0 :::143           :::*             LISTEN   1439/dovecot
tcp6       0      0 :::80            :::*             LISTEN   2196/apache2

DNS records

Hostname   TTL   RR-Type  Parameters   Data
rajohan.no  1hour  A  - 52.232.21.85
rajohan.no 24hours MX 10 mail.rajohan.no
rajohan.no  24 hours TXT - "v=spf1 mx a ?all"
mail.rajohan.no 24 hours A - 52.232.21.85
mail._domainkey.rajohan.no 24 hours TXT - "v=DKIM1; h=sha256; k=rsa; s=email; "       "p=M......"

Telnet localhost 25

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mail.rajohan.no ESMTP
  • Doubt it's firewall related if Roundcube is getting an SMTP response. The not logged in error suggests you have Postfix configured to require authentication when sending email (usually a good choice), but Roundcube isn't configured to send login details to the SMTP server when sending emails. It's a bit strange as I suspect you have this all on one server and usually you'd have connections without auth enabled from localhost, but would need to see the Postfix config to see how the restrictions are configured. – USD Matt Dec 19 '17 at 9:07
  • You need to check in your roundcube/apache logs to check for errors in the php and roundcube. If that shows nothing then the postfix logs should – user3788685 Dec 19 '17 at 9:09
  • Everything is running on the same server. master.cf: pastebin.com/miViZZsm , main.cf: pastebin.com/ePgK3Lgm – Rajohan Dec 19 '17 at 9:12
  • Roundcube error logs: pastebin.com/vycXQnPL – Rajohan Dec 19 '17 at 9:17
  • Could you please add your roundcube configuration as well? – Gerald Schneider Dec 19 '17 at 9:38
0

Your RoundCube configuration seems to be missing all the variables related to SMTP. That's most probably the reason why you get the not logged in error message.

Here are the values straight from my RoundCube installation (I have basically the same setup):

// IMAP AUTH type (DIGEST-MD5, CRAM-MD5, LOGIN, PLAIN or null to use
// best server supported one)
$config['imap_auth_type'] = 'LOGIN';

$config['smtp_server'] = 'tls://mail.example.com';
$config['smtp_user'] = '%u';
$config['smtp_pass'] = '%p';
// SMTP AUTH type (DIGEST-MD5, CRAM-MD5, LOGIN, PLAIN or empty to use
// best server supported one)
$config['smtp_auth_type'] = 'LOGIN';

You may have to adapt the auth type to your setup.

  • Got the login error go away but now im getting a new one. The roundcube page are trying to load/connect when i click send. In the roundcube error log i found [19-Dec-2017 09:59:53 UTC] ERROR: Connection timed out (110) [19-Dec-2017 09:59:53 UTC] ERROR: Failed to connect socket: Connection timed out () [19-Dec-2017 09:59:53 +0000]: <58561qbh> SMTP Error: Connection failed: Failed to connect socket: Connection timed out in /var/www/rajohan.no/www/roundcube/program/lib/Roundcube/rcube.php on line 1667 (POST /roundcube/?_task=mail&_unlock=loading1513677534827&_lang=en&_framed=1&_action=send) – Rajohan Dec 19 '17 at 10:03
  • Gerald is right. Your SMTP configuration might be missing those details. Usually code 5.7.1 means that the user doesn't exist since it first could even authenticate. I know your user is created and does exist but upon setting the right settings, you should be fine. – Phil Dec 19 '17 at 10:21
  • Yeah, when I added the lines Gerald suggested it looks like its trying to send the mail. But the roundcube page is just stuck in a loading/connecting state after clicking send. And then the roundcube error log outputs the error I pasted above under Gerald's suggestion. – Rajohan Dec 19 '17 at 10:24
  • You have to restart the related services for changes to take effect. To cut it short, restart the server and try again. – Phil Dec 19 '17 at 10:54
  • I've tryed restart the server multiple times. Also opned ports 993/tcp, 587/tcp, 465/tcp. Still getting the Connection failed: Failed to connect to socket error. – Rajohan Dec 19 '17 at 11:04
-2

If you cannot send mail, the problem is likely a restriction by your ISP (Internet Service Provider) as many block the normal sendmail port 25, due to their own security concerns. This can be the case even if sending was working recently as some ISP's roll these changes through without warning.

To give you an idea of how common port 25 blocking is, we've included below links to a few major ISP's and their online documentation regarding port 25 blocking:

  • 2
    There is absolutely no indication that the problem is related to a blocked port. – Gerald Schneider Dec 19 '17 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.