The Transactional Email Object represents a transactional email template in your Go-Mailer account. The API allows you to send or dispatch transactionals to your contacts.
Sends the specified transactional email to the specified recipients. A recipient does not have to be a contact in your account.
The transactional template's unique code.
The email address of the recipient.
The email address to blind copy.
A valid HTML document, for the event where you would like to use your own predesigned or pregenerated HTML markup as the email content. This will override the design you created in your Go-Mailer account.
A key => value set of information which will be used to replace any placeholders specified in the transactional email.
The key should be the name of the placeholder used. e.g: if you used @firstname placeholder in your template, then your data object should look like this { firstname: "Sample Name" }
This is a list of attachments to be sent via the transactional. Each attachment MUST NOT be more than 1MB.
This is the name of the attachment as it should be displayed to the recipient.
The link to the file if the attachment is hosted on a remote server.
This is a base64 representation of the attachment. This is best where the attachment is not hosted remotely.
This is the mimetype of the attachment. The supported values include: application/pdf
This is the attachment's content encoding. This should be base64
const response = await fetch("https://api.go-mailer.com/v1/transactionals", {
method: "POST",
headers: {
Authorization: "Bearer <API_KEY>"
},
body: JSON.stringify({
template_code: "BIRTHDAY_EMAIL",
recipient_email: "johndoe@example.com",
bcc: "admin@my-company.com",
data: {
firstname: "John",
age: 47,
},
attachments: [{
filename: "yourfile.pdf",
path: "https://path/to/file",
}]
})
});