MailMerge main banner

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 is set up, we can quickly produce thousands of letters
  • Much easier to proofread just one letter than thousands of individual letters
  • Letters can be sent to people who meet specific criteria
  • Save and reuse a standard letter
  • Personalize letters
  • 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. It also allows you to personalize the letter as per the recipient’s 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 a data file. These are two input arguments to ExecuteMailMergeOnline

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, we are going to insert an HTML table and image within the template file and save the resultant file to 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.


In this article, we have discussed the details on how to perform mail merge using PHP Cloud SDK. We have exclusively explored details pertinent to performing mail merge using a template and how to insert HTML during mail merge. Please note that Aspose.Words Cloud SDK for PHP is developed under MIT license and its complete source code is available for download over GitHub. In case you encounter any issues while using the SDK, please feel free to contact us via the free product support forum.

We also recommend visiting the following links to learn more about