this code inside fuction but not working
Email.send({ Host : "smtp.elasticemail.com", Username : "username", Password : "password", To : 'them@website.com', From : "you@isp.com", Subject : "This is the subject", Body : "And this is the body" }).then( message => alert(message) );
And Where should I put this?
<script src="https://smtpjs.com/v3/smtp.js"> </script>
I put it in jsx file but it gives this error. enter image description here
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: 'sender@mail.com',
to: 'recipient@mail.com',
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))