Ok so your code looks fine to me, if you want to change the message you should change the text in the echo statement. like echo "Some fancy html in here";
. The second issue about mail not receiving is probably due to the fact that php relies on the local smtp server by default to send mail, which on windows is nonexistent so its not sending it at all if you have xampp probably and on linux depending on many variables it might be sending it and its going in your spam folder or it might not be sending it at all. If you want to use a third party smtp server such as your gmail one just for testing purposes, the best and easiest way is to use some library such as:
http://swiftmailer.org/docs/sending.html
and define the third party smtp details.
The example code:
require_once 'lib/swift_required.php';
// Create the Transport
$transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25)
->setUsername('your username')
->setPassword('your password')
;
/*
You could alternatively use a different transport such as Sendmail or Mail:
// Sendmail
$transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
// Mail
$transport = Swift_MailTransport::newInstance();
*/
// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
// Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('john@doe.com' => 'John Doe'))
->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name'))
->setBody('Here is the message itself')
;
// Send the message
$result = $mailer->send($message);
is pretty straightforward i think, and you can add also:
if($result){ echo "Message has been sent"; }else{ echo "Error!"; }
at the very end. That should do the trick...
btw the settings for gmail are:
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl');
and use your gmail email and password for username and password accordingly...