How to send email with javascript using smtp js || web developer joy

Share:

how to send mail without a back-end? is this possible to send mail without a back-end?

 




ans: yes anyone can send email without back-end language .if you want to send mail without use back-end language you can use smtpjs  .

for sending mail you should  follow this way :

1. your Gmail address should be turned on 2 step verification .




2. add password .









copy the password this is your password for email sending











3.go to smtp js website .

4. copy all the code on your index.html file




index.html file :


<!DOCTYPE html>

<html>

<head>

    <title>web developer joy : send email</title>

</head>

<body>

<label>name</label>

<input type="text" name="name" id="name" placeholder="name"><br>

<label>email</label>

<input type="email" name="name" id="email" placeholder="eamil"><br>

<label>messege</label>

<input type="text" name="name" id="mm" placeholder="message"><br>

<button id="ol">ok</button>


 <script src="https://smtpjs.com/v3/smtp.js"></script>

<script type="text/javascript">

document.getElementById("ol").addEventListener("click", function(){


var name =document.getElementById('name').value;


var  email= document.getElementById('email').value;


 var message = document.getElementById('mm').value;


 var send = "hi mr"+name+"<br/>"+message;



 Email.send({

     Host : "smtp.gmail.com",

     Username : "your email addreas",

     Password : "here is your password  whic you genarate",

     To : 'fiveerjoy@gmail.com',//which mail you want to get email

     From : xyz@gmail.com, //which mail from  you want to get email

     Subject : "This is the subject",

     Body : send

 }).then(

  message => alert(message)

 );


});




</script>

 




</body>

</html>

Post a Comment

No comments