How to send attachments with email using Python

Introduction We have seen various examples on sending text email, RFC 822 standard email, HTML email but here we will see how to send attachments with email using Python 3. Attachments may be any type of files such as image, pdf, text etc. We will send email message over TLS and SSL ports using Gmail SMTP Server. We are going to show you how to attach inline image as well as a pdf document. Inline means your image will be displayed in the message body itself. You may also attach…

Continue

How to send an HTML email using Python

Introduction This tutorial will show you how to send an HTML email using Python 3. In our previous example we have seen how to send text message using Python 3 email library. Another variant of sending text message is using RFC 822 standard. In simple text email you don’t have option to decorate your message using styles or you cannot put any HTML link. We will connect to both TLS and SSL ports over Gmail SMTP server. We will use here email package from Python programming language.

Continue

How to use RFC 822 for sending email in Python

Introduction Here we will create an example to send text message using RFC 822 in Python 3 programming language. We have seen how to send simple text email using gmail SMTP server in Python programming language. In this example we will also send the text message using RFC 822 standard, because RFC 822 standard does not support special encoding for the message. Here we will use both TLS and SSL ports to send the message. RFC 822 is a standard for ARPA Internet Text Messages. RFC 822 standard is where…

Continue

Gmail SMTP and Security settings for sending email

Introduction We will see here how to do Gmail SMTP and Security settings for sending email using programming language. You can use any server side technology for sending email using Gmail SMTP server. This example will show you only what configurations you need in order to send email and it does not show any concrete example for sending email. This post will also show how to reduce the security level in Gmail settings to send email otherwise you will get an error even if you use correct username and password…

Continue

Send email with multiple attachments via Spring

This tutorial will show you how to send a basic mail via Spring framework’s email support. The Spring Framework provides a helpful utility library for sending email that shields the user from the specifics of the underlying mailing system and is responsible for low level resource handling on behalf of the client. I will show you both annotation based Spring Boot application and XML based Spring application using gradle and maven to send email with multiple attachments. A class that comes in pretty handy when dealing with JavaMail messages is…

Continue

Send email using email template library via Spring

This tutorial will show you how to send a basic mail via Spring framework’s email support using Velocity email template library. We will use class org.springframework.mail.javamail.MimeMessageHelper, which shields you from having to use the verbose JavaMail API. Using the MimeMessageHelper it is pretty easy to create a MimeMessage. The code in the other email sending examples explicitly created the content of the email message, using methods calls such as message.setText(..). This is fine for simple cases, and it is okay in the context of the aforementioned examples, where the intent…

Continue

Send email with inline attachment or resource via Spring

This tutorial will show you how to send a basic mail via Spring framework’s email support. We will attach a resource (an image) as an inline attachment in the email body. The Spring Framework provides a helpful utility library class that comes in pretty handy when dealing with JavaMail messages is the org.springframework.mail.javamail.MimeMessageHelper class, which shields you from having to use the verbose JavaMail API. Using the MimeMessageHelper it is pretty easy to create a MimeMessage. Multipart email messages allow for both attachments and inline resources.

Continue

Send email with attachment via Spring

This tutorial will show you how to send a basic mail via Spring framework’s email support. A class that comes in pretty handy when dealing with JavaMail messages is the org.springframework.mail.javamail.MimeMessageHelper class, which shields you from having to use the verbose JavaMail API. Using the MimeMessageHelper, it is pretty easy to create a MimeMessage. Multipart email messages allow for both attachments and inline resources. The following example shows you how to use the MimeMessageHelper to send an email along with a single MS Word attachment.

Continue