how to use email php code example
Example 1: php mail
<?php
$to = $_POST['email'];
$subject = "Email Subject";
$message = 'Dear '.$_POST['name'].',<br>';
$message .= "We welcome you to be part of family<br><br>";
$message .= "Regards,<br>";
// 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";
// More headers
$headers .= 'From: <[email protected]>' . "\r\n";
$headers .= 'Cc: [email protected]' . "\r\n";
mail($to,$subject,$message,$headers);
?>
Example 2: php mail
$mailtext = '<html>
<head>
<title>HTML-E-Mail mit PHP erstellen</title>
</head>
<body>
...
</body>
</html>
';
$empfaenger = "[email protected]"; // Mailadresse
$absender = "[email protected]";
$betreff = "Mail-Test - HTML-E-Mail mit PHP erstellen";
$antwortan = "[email protected]";
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset=utf-8\r\n";
$header .= "From: $absender\r\n";
$header .= "Reply-To: $antwortan\r\n";
// $header .= "Cc: $cc\r\n"; // falls an CC gesendet werden soll
$header .= "X-Mailer: PHP ". phpversion();
mail( $empfaenger,
$betreff,
$mailtext,
$header);
echo "Mail wurde gesendet!";