1SPARKPOST_API_KEY = 'API_KEY'
2EMAIL_BACKEND = 'sparkpost.django.email_backend.SparkPostEmailBackend'
3
1from django.core.mail import EmailMultiAlternatives
2
3email = EmailMultiAlternatives(
4 subject='hello from sparkpost',
5 body='Woo hoo! Sent from Django!',
6 from_email='from@yourdomain.com',
7 to=['to@example.com'],
8 cc=['ccone@example.com'],
9 bcc=['bccone@example.com'],
10 reply_to=['replyone@example.com']
11)
12
13email.attach_alternative('<p>Woo hoo! Sent from Django!</p>', 'text/html')
14email.attach('image.png', img_data, 'image/png')
15email.send()
16
1SPARKPOST_OPTIONS = {
2 'track_opens': False,
3 'track_clicks': False,
4 'transactional': True,
5}
6
1from django.core.mail import send_mail
2
3send_mail(
4 subject='Hello from SparkPost',
5 message='Woo hoo! Sent from Django!',
6 from_email='from@yourdomain.com',
7 recipient_list=['to@example.com'],
8 html_message='<p>Hello Rock stars!</p>',
9)
10