Home > Mobile >  how can anyone send email to me on my website in js
how can anyone send email to me on my website in js

Time:05-07

I am creating a project as I have created a contact page. I want any user to send me a email by putting his email and message in input box of contact page. I have also tried smtpjs but with that I can send the email from my side and registered email on smtpjs but unknown user who put his email without putting his password can't send email to me

for eg-

my email - [email protected]

my password - mypassword

unknown user email - [email protected]

how can unknown user send me email by putting only his email on my website contact page

any js library and js code can use for this problem please tell me

CodePudding user response:

You should try emailjs. Just follow the docs here.

CodePudding user response:

1 Include SMTP in your <script></script> tag : 
<script src="https://smtpjs.com/v3/smtp.js"></script>

2 Include the script for use your send email button
<script type="text/javascript">
    function sendEmail() {
      Email.send({
        Host: "smtp.gmail.com",
        Username: "sender@email_address.com",
        Password: "Enter your password",
        To: 'receiver@email_address.com',
        From: "sender@email_address.com",
        Subject: "Sending Email using javascript",
        Body: "Well that was easy!!",
      })
        .then(function (message) {
          alert("mail sent successfully")
        });
    }
  </script>

3.Use that function in your Html button
 <input type="button" value="Send Email" 
        onclick="sendEmail()" />
  • Related