diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 2d53844..0000000 --- a/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/index.xlsx -/key.txt -/data -/utils/__pycache__ -/main.exe -/config.json \ No newline at end of file diff --git a/LICENCE b/LICENCE deleted file mode 100644 index 255f150..0000000 --- a/LICENCE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2024 南京工业大学大学生科学技术协会 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md index 3c3abc3..7ae2eb1 100644 Binary files a/README.md and b/README.md differ diff --git a/config.json b/config.json deleted file mode 100644 index 742f6b7..0000000 --- a/config.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "status": "", - "department": "", - "qqGroupId": "" -} \ No newline at end of file diff --git a/images/password.png b/images/password.png new file mode 100644 index 0000000..db7e5f3 Binary files /dev/null and b/images/password.png differ diff --git a/images/smtp.png b/images/smtp.png new file mode 100644 index 0000000..f48cddf Binary files /dev/null and b/images/smtp.png differ diff --git a/images/youxiang.png b/images/youxiang.png new file mode 100644 index 0000000..586456a Binary files /dev/null and b/images/youxiang.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..959f6e3 --- /dev/null +++ b/index.html @@ -0,0 +1,49 @@ + + + + + + + 南京工业大学校大学生科学技术协会招新邮件发送 + + + + +
+

南京工业大学校大学生科学技术协会招新邮件发送

+
+ +
+
+

获取邮箱的授权码和账户

+

这里推荐使用 163邮箱,注册后即可获得授权码。登录网页版后点击设置 - 账户 - POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服务 - + 开启服务 - POP3/SMTP服务 - 授权码,即可获得授权码。

+ 邮箱图标 +

访问链接

+
+ +
+

获取授权码

+ SMTP服务设置 +

在根目录下新建一个 key.txt 文件,把账号和授权码粘贴进去,保存。

+ 密码设置 +
+ +
+

下载

+
    +
  1. 下载最新版本的 + release +
  2. +
  3. 解压压缩包
  4. +
  5. 运行 main.exe
  6. +
+
+
+ + + + + \ No newline at end of file diff --git a/main.py b/main.py deleted file mode 100644 index 3c06afe..0000000 --- a/main.py +++ /dev/null @@ -1,67 +0,0 @@ -import smtplib -import json -from email.message import EmailMessage -from tqdm import tqdm -from utils.file_utils import read_recipient_list, read_credentials -from utils.smtp_utils import get_smtp_settings - -class EmailSenderApp: - def __init__(self, config): - self.status = config["status"] - self.department = config["department"] - self.qq_group_id = config["qqGroupId"] - self.file_path = f'./data/{self.status}名单.xlsx' - self.username, self.password = read_credentials('./key.txt') - recipient_data = read_recipient_list(self.file_path) - - if recipient_data: - self.send_emails(self.username, self.password, recipient_data) - - def send_emails(self, email_address, email_password, recipient_data): - total_recipients = len(recipient_data) - - with tqdm(total=total_recipients, desc="sending emails", unit="emails") as pbar: - for i, (recipient_name, recipient_email) in enumerate(recipient_data.items(), 1): - self.send_email(email_address, email_password, recipient_name, recipient_email) - pbar.update(1) - - def send_email(self, email_address, email_password, recipient_name, recipient_email): - smtp_host, smtp_port = get_smtp_settings(email_address) - smtp = smtplib.SMTP_SSL(smtp_host, smtp_port) - - subject = "南京工业大学校大学生科学技术协会面试结果通知" - msg = EmailMessage() - msg['Subject'] = subject - msg['From'] = email_address - msg['To'] = recipient_email - - try: - __path__ = f'web/{self.status}通知.html' - with open(__path__, 'r', encoding='utf-8') as f: - html_content = f.read() - - html_content = html_content.replace('{{name}}', recipient_name) - html_content = html_content.replace('{{qqGroupId}}', self.qq_group_id) - html_content = html_content.replace('{{department}}', self.department) - msg.add_alternative(html_content, subtype='html') - smtp.login(email_address, email_password) - smtp.send_message(msg) - print(f"successfully sent email to {recipient_name} ({recipient_email})") - except Exception as e: - print(f"failed to send email to {recipient_name} ({recipient_email}): {e}") - finally: - smtp.quit() - -def main(): - with open('config.json', 'r', encoding='utf-8') as config_file: - config = json.load(config_file) - - print(json.dumps(config, indent=4, ensure_ascii=False)) - - question = input("确认发送邮件吗?(y/n): ") - if question.lower() == 'y': - EmailSenderApp(config) - input("按任意键退出...") - -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 79514e9..0000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -openpyxl == 3.0.7 -tqdm == 4.62.3 \ No newline at end of file diff --git a/src/style.css b/src/style.css new file mode 100644 index 0000000..7463dae --- /dev/null +++ b/src/style.css @@ -0,0 +1,66 @@ +body { + font-family: Arial, sans-serif; + line-height: 1.6; + margin: 0; + padding: 20px; + background-color: #f4f4f4; + color: #333; +} + +header { + background: #333; + color: #fff; + padding: 10px 0; + text-align: center; +} + +.link { + background-color: aqua; +} + +h1 { + margin: 0; + font-size: 24px; +} + +h2 { + color: #333; +} + +.password .youxiang .smtp { + width: 400px; +} + +section { + background: #fff; + border: 1px solid #ddd; + border-radius: 5px; + margin: 20px 0; + padding: 15px; +} + +p { + margin: 10px 0; +} + +a { + color: #333; + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +img { + max-width: 100%; + height: auto; + margin: 10px 0; +} + +footer { + text-align: center; + margin-top: 20px; + font-size: 14px; + color: #777; +} \ No newline at end of file diff --git a/utils/file_utils.py b/utils/file_utils.py deleted file mode 100644 index 004cf1d..0000000 --- a/utils/file_utils.py +++ /dev/null @@ -1,35 +0,0 @@ -import openpyxl - -def read_credentials(key_file): - try: - with open(key_file, 'r') as file: - lines = file.readlines() - username = lines[0].strip() - password = lines[1].strip() - return username, password - except Exception as e: - print(f"读取密钥文件时出错:{e}") - return None, None - -def read_recipient_list(file_path): - try: - workbook = openpyxl.load_workbook(file_path) - sheet = workbook.active - - name_row_index = 0 - email_row_index = 1 - - result_dict = {} - for row in sheet.iter_rows(min_row=2, values_only=True): - name = row[name_row_index] - email = row[email_row_index] - result_dict[name] = email - - return result_dict - except FileNotFoundError: - print(f"文件未找到:{file_path}") - except ValueError: - print(f"表格中找不到 '姓名' 或 '邮件' 列") - except Exception as e: - print(f"读取文件时出错:{e}") - return None diff --git a/utils/smtp_utils.py b/utils/smtp_utils.py deleted file mode 100644 index 53d7057..0000000 --- a/utils/smtp_utils.py +++ /dev/null @@ -1,17 +0,0 @@ -def get_smtp_settings(email_address): - domain = email_address.split('@')[1].lower() - - if domain == '163.com': - return 'smtp.163.com', 465 - elif domain == 'gmail.com': - return 'smtp.gmail.com', 465 - elif domain == 'qq.com': - return 'smtp.qq.com', 465 - elif domain == 'outlook.com': - return'smtp-mail.outlook.com', 587 - elif domain == 'foxmail.com': - return'smtp.foxmail.com', 465 - elif domain == '126.com': - return'smtp.126.com', 25 - else: - raise ValueError(f"不支持的电子邮件域名: {domain}") diff --git "a/web/\345\275\225\345\217\226\351\200\232\347\237\245.html" "b/web/\345\275\225\345\217\226\351\200\232\347\237\245.html" deleted file mode 100644 index d40c057..0000000 --- "a/web/\345\275\225\345\217\226\351\200\232\347\237\245.html" +++ /dev/null @@ -1,337 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git "a/web/\346\234\252\345\275\225\345\217\226\351\200\232\347\237\245.html" "b/web/\346\234\252\345\275\225\345\217\226\351\200\232\347\237\245.html" deleted file mode 100644 index 4e78382..0000000 --- "a/web/\346\234\252\345\275\225\345\217\226\351\200\232\347\237\245.html" +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -