簡體   English   中英

誰能用 js 在我的網站上向我發送 email

[英]how can anyone send email to me on my website in js

我正在創建一個項目,因為我已經創建了一個聯系頁面。 我希望任何用戶通過在聯系頁面的輸入框中輸入他的 email 和消息來向我發送 email。 我也嘗試過 smtpjs 但這樣我可以從我這邊發送 email 並在 smtpjs 上注冊 email 但是未知用戶在沒有輸入密碼的情況下輸入 email 無法發送 email 給我

例如-

我的 email - myemail@gmail.com

我的密碼-我的密碼

未知用戶 email - unknown@gmail.com

未知用戶如何通過僅將他的 email 放在我的網站聯系頁面上來向我發送 email

任何 js 庫和 js 代碼都可以用於這個問題請告訴我

你應該試試emailjs 只需按照此處的文檔操作即可。

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()" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM