We send emails via mutation _sendEmail provided by the Email Sender extension.
The email is sent with content type "text" or "HTML" depending on what property from the messageAs input is used
The from input is optional; if not provided, the settings stored in WordPress are used
_sendEmail executes WordPress wp_mail function, so it will use the configuration defined for sending emails in WordPress (such as the SMTP provider to use)
Using the function fields provided by the PHP Functions via Schema, we can create a message template containing placeholders, and replace them with dynamic data:
We can retrieve the email of the admin user from the WordPress wp_options table, and inject this value into the to field:
Alternatively, if Nested Mutations is enabled in the Schema Configuration, we can retrieve the admin email in the mutation operation already (and inject it into the mutation via Field to Input):
Because _sendEmail is a global field (or, more precisely, a global mutation), it can be executed on any type from the GraphQL schema, including User.
This query retrieves a list of users, obtains their data (name, email and number of remaining credits, which is stored as meta), and sends a personalized email to each of them: