Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function actionCreate()
- {
- $model=new EmpLeave;
- $model->dateof_leave = date("Y-m-d H:i");
- if(isset($_POST['EmpLeave']))
- {
- $model->attributes=$_POST['EmpLeave'];
- if($model->save())
- $recipients = "sridhar.venkatesan53@gmail.com";
- $headers["From"] = "noreply@elixir.in";
- $headers["To"] = "sridhar.venkatesan53@gmail.com";
- $headers["Subject"] = "User feedback";
- $mailmsg = (array('id'=>$model->leave_id));
- /* SMTP server name, port, user/passwd */
- $smtpinfo["host"] = "smtp.mandrillapp.com";
- $smtpinfo["port"] = "587";
- $smtpinfo["auth"] = true;
- $smtpinfo["username"] = "noreply@elixir.in";
- $smtpinfo["password"] = "oNkeBOEA5MfaN_24loUs1w";
- /* Create the mail object using the Mail::factory method */
- $mail_object =& Mail::factory("smtp", $smtpinfo);
- /* Ok send mail */
- $mail_object->send($recipients, $headers, $mailmsg);
- $this->redirect(array('view','id'=>$model->leave_id));
- }
- $this->render('create',array(
- 'model'=>$model,
- ));
- }
- <?php $this->widget('zii.widgets.CDetailView', array(
- 'data'=>$model,
- 'attributes'=>array(
- 'leave_id',
- 'leave_type',
- 'leave_reason',
- 'numof_days',
- 'type',
- 'dateof_leave',
- ),
- )); ?>
- if($model->save()){
- .....
- }
- $mailmsg=(array('id'=>$model->leave_id)) /*just try this for your own testing after you get idea about this*/
- echo "<pre>";
- print_r($mailmsg);
- exit();
- $mailmsg="<div><ul>";
- foreach($_POST as $key=>$value)
- {
- $mailmsg.="<li>".$key." - ".$value."</li>"; // String Generated
- }
- $mailmsg.="</ul></div>";
- public function actionCreate()
- {
- $model=new EmpLeave;
- $model->dateof_leave = date("Y-m-d H:i");
- if(isset($_POST['EmpLeave']))
- {
- $model->attributes=$_POST['EmpLeave'];
- if($model->save())
- {
- require_once(Yii::app()->basePath.'/extensions/PearMail/Mail-1.2.0/Mail.php');
- $recipients = "sridhar.venkatesan53@gmail.com";
- $headers["From"] = "noreply@elixir.in";
- $headers["To"] = "sridhar.venkatesan53@gmail.com";
- $headers["Subject"] = "User feedback";
- $mailmsg="<div><ul>";
- foreach($_POST as $key=>$value)
- {
- $mailmsg.="<li>".$key." - ".$value."</li>";
- }
- $mailmsg.="</ul></div>";
- /* SMTP server name, port, user/passwd */
- $smtpinfo["host"] = "smtp.mandrillapp.com";
- $smtpinfo["port"] = "587";
- $smtpinfo["auth"] = true;
- $smtpinfo["username"] = "noreply@elixir.in";
- $smtpinfo["password"] = "oNkeBOEA5MfaN_24loUs1w";
- /* Create the mail object using the Mail::factory method */
- $mail_object =& Mail::factory("smtp", $smtpinfo);
- /* Ok send mail */
- $mail_object->send($recipients, $headers, $mailmsg);
- $this->redirect(array('view','id'=>$model->leave_id));
- }
- $this->render('create',array(
- 'model'=>$model,
- ));
- }
- Yii::import('application.extensions.phpmailer.JPhpMailer');
- $mail = new JPhpMailer;
- $mail->IsSMTP();
- $mail->Host = 'smpt.163.com'; // your host and smtp address
- $mail->SMTPAuth = true;
- $mail->Username = 'yourname@163.com'; //login username
- $mail->Password = 'yourpassword'; //login password
- $mail->SetFrom('yourname@163.com', 'yourname'); //from
- $mail->Subject = 'PHPMailer Test Subject via smtp, basic with authentication';
- $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
- $mail->MsgHTML('<h1>JUST A TEST!</h1>');
- $mail->AddAddress('john.doe@otherdomain.com', 'John Doe');
- $status=$mail->Send();
- print_r($status);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement