How to send email from Dialplan

The document describes ways of configuring Dialplan to send an email.

Created: October 2023

Permalink: https://wildix.atlassian.net/wiki/x/AQCnEQ


There are several ways you can send email from Dialplan:

Option 1: Use 'sendemail' application 

1. Add Custom application in Dialplan

2. In the Custom application field, enter the following data:

System(sendemail "youremail@domain.com" "email subject" "email body" /path/to/some_attachment_file.wav)

Where you need to replace the following points with the relevant info: 

  • email body: the the content of your email
  • email subject: the subject of your email
  • youremail@domain.com: replace with the email address where the email should be sent from
  • /path/to/some_attachment_file.wav: path to the file you want to attach to the email

Option 2: Use HTML template file

This method allows you to compose a more complex email using an HTML template file. 

1. Create HMTL email body and save to /tmp/ folder

2. Send the message to specific mail direction

3. Remove mail body file from tmp folder

For this, you need to add three Custom applications with the following data:

1) Custom application:

System(echo '<html><head></head><body> Missed call from ${CALLERID(name)} from the number <a href="tel:${CALLERID(num)}">${CALLERID(num)}</a>.</body></html>' > /tmp/mail_${UNIQUEID})

2) Custom application:

System(sendemail "youremail@domain.com" "email subject" /path/to/some_attachment_file.wav < /tmp/mail_${UNIQUEID})

3) Custom application:

System(rm /tmp/mail_${UNIQUEID})