DEV Community

Cover image for Create a Private Email API for Free
Steeve
Steeve

Posted on

Create a Private Email API for Free

Liquid syntax error: Unknown tag 'endraw'

Top comments (10)

Collapse
 
stankukucka profile image
Stan Kukučka

@steeve this is cool. Good for SSG websites.

Collapse
 
neurabot profile image
Neurabot

What's SSG acronym ?

Collapse
 
stankukucka profile image
Stan Kukučka

@heyeasley it's a "static site generator".

Thread Thread
 
neurabot profile image
Neurabot

Thank. Brilliant.

Collapse
 
steeve profile image
Steeve

Thank Stan! Yes, I have 4 SSG websites hosted on CDN, all using the Email API server for 2 years now: it works great for SEO, loading time, almost no maintenance, and cost nothing.

Collapse
 
stankukucka profile image
Stan Kukučka

@steeve I would love to try it. But not clear what to implement on the website side (SSG). The Github repo seems to explain how to run the server only.

Thread Thread
 
steeve profile image
Steeve

On the website side, you just have to make a POST HTTP request to the API server, for instance:

 await fetch('https://mailerapi.domain.com/send', {
     method: 'POST',
     headers: {
          Accept: 'application/json',
          'Content-Type': 'application/json'
     },
     body: JSON.stringify({
         from: "email-sender@domain",
         to: "email-receiver@domain",
         subject: "Email subject",
         text: "Content of the email as text",
         html: "Content of the email as HTML"
    })
})
Enter fullscreen mode Exit fullscreen mode

Notes:

  • For creating the content of the Email, I searched Email template online, then I adapted with JSFiddle to preview the result.
  • The from is the email address linked to the SMTP server
  • The to could be your personal email address
Collapse
 
neurabot profile image
Neurabot

Brilliant. nice

Collapse
 
salika_dave profile image
Salika Dave

Nicely done 🙌

Collapse
 
steeve profile image
Steeve

Thank you Salika 🙌