Skip to content

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

FieldTypeDescription
emailString!Email address of the recipient
subjectString!The subject of the email (Base64 encoded)
contentString!The content of the email (Base64 encoded)
templateVariablesJSONTemplate variables for dynamic content

Return Type

type AdminSendCustomEmailPayload {
# Success message or error details
message: String
# Boolean indicating whether the email was sent successfully
success: Boolean!
}

Example

mutation SendCustomEmail {
sendCustomEmail(
subject: "V2VsY29tZSB0byBvdXIgY291cnNlIQ==" # Base64 for "Welcome to our course!"
content: "SGkgSm9obiwgd2VsY29tZSB0byBvdXIgR3JhcGhRTCBjb3Vyc2UhIFdlJ3JlIGV4Y2l0ZWQgdG8gaGF2ZSB5b3UuLi4=" # Base64 encoded content
templateVariables: {
userName: "John"
courseName: "GraphQL Fundamentals"
}
) {
success
message
}
}

Sample Response

{
"data": {
"sendCustomEmail": {
"success": true,
"message": "Email sent successfully"
}
}
}

Error Response

If the email fails to send:

{
"data": {
"sendCustomEmail": {
"success": false,
"message": "Invalid email address"
}
}
}

Base64 Encoding

The subject and content fields must be Base64 encoded. Here’s how to encode them:

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

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

The templateVariables field allows you to pass dynamic content that can be used in the email template. Common variables include:

VariableDescription
userNameThe recipient’s name
courseNameName of a course
schoolNameName of your school
customDataAny custom data you want to include

Common Errors

ErrorDescription
Invalid email addressThe provided email address is not valid
Subject requiredThe email subject cannot be empty
Content requiredThe email content cannot be empty
Invalid Base64 encodingThe subject or content is not properly Base64 encoded
Email service unavailableThe email service is temporarily unavailable

Important Notes

  • Both subject and content must 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

For more information about the Teachify Admin API, please refer to the API Overview.