| [AsK] Php Mailer on Mac OS X
permisi kakak2 master,, ane mau numpang nanya tentang php mailer atau mengirim email menggunakan account GMAIL. yang pertama kali ane lakukan membuat function/class mail, berikut source nya var $mail; public function __construct() { require_once('PHPMailer/class.phpmailer.php'); // the true param means it will throw exceptions on errors, which we need to catch $this->mail = new PHPMailer(true); $this->mail->IsSMTP(); // telling the class to use SMTP $this->mail->CharSet = "utf-8"; // CharSet $this->mail->SMTPDebug = 0; // enables SMTP debug information $this->mail->SMTPAuth = true; // enable SMTP authentication $this->mail->SMTPSecure = "tls"; // sets the prefix to the servier $this->mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $this->mail->Port = 587; // set the SMTP port for the GMAIL server $this->mail->Username = "adadeh@gmail.com";// GMAIL username $this->mail->Password = "kepokepo"; // GMAIL password $this->mail->AddReplyTo('adadeh@gmail.com', 'Romdoni Agung Purbayanto'); $this->mail->SetFrom('adadeh@gmail.com', 'donny'); } public function sendmail($to, $to_name, $subject, $body){ try{ $this->mail->AddAddress($to, $to_name); $this->mail->Subject = $subject; $this->mail->Body = $body; $this->mail->Send(); echo "<script>consloe.log('Message Sent OK'); </script>"; } catch (phpmailerException $e) { echo "<script>consloe.log(".$e->errorMessage()."); </script>"; //Pretty error messages from PHPMailer } catch (Exception $e) { echo "<script>consloe.log(".$e->getMessage()."); </script>"; //Boring error messages from anything else! } }
setelah itu ane pergi ke controller dan memakai class mail yang tadi ane buat, berikut potongan script nya,, $this->mailer->sendmail( $to, 'doni', $subjek, $mail_body );
trus ane jalanin dan tentu saja gagal (nggk asik kalo langsung sukses :p :p :p ) trus ane pergi/edit php.ini dan menghapus komentar extension=php_openssl.dll lalu ane restart server(apache) dan ane jalankan (gagal lagi)
ada yang bisa bantu tidak kakak2 master sekalian thanks sebelumnya
best regards |
Tidak ada komentar:
Posting Komentar