Mail Merge using PHP Cloud API

MailMerge main banner

The Microsoft Word’s mail merge is one remarkable feature that enables the users to render letters into documents that read like individual correspondence. Compared to the process of preparing individual letters to convey one set of information to many people, mail merge saves time and effort, producing mass mailings complete with labels or envelopes, and you can send a unified message with customized details. Other benefits of Mail Merge include

  • Once the merge has been set up, thousands of letters can be produced very quickly
  • Much easier to proofread just one letter than thousands of individual letters
  • Letters can be sent to people who meet specific criteria
  • A standard letter can be saved and reused
  • Letters can be personalized
  • The same data source and be reused – reducing the risk of errors

Keeping in view the importance of this feature, Aspose.Words Cloud perfectly supports the Mail Merge feature and a letter can easily be personalized to deal with each recipient by name. The data source can be a sort of a list, spreadsheet, or database, is related to the document. In this blog post, we will be discussing the points to populate the mail merge or mustache template with data using PHP language.

MailMerge using Template

In order to use the MailMerge feature, we need to use the Word template document and datafile which are provided as an argument to ExecuteMailMergeOnline, and resultant file with updated content is generated.

cRUL command

curl -X PUT "" -H  "accept: application/octet-stream" -H  "Authorization: Bearer <JWT Token>" -H  "Content-Type: multipart/form-data" -H  "x-aspose-client: Containerize.Swagger" -d {"Template":{},"Data":{}}

Request URL


MailMerge resultant file
Fig 1:- Preview of MailMerge operation.

Insert HTML during Mail Merge

Apart from simple content, the API also provides the capabilities to insert HTML inside Mail Merge fields. The ExecuteMailMerge API enables you to insert HTML inside Mail Merge fields. As per the example below, an HTML table and image are inserted within the template file and the resultant file is stored over cloud storage.

cURL command

curl -X PUT "" -H  "accept: application/json" -H  "Authorization: Bearer <JWT Token>" -H  "Content-Type: multipart/form-data" -H  "x-aspose-client: Containerize.Swagger" -d {"data":""}

Request URL


Mail Merge preview after HTML insert
Fig 2:- Mail Merge after HTML insert.