When a User registers i need to send them an confirmation email using vue.js.
I want to use this scrip provided by https://www.smtpjs.com/ How can i make use of this "Email.send" Method within my vue.js application
<script src="https://smtpjs.com/v3/smtp.js">
</script>
Email.send({
Host : "smtp.yourisp.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)
);
I want it to be like
export default {
name: 'landing',
data () {
return {
component: null
}
},
methods: {
sendEmail(){
Email.send({
Host : "smtp.yourisp.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)
);
}
}
}
1 Answer 1
The script must have an export, so you could download the script and modify it like this:
export var Email = {
... code ...
};
export default Email;
Then in your component, you import it like this:
import Email from './smtp.js';
With that you should be able to access its functions.
answered May 15, 2019 at 19:47
Jota Mario Miranda Guerra
263 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-js
<script src="https://smtpjs.com/v3/smtp.js">in your index.html