Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fake mailer API
  • Loading branch information
nlz18001 committed Apr 7, 2024
1 parent eb3b91c commit 478d27f
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions week-11/index.html
@@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Email Form</title>
<style>
label {
font-family: Arial, Helvetica, sans-serif;
font-size: 15px;
}

button {
font-size: 12px;
color: green;
margin-top: 10px;
}

div {
font-family: Arial, Helvetica, sans-serif;
font-size: 15px;
margin-top: 10px;
font-weight: bold;
}
</style>
</head>
<body>
<form id="emailForm">
<label for="to">To:</label><br>
<input type="email" id="to" name="to" required><br>
<label for="subject">Subject:</label><br>
<input type="text" id="subject" name="subject" required><br>
<label for="message">Message:</label><br>
<input type="message" id="message" name="message" required></input><br>
<button type="submit">Send</button>
</form>

<div id="response"></div>

<script>
const form = document.getElementById("emailForm");
const responseDiv = document.getElementById("response")

form.addEventListener("submit", function(event) {
event.preventDefault();

let data = new FormData(form);
data.set("to", "brian@uconn.edu");
data.set("subject", "Nigerian Prince: $1M Owed to You!");
data.set("message", "sdfsdfdsfsd");

fetch("https://bdaley.npkn.net/dmd-formmail/", {
method: "POST",
body: data
})
.then((response) => response.json())
.then((responseObject) => {
responseDiv.textContent = responseObject.message;
})
.catch((error) => {
responseDiv.textContent = responseObject.error;
});
});
</script>
</body>
</html>

0 comments on commit 478d27f

Please sign in to comment.