Modifying the email content to include an attachment

In this recipe, you will learn how to send a file as an attachment to the registered user. In our previous recipe, we created a log file of the email content. We will send the same file as an attachment to the email. However, in real-world applications, you might not intend to send log files to the end user. For the sake of simplicity, we will send the log file as an attachment.

At the time of writing, SendGrid recommends that the size of the attachment shouldn't exceed 10 MB though, technically, your email can be as large as 20 MB.