Sending mail via Sendgrid Web API

https://paste.ubuntu.com/p/hbxdMMytxJ/

Update:Because other issues I’m restoring the droplet to before making changes in postfix configuration to send mail using external SMTP server…

One thing that should probably be mentioned … before tinkering with conf files make a copy so that they can be easily reverted … in this case

sudo cp main.cf main.cf-original

Then to revert simply

sudo mv main.cf-original main.cf

and always remember to reload postfix,

Yes, I will make note of it. Thanks!
Also, I decided to move out of DO because in my undelivered mail to hotmail I get:

Unfortunately, messages from [MyIP] weren’t sent. Please contact
your Internet service provider since part of their network is on our block list.

So, I don’t know what’s the good part of DO. I think MSFT just block anything from DO.

I think MS$ just blocks anyone … sure seems that way sometimes. Fortunately there are a gazillion alternatives to DO.

I started searching here documentation on how to properly move out of DO.
ie. I found you saying:
Is DNSSEC set up with the registrar? Did you remove it before moving the box if it is?

You may want to delete the contents of the /home/user-data/ssl directory and run management/ssl_certificates.py to obtain new certs with a new private key.

Is there a location with all the step-by-step of moving out of DO.

No, not specifically … it will basically be a combination of the initial install guide and the upgrade to Ubuntu 18 guide.

I might miss something but …

  • Stop mail on the current box.

  • Copy the contents of /home/user-data/backup/encrypted and the secret_key.txt file to someplace safe so that you have all the data and the key to restore it.

  • Change your glue records to the new IP. Delete DNSSEC at the registrar.

  • Run the setup on the new VPS including the restore.

That is the basic overview…

For less problems ABSOLUTELY. The new install of MiaB will not handle DNS properly if this is not disabled. It can be re-enabled once everything is up and running again on the new VPS.

This is unrelated to the subject. New SSL certificates will automatically be provisioned during the set up … just as they were the first time around.

I just looked at the main,cf file and I think I identified the issue

relayhost = [smtp.sendgrid.net]:589

Should the port be 589 or 587? Usually it would be port 587 unless they use a custom port. Maybe a typo?

In the mail.log there is this line repeatedly:

Jun 5 20:55:44 box postfix/smtpd[18261]: warning: /etc/postfix/main.cf, line 49: overriding earlier entry: relayhost=[smtp.sendgrid.net]:587

But the main.cf only had 42 lines, so … maybe @murgero the log file guy can take a look? (hint, hint Mitchell!)

Did you send the right file, and with all lines of text?

I’m sure it was the right file but just the lines around the time I sent the test email.
I’ll spin a test droplet and try it again.

I have a brand new (test) droplet with new domain.
Everything checkmarked green.
Sent a test email to a hotmail account that arrived in the junk folder (of course).
Authenticated the domain by sendgrid.
Followed Alento’s linked instructions for postfix using an external SMTP server.
Then, for the last part (verfy the integration with sendgrid) I’m at this page:

Does “send an email from your application” means from within postfix?
“Using the code you just integrated” ??
“If that runs without errors” Where do I go to look for errors?

Thanks!

I figured it out:
I ran this:

[root@mail ~]# telnet localhost 25
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.
220 mail.zimbra.local ESMTP Postfix
Helo box.mydomain.com
250 box.mydomain.com
MAIL FROM:<admin@mydomain.com>
250 2.1.0 Ok
RCPT TO:<user@somedomain.com>
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Subject: My Test Email
This is the body of the Email
.
250 2.0.0 Ok: queued as 194869C1AB
quit
221 2.0.0 Bye
Connection closed by foreign host.

Then, I clicked the Verify Integration button at sengrid.
I got this message from sengrid:
It worked!
We successfully received your email. Your setup is complete!

1 Like

At the beginning, emails to hotmail arrived to the inbox then after a few hours emails were being blocked by microsoft. less than 10 emails were sent during those hours.
So, I will have to move out of DO.

Just for fun, I was trying to create a miab in azure but I don’t know if it is possible.
I was naming the vm box.exampledomain.com but I’m not allowed to use a period!!

I just realized the miab setup guide says:
we recommend naming your box box + . + your domain name.

So I don’t have to use periods.
But what are the future implications of not going with the recommending naming convention?

DO is wierd IMHO as the name of the droplet is the rDNS … I have not come across another VPS provider that does this craziness. On the same token I have never used Azure so no clue what/how they work.

If you were to give your MiaB server a host name of simply domain.com, then you would never be able to host a website on the URL domain.com other than the limited static site that MiaB can host … so many people would not find that reasonable as they want to run a website somewhere else on their domain.

However, you can name it courriel.domain.com or somethingstupid.domain.com and the likelyhood that you would want to run a website on THAT subdomain would usually be nil.

Most websites are on the host (subdomain) www but often times just the naked domain is used. So if the naked domain is used for the mail server then they are out of luck if they want to run a website on the naked domain name.

This is what is being avoided by naming your MiaB’s hostname something other than simply domain.com.

Thanks Alento!
Again, just for fun I tried the box.anydomain.com as name and the setup allowed me to click next!

Alento how to connect in slack?

I couldn’t create the miab in azure.
I get this during install:

Then when I try to connect via https://IPaddress/admin I never get there.

Update: I just got in to the admin panel. I guess the tenth time it’s a charm with MSFT.
I can get everywhere inside the admin panel except the system status checks.
First I get Error, something went wrong, sorry. Then it just says Loading…