私のウェブサイトでは、ユーザに電子メールを送信しようとしています。私は、nodeJSでメールを送るのにsendgridプロバイダを使いました。私はnodeJSを初めて使用しているので、ページ上の指示に従ってコマンドプロンプトからメールを送ってきました。しかし、私はそれを実際のサーバーに実装する方法はありません。 sendgridで電子メールを送信するには、パッケージをインストールしました。そして、私は特定のイベントに電子メールを送りたいと思う。実サーバ(SendGrid)経由で電子メールを送信する方法
function goMail()
{
const sgMail = require('@sendgrid/mail');
sgMail.setApiKey(MY_API_KEY);
const msg = {
to: '********[email protected]',
from: '12345***@gmail.com',
subject: 'Sending with SendGrid is Fun',
text: 'and easy to do anywhere, even with Node.js',
html: '<strong>and easy to do anywhere, even with Node.js</strong>',
};
sgMail.send(msg);
}
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="index.js"></script>
</head>
<body>
<div class="container">
<h2>Vertical (basic) form</h2>
<form>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email" placeholder="Enter email" name="email">
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd" placeholder="Enter password" name="pwd">
</div>
<div class="checkbox">
<label><input type="checkbox" name="remember"> Remember me</label>
</div>
<button type="submit" class="btn btn-default" onclick="goMail();">Submit</button>
</form>
</div>
</body>
</html>
彼らは本当のサーバ上で動作しない方法をブリーフィングすることを説明してください。
ありがとうございます、firebase webapp – Badhusha
@Badhushaからメールを送信するためのチュートリアルを他に提供できますか?これはあなたが探しているものです:https://firebase.google.com/docs/functions/http-events –