PHP yang merupakan bahasa pemrograman favorit saya saat ini, selain dapat menangani urusan pembuatan file PDF , baca tulis file CSV maup...
Nama File: Mailer.class.php
<?php
/*
Class name : Mailer
Description : Class for handling sending an email
Author : Achmad Solichin (http://achmatim.net)
*/
class Mailer {
// declare private attributes
private $from;
private $subject;
private $message;
public $error;
// Class constructor
public function __construct($from, $to, $subject, $message) {
$this->from = $from;
$this->to = $to;
$this->subject = $subject;
$this->message = $message;
}
// accessor functions
public function __set($name, $value) {
$this->$name = $value;
}
public function __get($name) {
return $this->$name;
}
public function send_mail() {
}
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '. $this->from . "\r\n";
}
$headers .= 'Cc: ';
$headers .= "\r\n";
}
$headers .= 'Bcc: ';
$headers .= "\r\n";
}
return true;
} else {
$this->error = 'Server cannot sending mail.';
return false;
}
}
}
?>
Nama File: send_mail.php
<html>
<head><title>Aplikasi Kirim Email dengan PHP</title></head>
<body>
<h1>Demo Aplikasi Kirim Email dengan PHP</h1>
<form action="" method="post">
<table width="100%">
<tr>
<td width="150">Pengirim: </td>
<td><input type="text" name="pengirim" size="40"/></td>
</tr>
<tr>
<td>Penerima: </td>
<td><input type="text" name="penerima" size="40"/></td>
</tr>
<tr>
<td>Judul: </td>
<td><input type="text" name="judul" size="40"/></td>
</tr>
<tr>
<td>Pesan: </td>
<td> </td>
</tr>
<tr>
<td colspan="2"><textarea cols="58" rows="10" name="pesan"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Send" value="Send"/><input type="reset" name="reset" value="Cancel"/></td>
</tr>
</table>
</form>
<?php
include "Mailer.class.php";
$pengirim = $_POST['pengirim'];
$penerima = $_POST['penerima'];
$judul = $_POST['judul'];
$pesan = $_POST['pesan'];
if ($pengirim=='') {
}
$mailer = new Mailer($pengirim,$penerima, $judul, $pesan);
$mailer->send_mail();
}
?>
</body>
</html>
Semoga contoh program singkat ini berguna. Maju terus ilmu pengetahuan Indonesia!
Sumber - Achmatim.Net
Sumber - Achmatim.Net
nambah wawasan , mkasih bro
BalasHapusMy blog