A webmail mail
Here is a simple webmail application using HTML, CSS, and JavaScript:
index.html
<!DOCTYPE html>
<html>
<head>
<title>Webmail</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Webmail</h1>
<form>
<label for="username">Username:</label>
<input type="text" id="username" name="username"><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password"><br><br>
<input type="submit" value="Login">
</form>
<div id="inbox"></div>
<script src="script.js"></script>
</body>
</html>
style.css
body {
font-family: Arial, sans-serif;
}
form {
width: 300px;
margin: 0 auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
label {
display: block;
margin-bottom: 10px;
}
input[type="text"], input[type="password"] {
width: 100%;
height: 30px;
margin-bottom: 20px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
input[type="submit"] {
width: 100%;
height: 30px;
margin-top: 20px;
padding: 10px;
background-color: #4CAF50;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
#inbox {
margin-top: 20px;
}
.inbox-item {
background-color: #f0f0f0;
padding: 10px;
border-bottom: 1px solid #ccc;
}
.inbox-item:hover {
background-color: #e0e0e0;
}
.inbox-item.subject {
font-weight: bold;
}
.inbox-item.date {
font-size: 12px;
color: #666;
}
script.js
const form = document.querySelector('form');
const inbox = document.querySelector('#inbox');
form.addEventListener('submit', (e) => {
e.preventDefault();
const username = document.querySelector('#username').value;
const password = document.querySelector('#password').value;
// Simulate a login request
fetch('/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, password }),
})
.then((response) => response.json())
.then((data) => {
if (data.success) {
// Display the inbox
displayInbox(data.inbox);
} else {
alert('Invalid username or password');
}
});
});
function displayInbox(inboxItems) {
inbox.innerHTML = '';
inboxItems.forEach((item) => {
const inboxItem = document.createElement('div');
inboxItem.className = 'inbox-item';
inboxItem.innerHTML = `
<span class="subject">${item.subject}</span>
<span class="date">${item.date}</span>
<p>${item.message}</p>
`;
inbox.appendChild(inboxItem);
});
}
This code creates a simple webmail application with a login form and an inbox display. When the user submits the login form, it sends a POST request to the /login
endpoint with the username and password. If the login is successful, it displays the inbox with a list of email items.
Note that this is a very basic implementation and you should add more features such as email composition, sending, and receiving, as well as security measures like encryption and authentication.
Also, this code is just a starting point and you will need to modify it to fit your specific needs and requirements.