The PHP mail() function allows you to send emails directly from a script.
PHP use the mail() function to send an email. PHP Mail() function requires three mandatory parameters and two optional parameters. First Three parameters specify the email address, the subject of the mail and the actual message of mail.
mail( to, subject, message, headers, parameters );
Following example will send a simple plain text email to xyz@example.com.
<?php $to = "xyz@example.com"; $subject = "My subject"; $txt = "Hello world! This is simple plain text php mail"; $headers = "From: webmaster@example.com" . "\r\n" . "CC: somebodyelse@example.com"; mail($to,$subject,$txt,$headers); ?>
<?php $to = "xyz@example.com"; $subject = "My subject"; $txt = "Hello world! This is simple plain text php mail"; $headers = "From: webmaster@example.com" . "\r\n" . "CC: somebodyelse@example.com"; mail($to,$subject,$txt,$headers); ?>
<html> <head> <title>Sending HTML email using PHP</title> </head> <body> <?php $to = "xyz@example.com"; $subject = "This is subject of mail"; $message = "<b>This is HTML message.</b>"; $message .= "<h1>This is headline.</h1>"; // Always set content-type when sending HTML email $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; $header = "From: PHPKIDA\r\n"; $mailto = mail ($to,$subject,$message,$header); if( $mailto == true ) { echo "Message sent successfully..."; } else { echo "Message could not be sent..."; } ?> </body> </html>
Just put @ symbol before your mail function.
@mail ($to,$subject,$message,$header); // That code will be send direct mail into inbox