1. Halo Guest, pastikan Anda selalu menaati peraturan forum sebelum mengirimkan post atau thread baru.

[help] PHPMailer gag works

Discussion in 'Pemrograman Web' started by anonym, Jan 4, 2013.

  1. anonym

    anonym Banned

    Joined:
    Jan 18, 2012
    Messages:
    714
    Likes Received:
    213
    Location:
    the edge of the earth
    saya lagi coba² PHPMailer dgn versi 5.2.2 hxxps://code.google.com/a/apache-extras.org/p/phpmailer/downloads/list
    pertama saya coba di localhost, gag work juga, padahal dr tutorialnya udah bener smua settingannya.. kmudian saya load ke hosting di Hostgator.. coba eksekusi dan tetep ajah gag jalan..

    adakah mastah² yg expert PHP bisa membantu saya..

    terimakasih sebelumnya
     
  2. masadi

    masadi Super Hero

    Joined:
    Dec 12, 2010
    Messages:
    2,334
    Likes Received:
    144
    Location:
    mas-adi.com
  3. anonym

    anonym Banned

    Joined:
    Jan 18, 2012
    Messages:
    714
    Likes Received:
    213
    Location:
    the edge of the earth
    hwa threadnya si agan juga.. beugh, amanin di coba dulu mastagh..
    btw bisa send HTML templates yah kalo dibikin plugin gituh, secara tuhkan form posting di WP jadi form buat send email yah?

    oya, di PHPMailer kan support, BC dan BCC yah.. sedangkan yg plugin agan utk kirim mass masukin emailnya sperti isi tags form.. nah mangsud saya kalo ada BCCnya kan bisa ngurangi scan sbg spam email mas gan, lagian kalo gag di BCC kasihan pemilik emailnya jd banyak yg tau.. soalnya mo dipake buwat company sih.. thanxs
     
    Last edited: Jan 4, 2013
  4. masadi

    masadi Super Hero

    Joined:
    Dec 12, 2010
    Messages:
    2,334
    Likes Received:
    144
    Location:
    mas-adi.com
    Bisa banget om... tapi fitur tersebut belum ada di plugin itu...
    Contoh kode kalo pake CC

    PHP:
    // Example using the array form of $headers
    // assumes $to, $subject, $message have already been defined earlier...

    $headers[] = 'From: Me Myself <[email protected]>';
    $headers[] = 'Cc: John Q Codex <[email protected]>';
    $headers[] = 'Cc: [email protected]'// note you can just use a simple email address

    wp_mail$to$subject$message$headers );
    Sampean bisa oprek2 lagi...

    Panduannya bisa dibaca dimari:
    _http://codex.wordpress.org/Function_Reference/wp_mail
     
  5. anonym

    anonym Banned

    Joined:
    Jan 18, 2012
    Messages:
    714
    Likes Received:
    213
    Location:
    the edge of the earth
    okey, matur thankyou mas dab.. uprek² dulu dah..
     
  6. mp3online

    mp3online Super Hero

    Joined:
    Jul 19, 2011
    Messages:
    2,228
    Likes Received:
    294
    Location:
    jakarta
    php mail kalau di localhost emang agak susah boss, harus nyeting smtp nya dulu
     
  7. clumbiecom

    clumbiecom Newbie

    Joined:
    Feb 12, 2011
    Messages:
    24
    Likes Received:
    2
    Location:
    www.CLUMBiE.com
    kalau dilocalhost harus setting smtp dan port 25
    kalo dihosting biasanya langsung jalan
    tergantung hostingnya



    coba pakai code
    Nama File: Mailer.class.php


    1. <?php
    2. /*
    3. Class name : Mailer
    4. Description : Class for handling sending an email


    5. */

    6. class Mailer {
    7. // declare private attributes
    8. private $from;
    9. private $subject;
    10. private $to = array();
    11. private $cc = array();
    12. private $bcc = array();
    13. private $message;
    14. public $error;
    15. // Class constructor
    16. public function __construct($from, $to, $subject, $message) {
    17. $this->from = $from;
    18. $this->to = $to;
    19. $this->subject = $subject;
    20. $this->message = $message;
    21. }
    22. // accessor functions
    23. public function __set($name, $value) {
    24. $this->$name = $value;
    25. }
    26. public function __get($name) {
    27. return $this->$name;
    28. }

    29. public function send_mail() {
    30. if (!empty($this->to) && count($this->to) > 0) {
    31. $destination = implode (',' ,$this->to);
    32. }
    33. $headers = 'MIME-Version: 1.0' . "\r\n";
    34. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    35. if (!empty($this->to)) {
    36. $headers .= 'From: ' . $this->from . "\r\n";
    37. }
    38. if (!empty($this->cc) && count($this->cc) > 0) {
    39. $headers .= 'Cc: ' ;
    40. $headers .= implode (',' ,$this->cc);
    41. $headers .= "\r\n";
    42. }
    43. if (!empty($this->bcc) && count($this->bcc) > 0) {
    44. $headers .= 'Bcc: ' ;
    45. $headers .= implode (',' ,$this->bcc);
    46. $headers .= "\r\n";
    47. }

    48. if(mail($destination, $this->subject, $this->message, $headers)) {
    49. return true;
    50. } else {
    51. $this->error = 'Server cannot sending mail.' ;
    52. return false;
    53. }
    54. }
    55. }
    56. ?>
    Nama File: send_mail.php


    1. <html>
    2. <head><title>Aplikasi Kirim Email dengan PHP</title></head>
    3. <body>
    4. <h1>Demo Aplikasi Kirim Email dengan PHP</h1>
    5. <form action="" method="post">
    6. <table width="100%">
    7. <tr>
    8. <td width="150">Pengirim: </td>
    9. <td><input type="text" name="pengirim" size="40"/></td>
    10. </tr>
    11. <tr>
    12. <td>Penerima: </td>
    13. <td><input type="text" name="penerima" size="40"/></td>
    14. </tr>
    15. <tr>
    16. <td>Judul: </td>
    17. <td><input type="text" name="judul" size="40"/></td>
    18. </tr>
    19. <tr>
    20. <td>Pesan: </td>
    21. <td>&nbsp;</td>
    22. </tr>
    23. <tr>
    24. <td colspan="2"><textarea cols="58" rows="10" name="pesan"></textarea></td>
    25. </tr>
    26. <tr>
    27. <td>&nbsp;</td>
    28. <td><input type="submit" name="Send" value="Send"/><input type="reset" name="reset" value="Cancel"/></td>
    29. </tr>
    30. </table>
    31. </form>

    32. <?php
    33. include "Mailer.class.php";
    34. if (isset($_POST['Send' ])) {
    35. $pengirim = $_POST['pengirim' ];
    36. $penerima = $_POST['penerima' ];
    37. $judul = $_POST['judul' ];
    38. $pesan = $_POST['pesan' ];

    39. if ($pengirim=='' ) {
    40. die("Pengirim harus diisi");
    41. }

    42. $mailer = new Mailer($pengirim,$penerima, $judul, $pesan);
    43. $mailer->send_mail();
    44. }
    45. ?>
    46. </body>
    47. </html>
     

Share This Page