forked from bpd01001/2024-spring-dmd-3475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fake mailer API
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |