Ali
Ali

Reputation: 357

How To send an Email from a client side angular form without server side application for Contact us form

I have an angular website (pwa website) without server side ( no database ) and I have a contact us form that I want to allow end user to send some data like "name","email","topic" and ... to a specific email like "[email protected]"

Currently I uploaded the website without contact us form on a Host domain.

I'm using angular 7 for the website

Upvotes: 0

Views: 11205

Answers (3)

SoftCode
SoftCode

Reputation: 1

What i did was used an email api (mailthis.to) with a postmessage inside the service to send an email. and it works

Upvotes: 0

nandithakw
nandithakw

Reputation: 1029

You can not send email directly through front end code. Instead you can

  • use end users mail client.
  • use a thrid party web service.
  • use your own back end service.

(You can put the back end code in the same application and host it as one application. https://nodemailer.com/about/ is a lib for sending mail using back end js code)

Upvotes: 0

wentjun
wentjun

Reputation: 42556

I am currently this service called FormSpree, which allows us to handle email contact forms without the need for server-side code. It has been working decently well, even up till now.

1) You can handle it purely on your component.html, after specifying the name attribute and adding the POST request url on your form's action attribute.

<form action="https://formspree.io/[email protected]" method="POST" />
.
.
<input type="text" name="name">

2) Or, you can handle it on your component.ts/service.ts by calling HttpClient to send a post request to 'https://formspree.io/[email protected]', together with the request body and headers.


Alternatively, you may want to use SendGrid, though I may not be of much help here, since I have not actually tried it. However, they seem to have a pretty extensive API and decent documentation, so you may want to refer to that on how to get started with it.

Upvotes: 1

Related Questions