https://masterkey.masterweb.com/aff.php?aff=8803

Cara Kirim Email dengan PHP


Cara paling mudah  untuk  mengirim  email dengan  PHP adalah untuk mengirim email teks.

Pada contoh di bawah ini pertama-tama kita mendeklarasikan variabel ($ kepada, $ subjek, $ pesan, $ dari, $ header), maka kita gunakan variabel dalam fungsi mail () untuk mengirim e-mail:

<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "contoh@contoh.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
Dengan PHP, Anda dapat membuat sebuah Komentar-formulir di website Anda. Contoh di bawah ini mengirimkan pesan teks ke alamat e-mail tertentu:
<html>
<body>

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  {
  //send email
  $email = $_REQUEST['email'] ;
  $subject = $_REQUEST['subject'] ;
  $message = $_REQUEST['message'] ;
  mail("someone@example.com", "$subject",
  $message, "From:" . $email);
  echo "Thank you for using our mail form";
  }
else
//if "email" is not filled out, display the form
  {
  echo "<form method='post' action='mailform.php'>
  Email: <input name='email' type='text' /><br />
  Subject: <input name='subject' type='text' /><br />
  Message:<br />
  <textarea name='message' rows='15' cols='40'>
  </textarea><br />
  <input type='submit' />
  </form>";
  }
?>

</body>
</html>

0 Response to "Cara Kirim Email dengan PHP"

Post a Comment