Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .emails/welcome/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<html>
<body>
<h1>Welcome, {{name}}</h1>
<p>This is a test from your friendly technical writing manager, Rachael Stavchansky. We hope you enjoy our super simple emails!</p>
</body>
</html>
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Local Netlify folder
.netlify
.netlify
/node_modules
8 changes: 7 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/skeleton.css">


<!-- JavaScript
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<script type="module" src="js/script.js"></script>

</head>
<body>
<h1>Hello World</h1>
Expand Down Expand Up @@ -68,5 +72,7 @@ <h2>You can contact this sweet puppy here</h2>
<button type="submit">Send</button>
</p>
</form>

<button class="emailTest">Send email</button>
</body>
</html>
31 changes: 31 additions & 0 deletions js/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//var fetch = require('node-fetch');

import fetch from 'node-fetch'

sendEmailButton = document.querySelector(".emailTest");

var sendEmail = async function () {

await fetch(
`${process.env.URL}/.netlify/functions/emails/welcome`,
{
headers: {
"netlify-emails-secret": process.env.NETLIFY_EMAILS_SECRET,
},
method: "POST",
body: JSON.stringify({
from: "no-reply@yourdomain.com",
to: "jane.example@test.com",
cc: "cc@test.com",
bcc: "bcc@test.com",
subject: "Welcome",
parameters: {
products: ["product1", "product2", "product3"],
name: "Jane",
},
}),
}
);
}

sendEmailButton.addEventListener("click", sendEmail);
6 changes: 0 additions & 6 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
[[plugins]]
package = "netlify-plugin-checklinks"

[plugins.inputs]
checkExternal = true

[[headers]]
for = "/protected/*"
[headers.values]
Expand Down
140 changes: 140 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": {
"node-fetch": "^3.2.10"
},
"type": "module"
}