Receiving email with Amazon EC2? - email

I have no trouble sending out email with my EC2 server, but how can I check the email that is sent to me? I have an elastic IP setup and modified reverse DNS records. Do I need to install Postfix to receive email?

Ensure that port 25 is active and open on your server. Install an SMTP service on your instance ...postfix is mighty fine.
Ensure you have also set up some MX records if you want to receive email from the world...

I suppose the first thing to do is testing if you can open a telnet connection to port 25 on your server. Then you know if anything is listening for incoming mail.
If not, then you should probably install postfix as well as test your firewall settings (I seem to recall the EC2 having some sort of firewall setting for which ports to allow in the web interface)
edit: correct port number

Related

The IP you're using to send mail is not authorized 550-5.7.1 to send email directly to our servers

I am new to DO and I have tried to look for solution online but I didn't find any answer. I am using Ubuntu OS 20.04(LTS)X64 version.
My question is that I have 2 droplets, MailServer droplet where I have installed docker composer and mailcow to run mail mails, and another droplet named WebServer hosting my domains. I have also set up all required DS records under my domain added on WebServer droplet and pointed A record mail.mydomail.com to the IP of mail server droplet. However, whenever I try sending emails they all bounce back unless the ones sending between mydomain users(user1#mydomain.com & user2#mydomain.com). It just says that "The IP you're using to send mail is not authorized.....".
Any support to help me solve this issue will be highly appreciated. An I am wondering if that approach is possible or if there is any documentation on how someone can set up dns records on one server and configure mailserver on another server using digitalocean.
Here is how I set my DNS on mydomain.com to point to MailServer IP

Can I run an email Server with a fixed IP only?

I created a web app to do some basic content management for just myself. I want to mail some docs to the server instead of downloading then uploading them. Ive been looking at postfix but everything assumes you have a domain. Is it possible to receive email at a server with a fixed ip and no domain?
if you want anybody and any app to be able to send mail you need MX records in DNS. And MX records point at dns server names, not IP addresses.
https://serverfault.com/questions/663112/why-cant-mx-records-point-to-an-ip-address
If its just you then you can telnet to the SMTP port to send mail

Postfix attempting to bind to port 25, used for outgoing mail only (maybe not necessary?)

Not sure if this belongs on Stack Overflow or somewhere else but I'll try here first.
I have multiple servers, each with the same setup where nearly everything running on the server is in a docker container. I have two goals I would like to achieve. First, the host machine is setup to send emails for users with uid < 1000 to my external email address. Second, on one server, I have a docker-mailserver container running to handle random, seldom used emails (for log files, etc.).
It seems I can have either the host machine running postfix OR the docker-mailserver running (and bound to port 25). Currently, I have the docker container, running the mail server, full operational and everything can send and receive just fine.
However, now I am unable to start postfix on the host machine so that I can receive emails sent to the root user (things like cron output) since port 25 is --rightfully-- in use by the actual mail server receiving email.
Questions:
1) How can I tell postfix on the host to not bind to port 25? If port 25 is only used for receiving mail, why would my outgoing-only postfix config need to use port 25?
2) I am perfectly comfortable not receiving emails for the root user, if whatever would normally be sent to the root user is logged elsewhere (perhaps, syslog?). Are the emails to root only maintained as emails or are they somewhere else, negating the need for postfix on the host for forwarding to a real account?
Thanks in advance.
Specifically answering your questions first:
You should be able to have postfix listen on any port you specify by editing the main.cf configuration file and changing the smtp listener to a numbered port of your choice. Of course, if it isn't a "known" port, I'm not sure what/who will ever connect to it, but maybe you don't care in this situation as you are only using postfix as a relay?
It may depend some on the Linux distribution or setup of your host, but most systems will leave email in the local delivery "mail spool" if there is no system/daemon set up to move it anywhere else. Back when that was the normal way to handle multi-user mail on UNIX systems, a login user used a mail reader client to read through email in your local "spool", and of course if you don't have that, you can simply vi your mail file and read the raw contents if necessary. These mail files are normally located in /var/spool/mail on most systems.
Stepping away from your questions, I would guess you don't necessarily need postfix running on your host, especially as your containerized mailserver is handling the port 25 SMTP traffic for the host. Local email will stay local, I assume, without postfix, and be available through local means; and you might even find a simpler solution to external forwarding (e.g. a script that can parse mail spools and just connect to an SMTP relay and send it to an external address) if you want that.

Configure CSF to allow outbound SMTP

I have a web app that sends email via SMTP (Gmail, Zoho Mail servers). The thing is, the email sending works in my localhost but not on my VPS (using WHM).
I contacted support and the guy replied:
If your VPS has ConfigServer Firewall (CSF) installed then this would
most likely be causing the problem. As it is working on localhost but
not externally this certainly sounds like it might be the case. You
will need to review the firewall configuration on the VPS and ensure
hose ports are allowed outbound.
But when it comes to server management and configuration, I'm totally lost. I did check the CSF settings page on WHM but not sure where to start.
Any recommendation or solution would be appreciated.
You have to allow outgoing traffic to ports 25, 465, 587 and in the case of Mandrill 2525 as will. You should actually be fine enabling only the one you will connect to. So:
sudo vim /etc/csf/csf.conf
add 25,2525,465,587 to TCP_OUT, and to TCP6_OUT if you use IPv6.
You might also need to remove that ports from SMTP_PORTS if you have SMTP_BLOCK enabled (if it is set to 1).
Source: https://community.centminmod.com/threads/csf-firewall-info.25/#post-6613

Mail not getting send to specific domains

We have a VPS with CentOS combined with DirectAdmin which we use for a Magento shop. This runs fine, except for sending email.
Problem:
It appears that some specific domains won't receive our emails and we get a bounce. If we use any other email sending systems, the mails arrive without problems.
The bounce mail contains the following error:
SMTP error from remote mail server after HELO Company-Shops:
host mx-cluster-b2.one.com [IP ADRESS]: 504 5.5.2 :
Helo command rejected: need fully-qualified hostname
After googling and trying things for a week now, I am a bit lost. I tried checking postfix in CentOS, but this is not installed and I'm not quite sure if this is needed.
Possible issue?
I believe the hostfile in CentOS is setup incorrectly:
127.0.0.1 localhost localhost.localdomain localhost4 ... etc
OUR IP Company-Shops
'Company-Shops' should probably be a domain name, am I right? The same as the rDNS. But I'm afraid if I change this it will kill my site and whatnot. I'm not sure if this entry correlates with the 'company-Shops' helo label in the bounce error.
Some extra info:
- We use the webmail Roundcube from DirectAdmin
- At the moment we run one shop, but this might grow a bit (multiple sites on 1 IP)
- We don't use subdomains
- We've set up a reverse DNS, with the domain
Is there anyone with similiar experiences or with a bit more knowledge about this subject? I appreciate any advice we can get, as we are stuck..
Many thanks.
Yes, that's right: your mail server should identify itself using a fully-qualified domain name when it connects to send mail via SMTP. You don't say what mail server you're running, but since you're using DA, it's probably Exim. If so, you want to edit /etc/exim.conf and set primary_hostname to the FQDN of your server.
This would also be a good time to double-check that reverse DNS is set up properly for your IP address. Many hosts will also reject email from servers on IPs without a valid rDNS record.
I'm not familiar with Magento, but I can't see any way that changing the Exim configuration in this way could impact that program.