-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #403 from sreevidya-16/sreevidya1
Sendgrid API
- Loading branch information
Showing
6 changed files
with
1,347 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,26 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="style.css"> | ||
<title>SendGrid Email Sender</title> | ||
</head> | ||
<body> | ||
<header> | ||
<h1>SendGrid Email Sender</h1> | ||
</header> | ||
<main> | ||
<section> | ||
<form id="email-form"> | ||
<input type="email" id="to" placeholder="Recipient Email" required> | ||
<input type="text" id="subject" placeholder="Subject" required> | ||
<textarea id="message" placeholder="Message" required></textarea> | ||
<button type="submit">Send Email</button> | ||
</form> | ||
<div id="status"></div> | ||
</section> | ||
</main> | ||
<script src="index.js"></script> | ||
</body> | ||
</html> |
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,26 @@ | ||
document.getElementById('email-form').addEventListener('submit', async (e) => { | ||
e.preventDefault(); | ||
|
||
const to = document.getElementById('to').value; | ||
const subject = document.getElementById('subject').value; | ||
const message = document.getElementById('message').value; | ||
|
||
try { | ||
const response = await fetch('/send-email', { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify({ to, subject, message }) | ||
}); | ||
|
||
const data = await response.json(); | ||
|
||
if (data.success) { | ||
document.getElementById('status').textContent = 'Email sent successfully!'; | ||
} else { | ||
document.getElementById('status').textContent = 'Failed to send email.'; | ||
} | ||
} catch (error) { | ||
console.error('Error:', error); | ||
document.getElementById('status').textContent = 'An error occurred while sending the email.'; | ||
} | ||
}); |
Oops, something went wrong.