
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Django MailerSend makes it easier to send emails in Django apps using the MailerSend API.
Django MailerSend makes it easier to send emails in Django apps using the MailerSend API. Uses the official MailerSend Python SDK internally.
pip install django-mailersend
Add the following to your Django settings:
EMAIL_BACKEND = 'django_mailersend.backend.MailerSendEmailBackend'
MAILERSEND_API_KEY = 'Your API key'
send_mail
function:from django.core.mail import send_mail
send_mail(
subject='Hello world!',
message='Sent using the Django MailerSend Email Backend!',
from_email='sender@example.com',
recipient_list=['receiver@example.com']
)
EmailMessage
class for more options:from django.core.mail.message import EmailMessage
email_message = EmailMessage(
subject='Hello world!',
body='Sent using the Django MailerSend Email Backend!',
from_email='sender@example.com',
to=['receiver@example.com'],
bcc=['bcc@example.com'], # Optional
cc=['cc@example.com'], # Optional
reply_to=['reply-to@example.com'] # Optional
)
email_message.send()
send_mail
function:from django.core.mail import send_mail
send_mail(
subject='Hello world!',
message='Sent using the Django MailerSend Email Backend!',
from_email='sender@example.com',
recipient_list=['receiver@example.com'],
html_message='<p>Sent using <strong>Django MailerSend Email Backend</strong>!</p>'
)
EmailMultiAlternatives
class for more
options:from django.core.mail.message import EmailMultiAlternatives
email_message = EmailMultiAlternatives(
subject='Hello world!',
body='Sent using Django MailerSend Email Backend!',
from_email='sender@example.com',
to=['receiver@example.com'],
bcc=['bcc@example.com'], # Optional
cc=['cc@example.com'], # Optional
reply_to=['reply-to@example.com'] # Optional
)
email_message.attach_alternative(
'<p>Sent using <strong>Django MailerSend Email Backend</strong>!</p>',
'text/html'
)
email_message.send()
Sending attachments is supported when using Django's EmailMessage
or
EmailMultiAlternatives
classes. There are several ways of doing this:
path
to the attach_file
method:from django.core.mail.message import EmailMessage
email_message = EmailMessage(
subject='Hello world!',
body='Sent using the Django MailerSend Email Backend!',
from_email='sender@example.com',
to=['receiver@example.com']
)
email_message.attach_file('/example/attachment.txt')
email_message.attach_file('/example/attachment.jpg')
email_message.send()
filename
and the file content
to the attach
method:from django.core.mail.message import EmailMessage
email_message = EmailMessage(
subject='Hello world!',
body='Sent using the Django MailerSend Email Backend!',
from_email='sender@example.com',
to=['receiver@example.com']
)
# Text file (Read mode 'r')
with open('/example/attachment.txt', 'r') as file:
email_message.attach('attachment.txt', file.read())
# Binary file (Read mode 'rb')
with open('/example/attachment.jpg', 'rb') as file:
email_message.attach('attachment.jpg', file.read())
email_message.send()
MIMEBase
instance to the attach
method:from email.mime.image import MIMEImage
from email.mime.text import MIMEText
from django.core.mail.message import EmailMessage
email_message = EmailMessage(
subject='Hello world!',
body='Sent using the Django MailerSend Email Backend!',
from_email='sender@example.com',
to=['receiver@example.com']
)
# Text file (Read mode 'r')
with open('/example/attachment.txt', 'r') as file:
mime_text = MIMEText(file.read())
mime_text.add_header(
'Content-Disposition', 'attachment; filename=attachment.txt')
email_message.attach(mime_text)
# Binary file (Read mode 'rb')
with open('/example/attachment.jpg', 'rb') as file:
mime_image = MIMEImage(file.read())
mime_image.add_header(
'Content-Disposition', 'inline; filename=attachment.jpg')
email_message.attach(mime_image)
email_message.send()
FAQs
Django MailerSend makes it easier to send emails in Django apps using the MailerSend API.
We found that django-mailersend demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.