Mutation _sendEmail sends emails by executing WordPress wp_mail function. As a result, it will use the configuration defined for sending emails in WordPress (such as the SMTP provider to use).
The email can be sent with content types "text" or "HTML", depending on the value of the messageAs input (which is a "oneof" InputObject, so that only one of its properties can be provided).
_sendEmail is a global field (or, more precisely, a global mutation). This means that, if Nested Mutations are enabled, this mutations can be executed on any type from the GraphQL schema (i.e. not only in MutationRoot).
This is useful for iterating a list of users, and sending an email to each of them (in this case, the mutation is triggered while in the User type):
Combined with features from other extensions (in this case, Field to Input and PHP Functions via Schema), we can create personalized messages for every user:
The query below sends an email to the admin user with some post's content (eg: it can be triggered whenever a new post is published). It uses extensions:
Multiple Query Execution to manage the query into logical units
Helper Function Collection to compose the email message using Markdown and convert it to HTML via _strConvertMarkdownToHTML
PHP Functions via Schema to dynamically inject values into the email subject and message via fields _strReplaceMultiple and _sprintf
Field to Input to retrieve and provide the admin's email from wp_options