Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pysgs

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pysgs

Send messages through SendGrid using SMTP

  • 1.2
  • PyPI
  • Socket score

Maintainers
1

PYSGS

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

Table of Contents

  • Installation
  • Setup
  • Usage
  • Example

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))

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc