1

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)
 );
 }
 }
 }
asked May 15, 2019 at 19:17
1
  • 2
    That should work so long as you have the <script src="https://smtpjs.com/v3/smtp.js"> in your index.html Commented May 15, 2019 at 19:28

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.