Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.22 KB | None | 0 0
  1. public function actionCreate()
  2. {
  3. $model=new EmpLeave;
  4. $model->dateof_leave = date("Y-m-d H:i");
  5. if(isset($_POST['EmpLeave']))
  6. {
  7. $model->attributes=$_POST['EmpLeave'];
  8. if($model->save())
  9. $recipients = "sridhar.venkatesan53@gmail.com";
  10. $headers["From"] = "noreply@elixir.in";
  11. $headers["To"] = "sridhar.venkatesan53@gmail.com";
  12. $headers["Subject"] = "User feedback";
  13. $mailmsg = (array('id'=>$model->leave_id));
  14. /* SMTP server name, port, user/passwd */
  15. $smtpinfo["host"] = "smtp.mandrillapp.com";
  16. $smtpinfo["port"] = "587";
  17. $smtpinfo["auth"] = true;
  18. $smtpinfo["username"] = "noreply@elixir.in";
  19. $smtpinfo["password"] = "oNkeBOEA5MfaN_24loUs1w";
  20. /* Create the mail object using the Mail::factory method */
  21. $mail_object =& Mail::factory("smtp", $smtpinfo);
  22. /* Ok send mail */
  23. $mail_object->send($recipients, $headers, $mailmsg);
  24. $this->redirect(array('view','id'=>$model->leave_id));
  25. }
  26. $this->render('create',array(
  27. 'model'=>$model,
  28. ));
  29. }
  30.  
  31. <?php $this->widget('zii.widgets.CDetailView', array(
  32. 'data'=>$model,
  33. 'attributes'=>array(
  34. 'leave_id',
  35. 'leave_type',
  36. 'leave_reason',
  37. 'numof_days',
  38. 'type',
  39. 'dateof_leave',
  40. ),
  41. )); ?>
  42.  
  43. if($model->save()){
  44. .....
  45. }
  46.  
  47. $mailmsg=(array('id'=>$model->leave_id)) /*just try this for your own testing after you get idea about this*/
  48. echo "<pre>";
  49. print_r($mailmsg);
  50. exit();
  51.  
  52. $mailmsg="<div><ul>";
  53. foreach($_POST as $key=>$value)
  54. {
  55. $mailmsg.="<li>".$key." - ".$value."</li>"; // String Generated
  56. }
  57. $mailmsg.="</ul></div>";
  58.  
  59. public function actionCreate()
  60. {
  61. $model=new EmpLeave;
  62. $model->dateof_leave = date("Y-m-d H:i");
  63. if(isset($_POST['EmpLeave']))
  64. {
  65. $model->attributes=$_POST['EmpLeave'];
  66. if($model->save())
  67. {
  68. require_once(Yii::app()->basePath.'/extensions/PearMail/Mail-1.2.0/Mail.php');
  69.  
  70.  
  71. $recipients = "sridhar.venkatesan53@gmail.com";
  72. $headers["From"] = "noreply@elixir.in";
  73. $headers["To"] = "sridhar.venkatesan53@gmail.com";
  74. $headers["Subject"] = "User feedback";
  75. $mailmsg="<div><ul>";
  76. foreach($_POST as $key=>$value)
  77. {
  78. $mailmsg.="<li>".$key." - ".$value."</li>";
  79. }
  80. $mailmsg.="</ul></div>";
  81. /* SMTP server name, port, user/passwd */
  82. $smtpinfo["host"] = "smtp.mandrillapp.com";
  83. $smtpinfo["port"] = "587";
  84. $smtpinfo["auth"] = true;
  85. $smtpinfo["username"] = "noreply@elixir.in";
  86. $smtpinfo["password"] = "oNkeBOEA5MfaN_24loUs1w";
  87. /* Create the mail object using the Mail::factory method */
  88. $mail_object =& Mail::factory("smtp", $smtpinfo);
  89. /* Ok send mail */
  90. $mail_object->send($recipients, $headers, $mailmsg);
  91. $this->redirect(array('view','id'=>$model->leave_id));
  92. }
  93. $this->render('create',array(
  94. 'model'=>$model,
  95. ));
  96. }
  97.  
  98. Yii::import('application.extensions.phpmailer.JPhpMailer');
  99. $mail = new JPhpMailer;
  100. $mail->IsSMTP();
  101. $mail->Host = 'smpt.163.com'; // your host and smtp address
  102. $mail->SMTPAuth = true;
  103. $mail->Username = 'yourname@163.com'; //login username
  104. $mail->Password = 'yourpassword'; //login password
  105. $mail->SetFrom('yourname@163.com', 'yourname'); //from
  106. $mail->Subject = 'PHPMailer Test Subject via smtp, basic with authentication';
  107. $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
  108. $mail->MsgHTML('<h1>JUST A TEST!</h1>');
  109. $mail->AddAddress('john.doe@otherdomain.com', 'John Doe');
  110. $status=$mail->Send();
  111. print_r($status);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement