Some background - I am trying to use the Gmail rest API to send an email with curl/libcurl. I am able to send a regular plain text email, but I am struggling to make sense of the API docs regarding attachments.
The API requires the email message to be passed in RFC 2822 format. I know almost nothing about this format, but I'm trying to learn. It just dawned on me that the reason why the Gmail API doesn't deal explicitly with attachments could be because RFC 2822 deals with attachments instead.
My question is - does RFC 2822 include the format of attachments as part of the email? If so then I would love to see an example message with a few header fields, a simple body and a simple text file as an attachment. Could anyone point me at such an example for beginners.
This RFC 2822 includes only text part of the email. No attachments or other MIME types.
To quote directly from the RFC 2822:
Scope
This standard specifies a syntax for text messages that are sent
between computer users, within the framework of "electronic mail"
messages. This standard supersedes the one specified in Request For
Comments (RFC) 822, "Standard for the Format of ARPA Internet Text
Messages" [RFC822], updating it to reflect current practice and
incorporating incremental changes that were specified in other RFCs
[STD3].This standard specifies a syntax only for text messages. In
particular, it makes no provision for the transmission of images,
audio, or other sorts of structured data in electronic mail messages. There are several extensions published, such as the MIME document
series [RFC2045, RFC2046, RFC2049], which describe mechanisms for the transmission of such data through electronic mail, either by
extending the syntax provided here or by structuring such messages to conform to this syntax. Those mechanisms are outside of the scope of this standard.In the context of electronic mail, messages are viewed as having an envelope and contents. The envelope contains whatever information is needed to accomplish transmission and delivery. (See [RFC2821] for a discussion of the envelope.) The contents comprise the object to be
delivered to the recipient. This standard applies only to the format and some of the semantics of message contents. It contains no
specification of the information in the envelope.