Senden von E-Mails aus Winkel-2

Wie Sende ich E-Mails von einem Winkel 2 App?

Ich bin hosting eine Eckige 2-app auf FB. Ich möchte senden Sie ein Kontaktformular als E-Mail. Idealerweise meine Lösung verwenden würde, Nodejs, aber ich bin bereit, alles, was, die bekommen den job richtig gemacht. Unten ist eine Aufschlüsselung der meine app.


Client-Seite Fortschritt

Hier ist mein Fragebogen:

HTML:

<!-- contact-form.component.html -->

<form [formGroup]="formService.contactForm" (ngSubmit)="formService.onSubmitForm()">

  <input type="text" formControlName="userFirstName">
  <label>First Name</label>
  
  <input type="text" formControlName="userLastName">
  <label>Last Name</label>

  <button type="submit">SUBMIT</button>
  
</form>


Hier ist mein Kontakt-Formular-Komponente:

JS:

//contact-form.component.ts
import { Component } from '@angular/core';

import { ContactFormService } from './contact-form.service';

@Component({
  selector: 'contact-form',
  templateUrl: './contact-form.component.html',
  styleUrls: ['./contact-content.component.css'],
  providers: [ContactFormService]
})
export class ContactFormComponent {

  constructor(private formService: ContactFormService) {
    formService.buildForm();
  }

}

Hier ist mein Kontakt-Formular-service:

JS:

//contact-form.service.ts

import { Injectable } from '@angular/core';

import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms';


@Injectable()
export class ContactFormService {

  constructor(public formBuilder: FormBuilder) { }

  contactForm: FormGroup;
  formSubmitted: boolean = false;


  buildForm() {
    this.contactForm = this.formBuilder.group({
      userFirstName: this.formBuilder.control(null, Validators.required),
      userLastName: this.formBuilder.control(null, Validators.required)
    });
  }

  onSubmitForm() {
    console.log(this.contactForm.value);
    this.formSubmitted = true;
    this.contactForm.reset();
  }

}

Wenn ich auf den submit-button werden die Formulardaten erfolgreich Anzeige in der Konsole.


Server-Seite Nodejs Fortschritt

Ich erfolgreich senden können E-Mails aus der Eingabeaufforderung mit dem Befehl SendGrid und Nodejs:

Beispiel: sendmail.js

JS:

var Sendgrid = require('sendgrid')(
  process.env.SENDGRID_API_KEY || '<my-api-key-placed-here>'
);

var request = Sendgrid.emptyRequest({
  method: 'POST',
  path: '/v3/mail/send',
  body: {
    personalizations: [{
      to: [{ email: '[email protected]' }],
      subject: 'Sendgrid test email from Node.js'
    }],
    from: { email: '[email protected]' },
    content: [{
      type: 'text/plain',
      value: 'Hello Joe! Can you hear me Joe?.'
    }]
  }
});

Sendgrid.API(request, function (error, response) {
  if (error) {
    console.log('Mail not sent; see error message below.');
  } else {
    console.log('Mail sent successfully!');
  }
  console.log(response);
});

Dann eine E-Mail erfolgreich gesendet, wenn ich das tippe in der Eingabeaufforderung ein:

node sendmail

Aber ich kann nicht herausfinden, wie link meine eingegebene Formulardaten zu sendmail.js und auch ich kann nicht herausfinden, wie zu aktivieren Sie den code in sendmail.js durch anklicken der Absenden-Schaltfläche.

Jegliche Hilfe würde sehr geschätzt werden. Vielen Dank für Ihre Zeit!

  • Ich habe dies vor, im Winkel 2, ich werde sehen, wie ich ging, es zu tun.
InformationsquelleAutor Ty Sabs | 2017-04-03
Schreibe einen Kommentar