Sends messages with different services such as email and Google Chat.
pip install message-senderSend messages to Google Chat via webhooks. To set this up, create a "space" in Google Chat, then go to Apps & integrations and create a new webhook.
from message_sender.google_chat import GoogleChatClient
with GoogleChatClient("https://your-webhook-url.com") as client:
client.send_message("Some test message")from message_sender.google_chat import AsyncGoogleChatClient
async with AsyncGoogleChatClient("https://your-webhook-url.com") as client:
await client.send_message("Some test message")Send messages to Discord via webhooks. For setup instructions see https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks
from message_sender.discord import DiscordClient
with DiscordClient("https://your-webhook-url.com") as client:
client.send_message("Some test message")from message_sender.discord import AsyncDiscordClient
async with AsyncDiscordClient("https://your-webhook-url.com") as client:
await client.send_message("Some test message")Send emails through any SMTP server. Port 465 uses implicit TLS, other ports use STARTTLS.
from message_sender.email.smtp import SMTPClient
client = SMTPClient(
smtp_server="smtp.example.com",
smtp_port=587,
email_from="sender@example.com",
user_name="your-username",
password="your-password",
)
client.send_email(
message="Your message body",
email_to="someone@email.com",
subject="Example",
html_content="<p>Your HTML message body</p>", # optional
)from message_sender.email.smtp import AsyncSMTPClient
client = AsyncSMTPClient(
smtp_server="smtp.example.com",
smtp_port=587,
email_from="sender@example.com",
user_name="your-username",
password="your-password",
)
await client.send_email(
message="Your message body",
email_to="someone@email.com",
subject="Example",
html_content="<p>Your HTML message body</p>", # optional
)Send emails through Proton Mail's SMTP service. For setup instructions see https://proton.me/support/smtp-submission
from message_sender.email.proton import ProtonEmailClient
client = ProtonEmailClient(email_address="smtp_setup_email@proton.me", smtp_token="your-token")
client.send_email(
message="Your message body",
email_to="someone@email.com",
subject="Example",
html_content="<p>Your HTML message body</p>", # optional
)from message_sender.email.proton import AsyncProtonEmailClient
client = AsyncProtonEmailClient(email_address="smtp_setup_email@proton.me", smtp_token="your-token")
await client.send_email(
message="Your message body",
email_to="someone@email.com",
subject="Example",
html_content="<p>Your HTML message body</p>", # optional
)Send emails through Gmail's SMTP service. Requires a Google App Password (not your regular account password), which can be generated from your Google Account settings once 2-Step Verification is enabled.
from message_sender.email.gmail import GmailClient
client = GmailClient(email_address="sender@gmail.com", app_password="your-app-password")
client.send_email(
message="Your message body",
email_to="someone@email.com",
subject="Example",
html_content="<p>Your HTML message body</p>", # optional
)from message_sender.email.gmail import AsyncGmailClient
client = AsyncGmailClient(email_address="sender@gmail.com", app_password="your-app-password")
await client.send_email(
message="Your message body",
email_to="someone@email.com",
subject="Example",
html_content="<p>Your HTML message body</p>", # optional
)