0

I'm creating my portfolio and I have implemented a contact form.

I would to receive visitors messages in my gmail. I don't find on the web how to do it in Angular 2/4.

Should I add a Back end site to do that?

<div class="contactcard">
    <md-card class="mdcardcontact">
        <md-card-header style="background-color: black; width:100%"></md-card-header>
        <div>
            <md-card-content>
                <form [formGroup]="form" class="form">
                    <div>
                        <md-input-container class="full-width">
                            <input mdInput type="text" formControlName="name" placeholder="Votre nom">
                        </md-input-container>
                    </div>
                    <div>
                        <md-input-container class="full-width">
                            <input mdInput type="text" formControlName="email" placeholder="Votre adressse mail">
                            <md-error *ngIf="form.get('email').hasError('pattern') ">
                                Votre mail n'est pas valid
                            </md-error>
                        </md-input-container>
                    </div>
                    <div>
                        <md-input-container class="full-width">
                            <input mdInput type="tel" formControlName="telephone" placeholder="Votre numéro de téléphone">
                            <md-error *ngIf="form.get('email').hasError('pattern') ">
                                Votre mail n'est pas valid
                            </md-error>
                        </md-input-container>
                    </div>
                    <div>
                        <md-input-container class="full-width">
                            <textarea mdInput type="text" formControlName="message" placeholder="Votre message" style="height:200px; "></textarea>
                        </md-input-container>
                    </div>
                    <button md-fab class="send-button">
                        <md-icon>send</md-icon>
                    </button>
                </form>
            </md-card-content>
        </div>
    </md-card>
</div>
Cœur
  • 37,241
  • 25
  • 195
  • 267
Hamza Haddad
  • 1,516
  • 6
  • 28
  • 48
  • Possible duplicate of [How to send an email from JavaScript](https://stackoverflow.com/questions/7381150/how-to-send-an-email-from-javascript) – Jota.Toledo Aug 25 '17 at 08:06

4 Answers4

0

If I understand correctly you're trying to send an email using Javascript on the front end, which is not possible (see also this question). You're going to have to set up a server or use a 3rd party client for this.

Robin-Hoodie
  • 4,886
  • 4
  • 30
  • 63
-1

You will need a Server-side Language to do this (PHP, C#, Java, Python...). In sending mail to the client some SMTP protocols have to be executed and this in my opinion at the moment has to be done on the server.So collect user information in your contact form and pass it to the method on the server to transport it.

Frank Odoom
  • 1,545
  • 18
  • 19
-1

You need some sort of backend script to do that for you. Then you send required data to this script from your angular app.

Bart K
  • 324
  • 1
  • 8
-1

nodemailer and sendgrid could be used if you can pass it back to the server side

Zack
  • 294
  • 1
  • 10