add pages
This commit is contained in:
115
webpages/SendEmail.py
Normal file
115
webpages/SendEmail.py
Normal file
@@ -0,0 +1,115 @@
|
||||
import smtplib
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
|
||||
|
||||
# Function to send an email notification
|
||||
def send_email(sender_email, password, to_email, subject):
|
||||
# Create a MIMEMultipart email object to support multiple parts (e.g., HTML content)
|
||||
message = MIMEMultipart('alternative')
|
||||
message['Subject'] = subject # Set the email subject
|
||||
message['From'] = sender_email # Set the sender's email address
|
||||
message['To'] = to_email # Set the recipient's email address
|
||||
|
||||
# HTML content for the email body
|
||||
html_content = """
|
||||
<html>
|
||||
<head>
|
||||
<title>Welcome to BuffTeks!</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
line-height: 1.6;
|
||||
color: #333;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
.container {
|
||||
max-width: 600px;
|
||||
margin: 20px auto;
|
||||
background: #fff;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||
overflow: hidden;
|
||||
}
|
||||
.header {
|
||||
background-color: #450012;
|
||||
color: white;
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.content {
|
||||
padding: 20px;
|
||||
}
|
||||
.content a {
|
||||
color: #4CAF50;
|
||||
text-decoration: none;
|
||||
}
|
||||
.content a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.footer {
|
||||
background-color: #f1f1f1;
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
Welcome to BuffTeks!
|
||||
</div>
|
||||
<div class="content">
|
||||
<p>Dear New Member,</p>
|
||||
|
||||
<p>Thank you for your interest in the <a href="https://buffteks.org" target="_blank">BuffTeks</a> student organization! We're excited to have you with us. To further enrich your experience and connect with fellow members, we have set up a Discord server for BuffTeks. This platform will allow you to engage in discussions, seek help, share insights, and participate in various club activities.</p>
|
||||
|
||||
<p>Please join the BuffTeks Discord via the invitation link: <a href="https://discord.gg/dU8vKfAjxv" target="_blank">https://discord.gg/dU8vKfAjxv</a></p>
|
||||
|
||||
<p>Once you're in, take a moment to review our server rules and introduce yourself in the "Introductions" channel. If you have any questions, don't hesitate to reach out.</p>
|
||||
|
||||
<p>We look forward to seeing you there!</p>
|
||||
|
||||
<p>Sincerely,</p>
|
||||
|
||||
<p>BuffTeks Faculty Advisor</p>
|
||||
<p>Cheng (Carl) Zhang, Ph.D.<br>
|
||||
Paul Engler Professor of Business Innovation<br>
|
||||
Assistant Professor of Computer Information Systems<br>
|
||||
Paul and Virginia Engler College of Business<br>
|
||||
West Texas A&M University, Canyon, TX<br>
|
||||
Email: czhang@wtamu.edu<br>
|
||||
</p>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© 2024 BuffTeks Student Organization
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
# Convert the HTML content to a MIMEText object for HTML format
|
||||
html_part = MIMEText(html_content, 'html')
|
||||
|
||||
# Attach the HTML part to the MIMEMultipart message
|
||||
message.attach(html_part)
|
||||
|
||||
try:
|
||||
# Connect to the SMTP server and send the email
|
||||
with smtplib.SMTP('mail.privateemail.com', 587) as server:
|
||||
server.starttls() # Enable TLS encryption for secure connection
|
||||
server.login(sender_email, password) # Log in with the sender's email and password
|
||||
server.send_message(message) # Send the email message
|
||||
print("Email sent successfully!")
|
||||
except Exception as e:
|
||||
# Catch and display any exceptions that occur during the sending process
|
||||
print(f"Failed to send email: {str(e)}")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user