Thenet/mailpackage provides a number of useful functions that assist you when working with email. If you have the raw text of the email, it can be parsed into extract headers, information about the send date, and much more. This recipe will demonstrate a number of these functions by parsing a raw email hardcoded as a string.
How to do it...
These steps cover writing and running your application:
- From your Terminal or console application,create a new directory called~/projects/go-programming-cookbook/chapter5/mailand navigate to this directory.
- Run the following command:
$ go mod init github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition/chapter5/mail
You should see a file calledgo.modthat contains the following:
module github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition/chapter5/mail
- Copy tests from~/projects...