在PHP中使用自定义电子邮件模板发送电子邮件

I have a fetched a following record from database

post_name     post_detail               Technology
SE            Software Enginner         C,Java 
SSE           Senior Software Engineer  C,Java,PHP
TL            Tech Lead                 ios

Now I have 3 users let X,Y,Z

I need to send the email to each users in the following format

User X Mail Template

Software Engineer | C,Java

Need a Software Engineer for C and Java and PHP

Tech Lead | Ios

Need a Tech lead for ios 

User Y Mail Template

Senior Software Engineer | C,Java,PHP

Need a Senior Software Engineer for C and Java

Tech Lead | Ios

Need a Tech lead for ios 

I have tried to send the email using for loops but i can not able to send the email in above format , i can send only one job to user at a time (If i have three jobs for users then i have to sent three mails for each job) I want to send all fetched jobs in a single email to the user in above format.

Thanks In Advance !!