Log In

This guide provides a simple script to send out E-Mail using your SMTP2GO Account. You may refer the Django documentation on Sending email for more options.

Step 1

Please change the following variables in this guide:

Sender Name: the sender’s name.

sender@example.com: the sender’s email address.

Recipient Name: the recipient’s name.

recipient@example.com: the recipient’s email address.

USERNAME: your SMTP username.

PASSWORD: your SMTP password.

Step 2

Add the following lines of code into the settings.py file:

EMAIL_HOST = 'mail.smtp2go.com'
EMAIL_HOST_USER = 'USERNAME'
EMAIL_HOST_PASSWORD = 'PASSWORD'
EMAIL_PORT = 2525
EMAIL_USE_TLS = True

Step 3

Add the following code in your application to send the email:

from django.core.mail import EmailMultiAlternatives

subject = 'Your Subject'
from_email = 'Sender Name '
to = 'Recipient Name '
text_content = 'This is a text message.'
html_content = '

This is an HTML message.

'
msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
msg.attach_alternative(html_content, "text/html")
msg.send(fail_silently=False)

Ready for better email delivery?

Try SMTP2GO free for as long as you like:

Try SMTP2GO Free → Paid plans available for over 1,000 emails/month.