You need a From: [VALID EMAIL]
header of the message when you send the message. Try doing something like this:
$headers = array(
'From: [email protected]',
'Mime-Type: text/plain; charset=utf-8',
);
$dest = '[email protected]';
$subj = 'test';
$message = 'hello world';
mail($dest, $subj, $message, implode("\r\n", $headers));
Also, the mail
function is meant to be used as a frontend to the mail daemon that's running on the same server the web server is running on. Since most *NIX boxes have both, it usually works.
What I would not recommend, however, is using some remote server to send your mail. It's much more efficient and reliable (not to mention looking more professional) to just have the same server send the message as the one that generated the message.
Setting up your own SMTP server is easy and free and more flexible than Gmail. Gmail WILL NOT send messages whose From:
header does not match either the main account address or a connected address.