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.

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
type AdminSendCustomEmailPayload {
# Success message or error details
message: String
# Boolean indicating whether the email was sent successfully
success: Boolean!
}
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
}
}
{
"data": {
"sendCustomEmail": {
"success": true,
"message": "Email sent successfully"
}
}
}

If the email fails to send:

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

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

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
`);
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()

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
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
  • 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.