Send mail using javascript cdn (No server side required)



Have you ever wondered how you can send mail from front end using cdn?

Am going to show you how it works , with these few steps :
1.  firstly logon to https://www.smtpjs.com/

2. Open your IDE , e.g sublime text, vscode.. 

3. Include the script: 
<script src="https://smtpjs.com/v3/smtp.js"></script>
4. Send an email using:
Email.send({
  Host : "smtp.yourisp.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)
);
5. Fill your smtp server details , boom 💥.

How to add security to this?

According to smtpjs.com, you can encrypt your SMTP Credentials, using the script below.
Email.send({
    SecureToken : "C973D7AD-F097-4B95-91F4-40ABC5567812",
    To : 'them@website.com',
    From : "you@isp.com",
    Subject : "This is the subject",
    Body : "And this is the body"
}).then(
  message => alert(message)
);
More features available at smtpjs.com check it out. Don't forget to share.

    Choose :
  • OR
  • To comment
No comments:
Write Comments