addCond('time','>=',strtotime(date('Y-m-d H:i:s',strtotime($start_time)))); $criteria->addCond('time','<=',strtotime(date('Y-m-d H:i:s',strtotime($end_time)))); $cursor = JRecord::model()->findAll($criteria); $rows = CommonFn::getRowsFromCursor($cursor); $parsedRows = JRecord::model()->parse($rows); foreach ($cursor as $item) { $item->status = 2; $item->save(); } $type_name = '全部'; $res=Service::factory('JRecordService')->push($parsedRows,$type_name,['start' => $start_time, 'end' => $end_time],1); $mail = Yii::app()->mailer; try { $mail->SMTPDebug = 2; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.qq.com'; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = '1340652578@qq.com'; // SMTP username $mail->Password = 'iaycligvfccmjdcf'; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 587; // TCP port to connect to $mail->setFrom('1340652578@qq.com', 'Mailer'); $mail->AddAddress('1340652578@qq.com'); $mail->addAttachment(Yii::app()->basePath.'/export/'.$res); // Add attachments $mail->isHTML(true); // Set email format to HTML $mail->Subject = '提货记录'; $mail->Body = $res; $mail->AltBody = $res; $mail->send(); echo 'Message has been sent'; } catch (Exception $e) { echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo; } } }