When you use php to send an email from your server using sendmail, you may encounter some errors due to the default email From : from=<www-data@my-web-server>, a quick fix is to modify the php config file /etc/php5/apache2/php.ini
sendmail_path = '/usr/sbin/sendmail -t -i -fhello@cloudinit -Fcloudinit'