I\'ve done quite a bit of inbox manipulation with Gmail via IMAP functions in PHP, but one thing I haven\'t found is a way to create messages. I\'m not sure if IMAP or SMTP
You might want to look at imap_mail_compose()
Edit This doesn't create the message on the server. You need to use imap_append() also.
Further Edit This seems to work ok: