Skip to main content

PYSGS

This is a small tool designed as part of learning, allows sending SendGrid messages via SMTP

Table of Contents

Installation

pip install pysgs

Setup

import pysgs
service = pysgs.mailer('SENDGRID_API_KEY')

Headers

sender = "user@example.com"
recipient = "anotheruser@example.com"
subject = "This is a Subject!!"
service.headers(sender, recipient, subject)

Sender

There are different ways to set recipent emails.

You can also send a list of recipients

recipients = [
    "User <user@example.com>",
    "Another User <anotheruser@example.com>"
]

Usage

Plain text

service.content('Message from sendgrid')
service.send()

HTML Content

service.content('<h1>Hello World!</h1>', 'html')
service.send()

Attachment

service.content('/path/to/file/audio.mp3', is_attach=True)
service.send()

Example

import pysgs
from pysgs.exceptions import SGSError

try:
    """Start connection"""
    service = pysgs.mailer("SENDGRID_API_KEY")

    """Set message headers"""
    sender = "user@example.com"
    recipient = "anotheruser@example.com"
    subject = "This is a Subject!!"
    service.headers(sender, recipient, subject)

    """Set content"""
    service.content('Message from sendgrid')
    service.content('<h1>Hello World!</h1>', 'html')
    service.content('/path/to/file/audio.mp3', is_attach=True)

    """Send message"""
    service.send()

    """Finish service"""
    service.close()

except SGSError as e:
    print('There was an error: ' + str(e))

Metadata

Release files for pysgs 1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for pysgs 1.2
File Interpreter ABI Platform Actions
pysgs-1.2-py3-none-any.whl Python 3 none any Details for pysgs-1.2-py3-none-any.whl

Release files / pysgs-1.2-py3-none-any.whl

Download URL pysgs-1.2-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
caf7ecd2f05cd2f40f34262cbc43f54285d3cb3d9b178bff4c5bfb2ae7ae09a5
BLAKE2b-256 checksum
How to use checksums
0cc3dda7615504e710e0224bc8ef26697a6484dc177f44e5b4882cebb1059b5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.7

Security for pysgs 1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page