I’m trying to use Sendgrid (mailing service) for my contact page in my app. But… I’m not sure how… I think I’m close. Can anyone help me?
This is the code when the user hits the submission button…
async submit(form: NgForm) {
this.submitted = true;
if (form.valid) {
this.supportMessage = '';
this.submitted = false;
const toast = await this.toastCtrl.create({
message: 'Your support request has been sent.',
duration: 3000
const sgMail = require('@sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
msg = {
to: 'test@example.com',
from: 'test@example.com',
subject: 'Sending with Twilio SendGrid is Fun',
text: 'and easy to do anywhere, even with Node.js',
html: '<strong>and easy to do anywhere, even with Node.js</strong>',
};
this.sgMail.send(msg);
});
await toast.present();
}
}
I also added a picture so you could see the error.
Sorry if I’m wasting your time over something that’s simple.
Hope you can help