您好我正在尝试将我的表单数据提交到我的电子邮件(mostafamasri@outlook.com)我希望从输入和他的名字收到发件人的电子邮件,并在有组织的情况下收到消息方式。
这是我的HTML代码:
<div id="contact" class="contact">
<h5 style="font-family: 'Ubuntu', serif; font-size: 47px; color:#fff; padding-top: 110px">Get in touch</h5><br>
<form method="POST" id="contact-form" action="send">
<p>Dear Mostafa,</p>
<p>My
<label for="your-name">name</label> is
<input type="text" name="your-name" id="your-name" minlength="3" placeholder="(your name here)" required> and</p>
<p>my
<label for="email">email address</label> is
<input type="email" name="your-email" id="email" placeholder="(your email address)" required>
</p>
<p> I have a
<label for="your-message">message</label> for you,</p>
<p>
<textarea name="your-message" id="your-message" placeholder="(your msg here)" class="expanding" required></textarea>
</p>
<p>
<button type="submit" name="submit" value="Send!">
<svg version="1.1" class="send-icn" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="100px" height="36px" viewBox="0 0 100 36" enable-background="new 0 0 100 36" xml:space="preserve">
<path d="M100,0L100,0 M23.8,7.1L100,0L40.9,36l-4.7-7.5L22,34.8l-4-11L0,30.5L16.4,8.7l5.4,15L23,7L23.8,7.1z M16.8,20.4l-1.5-4.3
l-5.1,6.7L16.8,20.4z M34.4,25.4l-8.1-13.1L25,29.6L34.4,25.4z M35.2,13.2l8.1,13.1L70,9.9L35.2,13.2z" />
</svg>
<small>Submit</small>
</button>
</p>
</form>
这是我的nodejs代码:
var express = require('express');
var bodyParser = require("body-parser");
var app = express();
var path = require("path");
'use strict';
const nodemailer = require('nodemailer');
var port = process.env.PORT || 8000;
nodemailer.createTestAccount((err, account) => {
let transporter = nodemailer.createTransport({
host: 'smtp-mail.outlook.com',
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: 'mostafamasri@outlook.com', // generated ethereal user
pass: 'mamxais' // generated ethereal password
}
});
// setup email data with unicode symbols
let mailOptions = {
from: 'sender@server.com', // sender address
to: 'sql.leb@gmail.com', // list of receivers
subject: 'Hello ✔', // Subject line
text: 'Hello world?', // plain text body
html: '<b>Hello world?</b>' // html body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);
}
console.log('Message sent: %s', info.messageId);
// Preview only available when sending through an Ethereal account
console.log('Preview URL: %s', nodemailer.getTestMessageUrl(info));
// Message sent: <b658f8ca-6296-ccf4-8306-87d57a0b4321@blurdybloop.com>
// Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
});});
任何帮助或指导将不胜感激。谢谢。
答案 0 :(得分:0)
按照以下步骤
var htmlContent =“format html string”;