Send Custom Email
The sendCustomEmail mutation allows you to send custom emails to users through the Teachify platform. This enables you to communicate directly with your students and users.
Input Parameters
Section titled “Input Parameters”| Field | Type | Description |
|---|---|---|
email | String! | Email address of the recipient |
subject | String! | The subject of the email (Base64 encoded) |
content | String! | The content of the email (Base64 encoded) |
templateVariables | JSON | Template variables for dynamic content |
Return Type
Section titled “Return Type”type AdminSendCustomEmailPayload { # Success message or error details message: String
# Boolean indicating whether the email was sent successfully success: Boolean!}Example
Section titled “Example”mutation SendCustomEmail { sendCustomEmail( email: "student@example.com" subject: "V2VsY29tZSB0byBvdXIgY291cnNlIQ==" # Base64 for "Welcome to our course!" content: "SGkgSm9obiwgd2VsY29tZSB0byBvdXIgR3JhcGhRTCBjb3Vyc2UhIFdlJ3JlIGV4Y2l0ZWQgdG8gaGF2ZSB5b3UuLi4=" # Base64 encoded content templateVariables: { userName: "John" courseName: "GraphQL Fundamentals" } ) { success message }}Sample Response
Section titled “Sample Response”{ "data": { "sendCustomEmail": { "success": true, "message": "Email sent successfully" } }}Error Response
Section titled “Error Response”If the email fails to send:
{ "data": { "sendCustomEmail": { "success": false, "message": "Invalid email address" } }}Base64 Encoding
Section titled “Base64 Encoding”The subject and content fields must be Base64 encoded. Here’s how to encode them:
JavaScript Example
Section titled “JavaScript Example”const subject = btoa("Welcome to our course!");const content = btoa(`Hi {{userName}},
Welcome to {{courseName}}! We're excited to have you join us.
Best regards,The Teachify Team`);Python Example
Section titled “Python Example”import base64
subject = base64.b64encode("Welcome to our course!".encode()).decode()content = base64.b64encode("""Hi {{userName}},
Welcome to {{courseName}}! We're excited to have you join us.
Best regards,The Teachify Team""".encode()).decode()Template Variables
Section titled “Template Variables”The templateVariables field allows you to pass dynamic content that can be used in the email template. Common variables include:
| Variable | Description |
|---|---|
userName | The recipient’s name |
courseName | Name of a course |
schoolName | Name of your school |
customData | Any custom data you want to include |
Common Errors
Section titled “Common Errors”| Error | Description |
|---|---|
Invalid email address | The provided email address is not valid |
Subject required | The email subject cannot be empty |
Content required | The email content cannot be empty |
Invalid Base64 encoding | The subject or content is not properly Base64 encoded |
Email service unavailable | The email service is temporarily unavailable |
Important Notes
Section titled “Important Notes”- Both
subjectandcontentmust be Base64 encoded - Template variables can be used within the content using double curly braces (e.g.,
{{userName}}) - Emails are sent asynchronously - a successful response means the email was queued for delivery
- Consider rate limiting when sending bulk emails
Related Resources
Section titled “Related Resources”- User Management - Managing users
- Email Templates - Creating email templates
For more information about the Teachify Admin API, please refer to the API Overview.