How to send an email using PHP?

user590849 picture user590849 · Mar 17, 2011 · Viewed 1M times · Source

I am using PHP on a website and I want to add emailing functionality.

I have WAMPSERVER installed.

How do I send an email using PHP?

Answer

Muthu Kumaran picture Muthu Kumaran · Mar 17, 2011

Using PHP's mail() function it's possible. Remember mail function will not work on a Local server.

<?php
$to      = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?> 

Reference: