Apify actor to send mail.
Example:
{
// Email address of the recipient(s) (e.g. "Apify <info@apify.com>")
// Required
to: String,
// Email CC same format as to
// Required
cc: String
// Email BCC same format as to
bcc: String
// Email subject
// Required
subject: String,
// Text body of Email
// Required
text: String,
// Email attachments
attachments: [Object]
}
Attributes:
to
- Email address of the recipient(s), you can comma-separate multiple addresses (e.g. "Apify info@apify.com" or "info@apify.com, hello@apify.com")cc
- Email CC same format as tobcc
- Email BCC same format as tosubject
- Email subjecttext
- Text body of Emailhtml
- HTML body of EmailreplyTo
- Email address which will be set when recipient will try to reply to mail. (Uses headerReply-To
see doc)attachments
- array of attachments in base64 string, example:
[{
// attachment file name
filename: String,
// attachment content in base64 string
data: String
}]
await Apify.call('apify/send-mail', {
to: 'test@apify.com',
subject: 'Test from act',
text: "Email text",
attachments: [{
filename: 'test.txt',
data: 'dGVzdCBzZmFzZGFzZGFzZGFzZA'
}]
});
Calling this actor via a webhook is very handy because you can ensure it is sent only after specific event happens. Here is an example setup to send email after failed run.
- Open Webhooks tab of the actor/task that you want to monitor.
- Set Event types to
Run failed
andRun timed out
. - URL is the RUN API endpoint of this actor, just fill your API token - https://api.apify.com/v2/acts/apify~send-mail/runs?token=APIFY_API_TOKEN
- Payload template represents the body that is sent to this actor. An example below:
{
"to": "test@apify.com",
"subject": "Task Scrape-website run failed",
"text": "Run link - https://my.apify.com/tasks/{{eventData.actorTaskId}}#/runs/{{eventData.actorRunId}}"
}
This example expects that the webhook is sent from a task run. If you want to send it from an actor run, just update the "text" to
"text": "Run link - https://my.apify.com/actors/{{eventData.actorId}}#/runs/{{eventData.actorRunId}}"