[email protected] Googleの を使用してメールを送信します。私はこれに続いて - https://github.com/dwyl/html-form-send-email-via-google-script-without-server 私のウェブサイトのすべての機能を設定しています。Googleスクリプトを使用してサーバーなしでメールを送信する:ファイルエラーを開くことができない
<div id="content">
\t \t <h1>Contact Us</h1>
\t \t <h4>Fill out the form below and a representative will
contact you shortly.</h4>
\t \t <form id="gform" method="POST" action="https://script.google.com/macros/u/1/s/AKfycbwYbJ5WvIRmizYMr8MMtNVdIodpdYcJHz4DuO97Oxnuw4lnu3k/exec">
<div class="form-group">
<label for="exampleInputEmail1">Your Name (required)</label>
<input type="text" class="form-control" id="exampleInputEmail1" required>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Your Email (required)</label>
<input type="Email" class="form-control" id="exampleInputPassword1" required>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Subject</label>
<input type="text" class="form-control" id="exampleInputPassword1">
</div>
<div class="form-group">
\t <label for="exampleInputPassword1">Message</label>
\t <textarea class="message"></textarea>
</div>
<button type="submit" class="btn btn-default">Submit</button>
フォームのHTMLがあります私のウェブサイトのHTMLフォームであり、誰かが私のサイトここ
に提出ボタンをクリックするたびに、私は、電子メールを送信したいですここで
script.gsファイルである -
/******************************************************************************
* This tutorial is based on the work of Martin Hawksey twitter.com/mhawksey *
* But has been simplified and cleaned up to make it more beginner friendly *
* All credit still goes to Martin and any issues/complaints/questions to me. *
******************************************************************************/
var TO_ADDRESS = "[email protected]"; // where to send form data
function doPost(e) {
try {
Logger.log(e); // the Google Script version of console.log see: Class Logger
MailApp.sendEmail(TO_ADDRESS, "Contact Form Submitted",
JSON.stringify(e.parameters));
// return json success results
return ContentService
.createTextOutput(
JSON.stringify({"result":"success",
"data": JSON.stringify(e.parameters) }))
.setMimeType(ContentService.MimeType.JSON);
} catch(error) { // if error return this
Logger.log(error);
return ContentService
.createTextOutput(JSON.stringify({"result":"error", "error": e}))
.setMimeType(ContentService.MimeType.JSON);
}
}
私はこれを取得フォームに記入した後、送信ボタンをクリックすると -
私はあなたの最新のコードのテストWebアプリケーションをクリックしたとき、私は同じ画面を取得します。
私が出て見つけた -
私は「name」属性が、そのないものを追加するための非常に明確なようフォーム内の私のhtmlタグに追加する必要があるものがあります。
ここで、この機能の設定に間違いがありますか?
多くの問題があります。gsスクリプトコンソールでトリガーを設定しましたか? Secontly、私はフォームでアクションタグを使って投稿できるとは思わない。送信時にボタンがクリックされたときに、url(https://script.google.com/macros/u/1/s/AKfycbwYbJ5WvIRmizYMr8MMtNVdIodpdYcJHz4DuO97Oxnuw4lnu3k/exec)にajaxリクエストを送信する必要があります働く正しく展開しましたか?詳細情報が必要でしょう – imox
デプロイ後に「最新のコードをテストする」リンクとしてURLを開くと、URL自体が機能しないボタンの作業をそのままにしてください。 –
私はポイント1から7のチュートリアルにあるものとまったく同じようにしました。これらの手順を除き、私は私の側から何も追加していません。 –