emailrelay "cannot bind the listening port"

2.9k views Asked by At

I'm setting up my web server on Amazon's EC2. My site used to run locally and used my ISP's SMTP server to send email, which hasn't been a problem before - but now that the emails are originating from outside my ISP won't accept them.

Therefore, I'm trying the advice here to use EmailRelay to forward emails, adding authentication, via my account on Google.

I've followed the instructions, created the emailrelay.auth file, run the configure, make, make install, but when I try to start the emailrelay service I'm getting this error:

$ emailrelay --as-proxy smtp.gmail.com:587 --client-tls --client-auth /etc/emailrelay.auth
emailrelay: error: cannot bind the listening port: 0.0.0.0:25
emailrelay: exception: cannot bind the listening port: 0.0.0.0:25

I've looked through the user guide, tried using the --interface option thinking this might be the issue - providing various IPs, with no joy - and I don't know what to try next.

(my server is running Oracle Enterprise Linux 5.1)

EDIT:

Since sendmail is running on port 25, I've tried an alternative port. Now I get a new error:

$ emailrelay --as-proxy smtp.gmail.com:587 --client-tls --client-auth /etc/emailrelay.auth --port 8025
emailrelay: error: cannot do tls/ssl: openssl not built in
emailrelay: exception: cannot do tls/ssl: openssl not built in

After killing sendmail, I've retried with port 25 and I get the same error ("cannot do tls/ssl: openssl not built in").

EDIT:

Looks like openssl is not installed:

$ grep ssl config.log
  $ ./configure --with-openssl
configure:7373: checking for openssl
conftest.cpp:31:25: error: openssl/ssl.h: No such file or directory
| #include <openssl/ssl.h>
configure:7431: WARNING: ignoring --with-openssl, check config.log and try setting CFLAGS
config.status:719: creating src/gssl/Makefile
2

There are 2 answers

2
Slartibartfast On BEST ANSWER

The error means that it can't gain exclusive access to port 25 (the default port for SMTP). This is either because it is already in use, or because, as an unprivileged user, you don't have access to ports numbered less than 1024.

There may already be a program running on port 25. Probably sendmail, but possibly postfix or qmail (I don't know what Oracle uses for mail). You will need to shut any such program down.

If you shut down any email software on the computer and run emailrelay as root, you will probably not get that error message.

0
Marius Butuc On

I got to this question having the same issue on an EC2 instance running Ubuntu.

For Ubuntu:

  1. first sudo apt-get install libssl-dev
  2. then (re-)run ./configure && make && sudo make install

Now either using :25 if clear, or feeding another port to emailrelay --port 12345 it works as expected.