Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once "Mail.php";
- $subject = "Judul/subject email";
- $body = "isi pesan email...";
- $host = "ssl://smtp.gmail.com";
- $port = "465";
- $username = "username_pengirim";
- $password = "password_email";
- $headers = array('From' => $from, 'To' => $to, 'Subject' => $subject);
- $namafile = "/nama_path/inidia.pdf";
- $mime = new Mail_mime();
- if ($mime->addAttachment($namafile,'application/pdf')){
- echo "Sukses ngattach pail! </br>";
- } else {
- echo "Duh, gagal coy!</br>";
- }
- $smtp = Mail::factory('smtp', array('host' => $host, 'port' => $port,
- 'auth' => true, 'username' => $username, 'password' => $password));
- $mail = $smtp -> send($to, $headers, $body);
- if (PEAR::isError($mail)) {
- echo("<p> Email Gagal dikirim" . $mail -> getMessage() . "</p>");
- }else{
- echo "Email berhasil di kirim ";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment