Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sendgrid API #403

Merged
merged 1 commit into from
Aug 9, 2024
Merged
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
26 changes: 26 additions & 0 deletions New_APIs/SendGrid API/index.html
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>
26 changes: 26 additions & 0 deletions New_APIs/SendGrid API/index.js
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.';
}
});
Loading
Loading