Yii Framework Forum: can't send email using YiiMailer - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

can't send email using YiiMailer can't send email using YiiMailer

#1 User is offline   stefanushendys 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 28-July 16

Posted 28 July 2016 - 02:14 AM

i can't sending email using YiiMailer. nothing error but the email not send. please help me.

config/main.php
'mail' => array(
'class' => 'ext.yii-mail.YiiMail',
'transportType'=>'smtp',
'transportOptions'=>array(
'host'=>'smtp.gmail.com',
'username'=>'xxxxxxxxxxxxxxxxx',
'password'=>'xxxxxxxxxxxxxxxxx',
'port'=>'25',
),
'viewPath' => 'application.views.mail',
),

controler
<?php

Class EmailController extends Controller {
Yii::import('ext.yii-mail.YiiMailMessage');
public function actionKirim() {
$this -> layout = 'null';
if (isset($_POST['Data'])) {
//amdil data dari form
$data = $_POST['Data'];
//set email to
$emailTo = $data['email'];
//set subject
$subject = 'Anda Mendapatkan Disposisi Surat';
//set message
$message = 'Anda mendapatkan disposisi surat. Silahkan cek E-OFFICE Anda';
//panggil php mailer
$mail = Yii::app() -> Smtpmail;
//add replay to (penerima membalas akan ditujukan ke email ini)
$mail -> AddReplyTo('stefanhendysulis@gmail.com', '');
//add bcc
$mail -> AddBcc('stefanhendysulis@gmail.com');
//menyatakan email dikirim dari siapa
$mail -> SetFrom('stefanhendysulis@gmail.com', 'Notifikasi E-OFFICE');
//set subject
$mail -> Subject = $subject;
//set message untuk dikirim
$mail -> MsgHTML($message);
//set email address to dikirim
$mail -> AddAddress($emailTo, "");
//jika email tidak dikirim maka tampilkan error
if (!$mail -> Send()) {
echo "Mailer Error: " . $mail -> ErrorInfo;
} else {
//else tampilkan sukses
echo "Message sent!";
}
}
//render form untuk kirim email
$this -> render('index2');
}

}
//located at protected\controllers
?>

view
<tr>
<td class="a">Email Penerima</td>
<td class="a1">:</td>
<td class="b"><input size ="64" name = "data[email]"/></td>
</tr>

<tr><td>
<div class="button"><a class="button" onclick="fp(\'content\',\'f3\',\''.Yii::app()->createUrl('smdata/index2').'\',\'tmb4=Simpan\');">Simpan</a></div>
</td></tr>
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users