Setting up DNS MX Entry on Digital Ocean - email

I want to use DO as my DNS Server. For emails I use 1and1 and I setup the Nameserver Configuration in the Domain control panel to use the DO Nameserver.
In DO I added an MX entry:
But is this the correct way? If I use one of my email I set up, do I need to configure it differently? If I send an email, nothing is being received in my inbox. For example the mail test#isarfaktor.de
How do I need to configure DO to handle emails with 1and1 properly?
Thank you

You didn't mentioned the Operating system of your Virtual Private Server.
First, you have to setup your server using postfix if you follow my method.
Approx 29% of public mail servers on the internet run very popular opensource mail transfer agent Postfix.Its helps to route and deliver email on a Linux system.
Make sure you have set up the domain with the ip already.
Now install post fix
sudo apt-get update
sudo apt-get install postfix
it will ask for domain name put your domain like this - farukkadir.com without any prefix like www.
now you have to edit postfix config by put this command
sudo nano /etc/postfix/main.cf
find myhostname = something.com and edit with your domain
If you would like to configuring mail to be forwarded to other domains or wish to deliver to addresses that don't map 1-to-1 with system accounts, you can remove the alias_maps parameter and replace it with virtual_alias_maps. We would then need to change the location of the hash to /etc/postfix/virtual:
virtual_alias_maps = hash:/etc/postfix/virtual
and to get a webui install open source squirrel mail -
If you still need help just comment here

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

No Such User Here VPN/WHM with Mail Routed through Separate Server

Ok, I am using a VPN on GoDaddy for webhosting. But on one of the websites that I am hosting, the email is handled on a separate VPN.
So I have an A record for domain.com set to the GoDaddy VPN and an A record for mail.domain.com set to the IP of the other domain and several CNAMES pointed to that A record. It's all working beautifully except for one thing....
Email from other domains on the GoDaddy VPN cannot send to this domain. So myemail#mydomain.com cannot send to email#separateemailvpn.com
I get error "No Such User Here" from my server.
I understand that the GoDaddy VPN is checking for that user locally and not finding it, but I don't know how to make it NOT check for this domain.
I am using WHM/cPanel with Exim and SpamAsassin. Thanks!
Not sure what the deal is with the downvotes, but here was my solution (probably obvious).
From Linux Terminal:
sudo su (for admin rights)
nano /etc/localdomains (erase domain from local domains)
nano /etc/remotedomains (add domain to remote domains)
Now it doesn't check that domain for users locally before it sends it out to the remote server.
Changing the mail exchanger on the server is relatively easy from WHM too. In WHM left menu, navigate to "DNS Functions >> Edit MX Entry". From there, simply select the domain name you wish to edit, and then select the desired mail exchanger to change the mail routing settings for the domain.
The options are Auto, Local Mail Exchanger, Backup Mail Exchanger, or Remote Mail Exchanger. Set to "Remote Mail Exchanger" and click Save to have WHM update the /etc/localdomains and /etc/remotedomains for you.

Is it necessary to have domain name for installing postfix in ubuntu virtual server?

I have a Ubuntu LAMP server in virtual box. I want to install postfix for sending and receiving mail using the server.
Is it compulsory to have a domain name to my ip address for installing postfix and using it for mailing purposes?
You should be able to set up Postfix for local forwarding/exchange with just an IP address - that should be no problem. Sending email to other email servers, however, probably won't work as many email servers do reverse DNS lookup on the FQDN to verify the server isn't on a blacklist somewhere.

How to setup SSMTP on Debian/Respbian for domain other than GMail

Folks....I posted this question on the Raspberry Pi forum and got no replies. Hopefully you can help me?
I'm using a Raspberry Pi B+ running Raspbian OS.
I have set up e-mail using this link: http://rpi.tnet.com/project/faqs/smtp
sudo apt-get install ssmtp
sudo apt-get install mailutils
sudo apt-get install mpack
and then configured it like this
#
# Config file for sSMTP sendmail
#
root=me#mydomain.com
# The full hostname
hostname=MyRasPi
AuthUser=me#gmail.com
AuthPass=myGmailpw
FromLineOverride=YES
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES
#AuthUser=me#mydomain.com
#AuthPass=mypw
#mailhub=mail.mydomain.com:465
The above setup works and the test line
echo "sample text" | mail -s "Subject" myid#hotmail.com
works with the note arriving at my Hotmail account.
But, in fact, I do not want to use Google's Gmail system. I have my own domain and mail server.
I modified the above ssmtp.conf to use the hash-ed out lines to replace the Gmail lines. When I use Outlook I have to configure my outgoing (SMTP) server "requires authentication" and needs to use SSL and port 465. When I now try the above mail command it just hangs and I have to control-C to get back to the command line prompt.
What am I doing wrong? Thanks...RDK
I know I am late to the party, but this is this reason this didn't work for you:
Port 465 doesn't use STARTTLS (which is basically first connecting with a plaintext connection and then switching to TLS), but directly establishes a SSL/TLS connection.
So you should probably use the following options:
UseTLS=YES
UseSTARTTLS=NO
However, this is still completely insecure:
I wanted to use ssmtp today too, but noticed that it does NOT verify the SSL/TLS certificate of the remote server on the current debian & ubuntu releases and also does NOT verify the hostname of the certificate. This is a major issue, as this effectively renders the encryption useless and your password is being transmitted alike to being plaintext and anyone can sniff it. This has also been reported in a debian bug, but there has not been any progress for years: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=662960
The ssmtp version in the Redhat packages has been patched to atleast verify the certificate, but the hostname is still NOT being verified and the encryption is therefore as insecure as on debian/ubuntu. There is a bug for this, but there is also no progress for years: https://bugzilla.redhat.com/show_bug.cgi?id=864894
So, if you care about the security of the email account you use for your servers outgoing emails, do NOT use ssmtp.
ssmtp has had no active development since atleast 2009: https://anonscm.debian.org/gitweb/?p=ssmtp/ssmtp.git
After researching other solutions, like nullmailer and msmtp, I decided to settle on using postfix, as it is so much easier to set up and can easily be configured for just outgoing mails, and it's easy to use just the features you need without it acting as a full MTA.
Here is an example with the most important postfix settings for this: https://unix.stackexchange.com/questions/116805/how-to-install-postfix-for-sending-mails-to-admin-only/118101#118101
try to use postfix to configure gmail forward. Somehow ssmtp is not compatible with gmail anymore, even the account has enabled authentication by less secure application.
see the tutorial below:
https://www.howtoforge.com/tutorial/configure-postfix-to-use-gmail-as-a-mail-relay/
http://www.algissalys.com/network-security/send-email-from-raspberry-pi-command-line

sendmail and MX records when mail server is not on web host

This is a problem I'm sure is easy to fix, but I've been banging my head on it all day.
I'm developing a new web site for a client. The web site resides at (this is an example) website.com. I have a PHP form script to email visitors' requests to requests#website.com.
When I coded this on a staging server on a different domain, all worked fine. When I moved it to website.com, the mail messages never arrived. The web server is on a virtual host with a major ISP.
Here's what I've learned since then: My client's mail server is Microsoft Exchange on a box physically in their office. Whenever someone on the outside world emails requests#website.com, the mail arrives. But if the web server sends to the same email address, it fails every time. This is not a PHP problem. I secure shell in to the web server and have tested this both with sendmail and the UNIX mail application. I've also tested it by emailing various email accounts from the shell. I can email myself, for example, just nobody at the website.com domain.
In short, when I'm logged in to website.com, mail to requests#website.com, user#website.com, another_user#website.com all fail. All other addresses work fine. What I've discovered is those dropped emails are routed to the web server's "catchall" account where they sit in its inbox.
I've done an MX lookup on website.com. The MX record points to mailsec.website.com. I can telnet to mailsec.website.com port 25 and see the SMTP server.
It appears to me that website.com isn't doing an MX lookup when it's sending mail to requests#website.com. My theory is that it recognizes the domain as local, sees that there's no "requests" user account to deliver it to, and drops the mail into the catchall account. What I want is to force sendmail to do the MX lookup and send the message on to the Exchange server. I'm at wit's end here. I can't figure out how to do this.
For that matter, I may be way off base here and have misdiagnosed this entirely. Internet mail and MX has always seemed a black art to me, and my ignorance is certainly showing in this question.
I think the problem is that sendmail (your process) is talking to the local sendmail daemon. The local sendmail daemon thinks that because it is website.com, it should know how to deliver the email. Unfortunately, the actual address in the to field does not exist on the web server and thus it dumps it in the "catchall" mail box. You should talk to your ISP and have them update their sendmail configuration so that mail addressed to ...#website.com gets forward to the mail exchanger instead of being handled locally.
Sendmail by default guesses list of local email domains.
It can be turned off using the following line in your sendmail.mc file:
define(`confDONT_PROBE_INTERFACES',`True')
As root list local email domains before and after the change using:
echo '$=w' | sendmail -Am -bt
You will see which domains should be added "manually" to (usually) /etc/mail/local-host-names file after disabling auto-guessing.
After changing sendmail.mc:
Generate/compile new sendmail.cf file
Restart sendmail daemon (or send HUP signal)
tvanfosson basically has it, but as a temporary workaround, you should be able to change your script so that it mails 'user#mailsec.website.com', and then the mail will get delivered to the actual mail server.
Edit the tsm.cf file (in /etc/mail/ or similar) to include
FEATURE(relay_entire_domain)
between the DOMAIN() and MAILER() lines. Since you're editing the file, you may want to also improve security with
define(`confPRIVACY_FLAGS',``noexpn,novrfy'')
After changing the tsm.cf file (or any sendmail config file), restart or SIGHUP the sendmail process.
This change is necessary because the WWW and MX servers for the domain do not exist in the same process space; this FEATURE triggers sendmail to process messages for the domain using it's external delivery mechanism.
The edited portion of the tsm.cf file should look similar to this:
DOMAIN(website.com)dnl
FEATURE(relay_entire_domain)dnl
define(`confPRIVACY_FLAGS',``noexpn,novrfy'')dnl
MAILER(smtp)dnl
MAILER(procmail)dnl
What worked for me was to add an MX record on the webserver hosting the website, that points to the host assigned on the original domain name server. In the case presented here would be an mx record pointing to: mailsec.website.com
I'm new here. Wanted to extend RB_CWI answer, but I am not allowed to comment.
His solution worked great.
You are not required to define the DOMAIN().
However, on my system I was required to install the sendmail-cf package.
The instructions below were done on CentOS 6.5
First, install sendmail-cf
sudo yum install sendmail-cf
Then, edit the senmail.mc
sudo vi /etc/mail/sendmail.mc
At the bottom of the file add FEATURE(relay_entire_domain)dnl, so it looks like:
...
FEATURE(relay_entire_domain)dnl
MAILER(smtp)dnl # right above this line
MAILER(procmail)dnl
dnl MAILER(cyrusv2)dnl
Save the file, and restart sendmail.
sudo service sendmail restart
Got stuck on the same problem. MX points to an external Exchange server but php/sendmail did not lookup this record. Instead mails posted by WordPress on this webserver dropped in the catchall-mailbox.
Solution was to delete ALL mailboxes on the webserver. Now sendmail was interested in the MX and all mails went to the Exchange.
However, the Exchange uses the webspace's mail server as SmartHost for outgoing mails. As solution for this, we were able to use the FTP credentials for accessing the mail server. I assume this solution does not work on every provider on this planet, but in our case (all-inkl.com) it worked out.