Setting Up A Box Using Namecheap and Digital Ocean

I have a domain on namecheap that hosts my web app, lets say www.ultrawebapp.com
I want a subdomain that will be used by for MIAB, lets say mail.ultrawebapp.com

I have created the ‘glue records’ in namecheap. I have installed the MIAB software on my digital ocean droplet.

Nameserver config:
mank.ns.cloudflare.com
marnk.ns.cloudflare.com
ns1.mail.ultrawebapp.com
ns2.mail.ultrawebapp.com

DNS records:
ns1.mail 123.456.78.90
ns2.mail 123.456.78.90

The problem is when i visit mail.ultrawebapp.com/admin, it does not show me the MIAB interface. But when visiting the droplets ip address, i see the MIAB interface.

Similar issue on this forum

I have read the above thread and tried the solutions suggested but to no avail.

What must I do?

Using both Cloudflare’s and your own nameserver concurrently doesn’t really work unless you manually synchronize them. Cloudflare probably doesn’t know about the mail subdomain. You should use either (preferably) MIAB for all DNS services for the domain or Cloudflare as external DNS configured in MIAB.

You can run dig @123.456.78.90 mail.ultrawebapp.com A on an external machine to see what’s going on. It should resolve the address to the desired ip and show the nameservers in the other sections.

1 Like

Hey thanks a bunch.
I rather cloudflare as external dns because of the current architecture of my apps.
Does this mean I have to go to cloudflare and add the subdomain and ip of the droplet?
If there is another option too please show me how to go about it.

EDIT: this is the output of the dig command:

~$ dig @123.456.78.90 mail.ultrawebapp.com A

; <<>> DiG 9.18.28-0ubuntu0.22.04.1-Ubuntu <<>> @123.456.78.90 mail.ultrawebapp.com A
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57372
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;mail.ultrawebapp.com.			IN	A

;; ANSWER SECTION:
mail.ultrawebapp.com.		86400	IN	A	123.456.78.90

;; AUTHORITY SECTION:
ultrawebapp.com.		86400	IN	NS	ns1.mail.ultrawebapp.com.
ultrawebapp.com.		86400	IN	NS	ns2.mail.ultrawebapp.com.

;; ADDITIONAL SECTION:
ns1.mail.ultrawebapp.com.	86400	IN	A	123.456.78.90
ns2.mail.ultrawebapp.com.	86400	IN	A	123.456.78.90

;; Query time: 259 msec
;; SERVER: 123.456.78.90#53(123.456.78.90) (UDP)
;; WHEN: Mon Oct 21 21:22:57 WAT 2024
;; MSG SIZE  rcvd: 127

You have to go to MIAB admin page and >> Use External DNS and replicate all the DNS entries listed there, in your Cloudflare. It is painful but once it is setup it should be OK.

1 Like

The output looks right, assuming the ip there is the same as your miab instance’s public ip. It is possible that if it (randomly) selects a different nameserver it’ll yield no or a different ip instead.

AYE!!! Thanks fam. This was the solution.

I updated the cloudflare records and everything is honky dory.

Thank you all very much for pointing me in the right direction.
Till the next issue arises and we meet again, have a good one. :hugs:

Hello everyone. I currently have the following challenge on my box instance on digital ocean.

I cannot send emails. when i do try to send mails to someone, i get an error.
email-err

i also noticed in the status check this message:

Outbound mail (SMTP port 25) seems to be blocked by your network. You will not be able to send any mail. Many residential networks block port 25 to prevent hijacked machines from being able to send spam. A quick connection test to Google’s mail server on port 25 failed.

How do i fix this problem i.e inability to send mail. Thank you

Digital Ocean blocks Outbound port 25 on any new instances. You might try support and ask them to open it and give a statement that you will not send unsolicited mail.

1 Like

hmmm. thank you very much. are there any cloud providers who do not block this Port?

Digital Ocean offers a sendgrid solution for emailing. Sendgrid for mail
I have two questions:

  1. Is it possible to integrate sendgrid with MiaB?
  2. Is it possible to change the port MiaB sends mail from?

@alento has suggested a number of them and there are people here with affiliate codes that might recommend you ISPs depending on location. I am using a German based one now they have a partner in Virginia USA if you don’t want to be based in Europe. Netcup.de

You might as well read this Best VPS hosting provider - #7 by pm74

1 Like

Yeah you can use sendgrid or mailgun or mailjet. You need to edit /etc/postfix/main.cf and setup a relay. This is well documented. Just google setup postfix relay server. Or search this forum Setup MIAB as relay.

1 Like

Thank you. Will do just that. Will update thread of my progress

I used this thread and did as requested. still cannot send email.

I am trying to use sendgrid as the relay smtp server and it does not yet work.

If you are using Sendgrid. First verify your domain there.
Then edit main.cf.

Insert these lines in /etc/postfix/main.cf via sudo nano /etc/postfix/main.cf

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_tls_security_level = encrypt
relayhost = [smtp.sendgrid.net]:587

Hit ctr+x and save the file
Then make file sudo nano /etc/postfix/sasl_passwd
[smtp.sendgrid.net]:587 your_username:your_password
See credentials in your Sendgrid admin panel.

Hit ctr+x and save the file
Then:

sudo chmod 600 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd

Then:
sudo systemctl restart postfix

In MIAB admin panel Custom DNS>> insert TXT record for SPF records as permited senders for Sendgrid, read the instructions on sendgrid how to do it but it should be a TXT record something like this:
v=spf1 include:sendgrid.net -all .

Of course replace the examples above with the sendgrid credentials.
You are now good to send via the relay. MIAB will still show errors for outbound port 25 but you just ignore that.
Exvuse any spelling mistakes in the commands use tab for the correct paths.

EDIT: Also inspect main.cf for any duplicates as they may mess postfix. put a hashtag # infront of any disabled lines

1 Like

Thanks very much for the help. I did this and so far I see no change. I know I am just one config away from making it work.

I noticed this main.cf file

#smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_banner=$myhostname ESMTP Hi, I'm a Mail-in-a-Box (Ubuntu/Postfix; see https://mailinabox.email/)

is this okay?

Your main.cf should have the entire postfix config. Not just the 2 lines.
Did you manage to setup the relay? As per the instructions above.

Yes I setup the relay as per instructions.
I commented out duplicate assignments.
I added everything as per the instruction.

my main.cf is has many lines. I just taught maybe this line was the cause of the problem.

Somehow I still feel I am missing something because this has worked for many others. So definately I am missing something. But don’t know what it is.

If you are interested, I can DM you the snapshot of my present configs on MiaB and maybe the external DNS so we can troubleshoot further.

Thank you.

Yeah go ahead DM me. Send me the main.cf. And a screenshot of your MIAB status. I recommend you rerun MIAB setup before sending me anything

curl -s https://mailinabox.email/setup.sh | sudo -E bash

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.