我是Angular 8的新用户,并且正在发送电子邮件,我一直在寻找使用 Elastic Email API http://api.elasticemail.com/public/help#Email_Send和Angular 8 发送带有图像的电子邮件的正确方法,但是显然互联网上没有明显的例子,有人能建议如何正确地做,至少是一个想法如何做
我有这个https://evod-royalinvestmentproperties.firebaseapp.com/contact-us,我想做的就是将此表单的数据输入发送到特定的gmail地址,我想念的是什么?
import * as path from 'path';
import * as ejs from 'ejs';
import Axios from 'axios';
import { config } from 'firebase-functions';
export async function email(parameters: email.Parameters) {
const template = await renderTemplate(parameters.templateName, parameters.templateData);
const elasticUrl = url.format({
protocol: 'https',
host: 'api.elasticmail.com/v2',
pathname: '/email/send',
query: {
apiKey: config().elasticmail.mailKey,
msgFrom: parameters.msgFrom,
msgFromName: parameters.msgFromName,
msgTo: parameters.msgTo,
bodyHtml: template,
},
});
return Axios.post(elasticUrl, {})
.then(res => res.data);
}
export namespace email {
export interface Parameters {
msgFrom: string;
msgFromName: string;
msgTo: string;
templateName: string;
templateData?: any;
}
}
function renderTemplate(name: string, data: any = {}) {
const filePath = path.join(__dirname, '../templates', `${name}.ejs`);
return ejs.renderFile<string>(filePath, data, {
async: true,
delimiter: '?',
});
}```
here is the form https://evod-royalinvestmentproperties.firebaseapp.com/contact-us when a user inputs a name, email & message it will send its data to specified 2 gmail address(address1@gmail.com, address2@gmail.com)