HelloGitHub Email Configuration Options for the Notification System
The HelloGitHub notification system uses a simple SMTP-based configuration defined by the MAIL dictionary and RECEIVERS list in script/github_bot/github_bot.py to send automated email alerts.
The 521xueweihan/HelloGitHub repository includes an automated GitHub bot that monitors trending repositories and delivers updates via email. Understanding the available email configuration options for the notification system enables you to customize sender credentials, SMTP server parameters, and recipient lists to integrate with your existing mail infrastructure.
Core Email Configuration Parameters
The email functionality is controlled by a Python dictionary named MAIL located in script/github_bot/github_bot.py. This configuration object supports standard SMTP authentication and connection parameters required to send notifications via external mail servers.
Sender Authentication
The following keys manage the identity and credentials used to authenticate with the SMTP server:
mail: The sender email address that appears in the "From" field of outgoing messages. This is typically the same as the username for authentication purposes.username: The SMTP login username. In most configurations, this matches themailvalue, though some enterprise servers may require a distinct authentication identity.password: The SMTP login password or application-specific authorization token. For services like QQ Mail or Gmail, this should be an app-specific password rather than your main account password.
SMTP Server Settings
Connection parameters define which mail server handles the delivery:
host: The SMTP server hostname. The reference implementation uses QQ Mail (smtp.qq.com), but you can substitute any valid SMTP endpoint such assmtp.gmail.comor your organization's internal mail gateway.port: The SMTP server port. The configuration defaults to465, which enables SSL/TLS encryption viaSMTP_SSL. Alternative ports like587for STARTTLS would require modifying the connection logic in thesend_emailfunction.
Configuring Recipients with RECEIVERS
Separate from the MAIL configuration, the system uses a global list named RECEIVERS to define who receives the notifications. This list contains one or more email addresses as Python strings.
You can configure multiple recipients to distribute notifications across a team:
RECEIVERS = [
'admin@example.com',
'devops@example.com',
'alerts@example.com'
]
The send_email function iterates through this list and delivers the same HTML content to each address using individual SMTP transactions.
Implementation Details in github_bot.py
The actual email transmission logic resides in the send_email function (lines 86-108 of script/github_bot/github_bot.py). This function constructs a multipart HTML message and establishes an encrypted connection using Python's smtplib.SMTP_SSL.
The implementation follows this workflow:
- Parse the
MAILdictionary to extract credentials and server settings - Create a
MIMETextobject containing the HTML notification content - Connect to the specified
hostandportusingSMTP_SSLfor encryption - Authenticate with the
usernameandpassword - Iterate through
RECEIVERSand callsendmailfor each recipient
This design ensures that credentials are centralized in the MAIL configuration while allowing flexible recipient management through the RECEIVERS list.
Practical Configuration Examples
Basic MAIL Configuration
To configure the bot for a standard QQ Mail account, modify the MAIL dictionary in script/github_bot/github_bot.py:
MAIL = {
'mail': 'mybot@qq.com', # sender address
'username': 'mybot@qq.com', # SMTP user
'password': 'abcdefghijklmnop', # QQ Mail app-specific token
'host': 'smtp.qq.com', # QQ Mail SMTP server
'port': 465 # SSL port
}
RECEIVERS = [
'admin@example.com'
]
Environment Variable Configuration
For production deployments, avoid hardcoding credentials by using environment variables:
import os
MAIL = {
'mail': os.getenv('MAIL_ADDRESS', ''),
'username': os.getenv('MAIL_USER', ''),
'password': os.getenv('MAIL_PASS', ''),
'host': os.getenv('MAIL_HOST', 'smtp.qq.com'),
'port': int(os.getenv('MAIL_PORT', 465))
}
RECEIVERS = os.getenv('MAIL_RECEIVERS', 'admin@example.com').split(',')
This approach prevents sensitive tokens from appearing in version control while maintaining the same configuration structure expected by the send_email function.
Summary
- The HelloGitHub notification system uses a
MAILdictionary inscript/github_bot/github_bot.pyto configure SMTP authentication and server connection parameters. - Available configuration keys include
mail,username,password,host, andport, supporting standard SMTP with SSL/TLS encryption. - Recipients are managed separately through the
RECEIVERSlist, allowing multiple email addresses to receive identical notification content. - The
send_emailfunction implements the actual delivery logic usingsmtplib.SMTP_SSL, iterating through recipients after establishing an encrypted connection to the configured server.
Frequently Asked Questions
What SMTP server does HelloGitHub recommend?
The reference implementation in script/github_bot/github_bot.py uses QQ Mail (smtp.qq.com) with port 465 for SSL connections. However, the configuration is generic SMTP, so you can substitute any compatible provider such as Gmail, Outlook, or your organization's internal mail gateway by updating the host and port values in the MAIL dictionary.
How do I secure my email credentials?
Avoid hardcoding passwords in github_bot.py by loading sensitive values from environment variables. Use os.getenv() to retrieve the password, username, and other credentials at runtime. This prevents tokens from being exposed in version control and allows you to use container secrets or CI/CD environment variables for production deployments.
Can I send to multiple recipients?
Yes. The RECEIVERS variable is a Python list that supports one or more email addresses. The send_email function iterates through each entry in RECEIVERS and delivers the HTML notification content to every address listed. Simply append additional strings to the list to distribute alerts across a team or monitoring distribution list.
Where is the email sending logic implemented?
The email transmission logic resides in the send_email function defined at lines 86-108 of script/github_bot/github_bot.py. This function constructs a multipart HTML message, connects to the SMTP server using smtplib.SMTP_SSL with the credentials from the MAIL dictionary, and dispatches messages to each address in the RECEIVERS list.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →