graph LR
Mail_Composer["Mail Composer"]
Personalization_Manager["Personalization Manager"]
Email_Data_Models["Email Data Models"]
Internal_Utilities["Internal Utilities"]
Mail_Composer -- "uses" --> Personalization_Manager
Mail_Composer -- "uses" --> Email_Data_Models
Personalization_Manager -- "uses" --> Email_Data_Models
Mail_Composer -- "uses" --> Internal_Utilities
Personalization_Manager -- "uses" --> Internal_Utilities
The Email Message Assembly subsystem is responsible for constructing a complete email message payload that adheres to SendGrid's API specifications. It manages global email attributes, handles recipient-specific personalization, and utilizes various data models to represent different parts of an email. The core flow involves a Mail Composer component that orchestrates the assembly, leveraging a Personalization Manager for recipient-specific details and a set of Email Data Models for structured data representation. Internal utility methods support the data manipulation within these main components.
This component is responsible for the overall construction and representation of an email message. It provides methods to set global email attributes like sender, subject, content, attachments, and manage personalizations. It also handles the conversion of the email object into a JSON-ready format for sending.
Related Classes/Methods:
sendgrid.helpers.mail.mail.Mail(20:1041)sendgrid.helpers.mail.mail.Mail:__init__(23:81)sendgrid.helpers.mail.mail.Mail:__str__(83:89)sendgrid.helpers.mail.mail.Mail:from_email(658:663)sendgrid.helpers.mail.mail.Mail:reply_to(679:684)sendgrid.helpers.mail.mail.Mail:content(734:735)sendgrid.helpers.mail.mail.Mail:add_content(750:783)sendgrid.helpers.mail.mail.Mail:attachment(794:795)sendgrid.helpers.mail.mail.Mail:add_attachment(810:816)sendgrid.helpers.mail.mail.Mail:template_id(819:824)sendgrid.helpers.mail.mail.Mail:section(847:848)sendgrid.helpers.mail.mail.Mail:add_section(862:868)sendgrid.helpers.mail.mail.Mail:category(879:880)sendgrid.helpers.mail.mail.Mail:add_category(894:899)sendgrid.helpers.mail.mail.Mail:get(986:1015)sendgrid.helpers.mail.mail.Mail:from_EmailMessage(1018:1041)
This component manages recipient-specific data within an email, allowing for different recipients to receive customized subjects, headers, substitutions, custom arguments, and send times. It orchestrates the addition and management of Personalization objects.
Related Classes/Methods:
sendgrid.helpers.mail.personalization.Personalization(1:271)sendgrid.helpers.mail.mail.Mail:_set_emails(136:191)sendgrid.helpers.mail.mail.Mail:add_personalization(201:210)sendgrid.helpers.mail.mail.Mail:to(213:214)sendgrid.helpers.mail.mail.Mail:add_to(244:277)sendgrid.helpers.mail.mail.Mail:cc(280:281)sendgrid.helpers.mail.mail.Mail:add_cc(311:332)sendgrid.helpers.mail.mail.Mail:bcc(335:336)sendgrid.helpers.mail.mail.Mail:add_bcc(371:399)sendgrid.helpers.mail.mail.Mail:subject(402:407)sendgrid.helpers.mail.mail.Mail:header(445:446)sendgrid.helpers.mail.mail.Mail:add_header(461:491)sendgrid.helpers.mail.mail.Mail:substitution(494:495)sendgrid.helpers.mail.mail.Mail:add_substitution(510:536)sendgrid.helpers.mail.mail.Mail:custom_arg(547:548)sendgrid.helpers.mail.mail.Mail:add_custom_arg(564:594)sendgrid.helpers.mail.mail.Mail:send_at(597:602)sendgrid.helpers.mail.mail.Mail:dynamic_template_data(633:634)sendgrid.helpers.mail.personalization.Personalization:add_email(19:33)sendgrid.helpers.mail.personalization.Personalization:tos(50:55)sendgrid.helpers.mail.personalization.Personalization:add_to(61:82)sendgrid.helpers.mail.personalization.Personalization:ccs(96:101)sendgrid.helpers.mail.personalization.Personalization:bccs(116:121)
This component comprises various classes that serve as data structures for specific email attributes. These classes encapsulate the data and provide methods to retrieve their JSON representation, facilitating the construction of the overall email payload.
Related Classes/Methods:
sendgrid.helpers.mail.to_email.To(4:5)sendgrid.helpers.mail.cc_email.Cc(4:5)sendgrid.helpers.mail.bcc_email.Bcc(4:5)sendgrid.helpers.mail.content.Content(5:81)sendgrid.helpers.mail.from_email.From(4:5)sendgrid.helpers.mail.reply_to.ReplyTo(4:5)sendgrid.helpers.mail.subject.Subject(1:69)sendgrid.helpers.mail.header.Header(1:94)sendgrid.helpers.mail.substitution.Substitution(1:90)sendgrid.helpers.mail.custom_arg.CustomArg(1:94)sendgrid.helpers.mail.send_at.SendAt(1:79)sendgrid.helpers.mail.dynamic_template_data.DynamicTemplateData(1:73)sendgrid.helpers.mail.template_id.TemplateId(1:39)sendgrid.helpers.mail.email.Email(13:228)sendgrid.helpers.mail.dynamic_template_data.DynamicTemplateData:__str__(59:64)sendgrid.helpers.mail.dynamic_template_data.DynamicTemplateData.get(66:73)sendgrid.helpers.mail.send_at.SendAt:__str__(65:70)sendgrid.helpers.mail.send_at.SendAt.get(72:79)sendgrid.helpers.mail.email.Email:__init__(16:60)
This component consists of private helper methods within the Mail and Personalization classes that provide common functionalities like ensuring items are appended or inserted into lists, flattening dictionaries, and safely retrieving JSON representations of objects. These are internal to the Mail class's operation.
Related Classes/Methods:
sendgrid.helpers.mail.mail.Mail._ensure_append(91:103)sendgrid.helpers.mail.mail.Mail._ensure_insert(105:115)sendgrid.helpers.mail.mail.Mail._flatten_dicts(117:125)sendgrid.helpers.mail.mail.Mail._get_or_none(127:134)sendgrid.helpers.mail.personalization.Personalization._get_unique_recipients(35:46)