Sending Email
You can send out emails from your DreamFactory instance using various email service providers. The following email providers are currently supported:
- AWS SES
- Mailgun
- Mandrill
- Local sendmail
- SMTP
Contents
Provisioning an Email Service
You can provision an email service from the admin console.
Log in to the admin console and select the 'Services' tab. Click on the 'Create' button from the left menu. On the service creation form select your email provider from the 'Service Type' drop down box. Enter a short, one-word, meaningful name for your service as well as a label and description.
For this tutorial, let's say we name our email service 'mailer'. Depending on which provider you pick, you will need to enter the service configuration values on the 'Config' tab. Create your email service after entering all your configuration values. Your email service is now ready to send out emails.
API Endpoints
POST https://{url}/api/v2/{email_service_name}
Request body:
{ "template": "", // (Optional) Email template name if any. "template_id": 0, // (Optional) Email template ID if any. "to": [ { "name": "", "email": "" } ], "cc": [ { "name": "", "email": "" } ], "bcc": [ { "name": "", "email": "" } ], "subject": "", "body_text": "", "body_html": "", "from_name": "", "from_email": "", "reply_to_name": "", "reply_to_email": "" }
Example - Sending email using a template
- Email service name: mailer
- Email template name: newsletter
- Recipient's name: John Doe
- Recipient's email: [email protected]
- Email subject: A test email
- Email body: This is a test email
- From name: Jane Doe
- From email: [email protected]
- Reply to name: Jane Doe
- Reply to email: [email protected]
- Request body:
{ "template": "newsletter", "to": [ { "name": "John Doe", "email": "[email protected]" } ], "subject": "A test email", "body_text": "This is a test email", "from_name": "Jane Doe", "from_email": "[email protected]", "reply_to_name": "Jane Doe", "reply_to_email": "[email protected]" }
- Request URL:
POST https://foo.com/api/v2/mailer
Example - Sending email using an in-load data
- Email service name: mailer
- Recipient's name: John Doe
- Recipient's email: [email protected]
- Email subject: A test email
- Email body: Hi {name}, This is a test for {service} service.
- name = 'John'
- service = 'mailer'
- From name: Jane Doe
- From email: [email protected]
- Reply to name: Jane Doe
- Reply to email: [email protected]
- Request body:
{ "to": [ { "name": "John Doe", "email": "[email protected]" } ], "subject": "A test email", "body_text": "Hi {name}, This is a test for {service} service.", "from_name": "Jane Doe", "from_email": "[email protected]", "reply_to_name": "Jane Doe", "reply_to_email": "[email protected]", "name":"John", "service":"mailer" }
- Request URL:
POST https://foo.com/api/v2/mailer