Use php send email in ubuntu.
  install the mail package: apt-get install sendmail sendmail-cf;
  and then use the cmd to send mail: mail hjwsm1989@gmail.com.
Use foreach syntax of php.