此代码在功能内但不起作用
Email.send({ Host : "smtp.elasticemail.com", Username : "username", Password : "password", To : '[email protected]', From : "[email protected]", Subject : "This is the subject", Body : "And this is the body" }).then( message => alert(message) );
还有 我应该把这个放在哪里?
<script src="https://smtpjs.com/v3/smtp.js"> </script>
Step 1:
npm install smtp.js
Step 2:
import smtp from 'smtp.js';
const credentials = {
host: 'smtp.host.com',
port: 465,
secure: true,
auth: {
user: 'username',
pass: 'password'
}
}
smtp.connect(credentials)
.then(info => {
// connected, credentials OK
})
Step 3:
const email = {
from: '[email protected]',
to: '[email protected]',
subject: 'test subject',
html: '<p>This is an <strong>HTML email</strong></p>'
}
smtp.connect(credentials)
.then(() => smtp.sendMail(email))
.then(info => console.log('Email sent!'))
.catch(err => console.error(err))