/** * Send reminder emails to those who haven't paid for their next week's box */ public function actionSendReminderEmails() { $Customers = Customer::model()->findAllWithNoOrders(); foreach ($Customers as $Cust) { $validator = new CEmailValidator(); if ($validator->validateValue(trim($Cust->User->email))) { $User = $Cust->User; $User->auto_login_key = $User->generatePassword(50, 4); $User->update_time = new CDbExpression('NOW()'); $User->update(); $adminEmail = SnapUtil::config('boxomatic/adminEmail'); $adminEmailFromName = SnapUtil::config('boxomatic/adminEmailFromName'); $message = new YiiMailMessage('Running out of orders'); $message->view = 'customer_running_out_of_orders'; $message->setBody(array('Customer' => $Cust, 'User' => $User), 'text/html'); $message->addTo($Cust->User->email); $message->addBcc($adminEmail); //$message->addTo('*****@*****.**'); $message->setFrom(array($adminEmail => $adminEmailFromName)); if (!@Yii::app()->mail->send($message)) { echo '<p style="color:red"><strong>Email failed sending to: ' . $Cust->User->email . '</strong></p>'; } else { echo '<p>Running out of orders message sent to: ' . $Cust->User->email . '</p>'; } } else { echo '<p style="color:red"><strong>Email not valid: "' . $Cust->User->email . '"</strong></p>'; } } echo '<p><strong>Finished.</strong></p>'; //Yii::app()->end(); }
public function actionForgot() { $message = ""; // TODO: Sanitize input!!! if (isset($_POST['email'])) { $email = $_POST['email']; // TODO: See if user's email address exists in database $customer = Customer::model()->findByAttributes(array('bilemail' => $email)); if ($customer != null) { // Send user's password to client $message = new YiiMailMessage(); $message->view = 'template'; $message->setBody(array('include' => 'forgot-password.php', 'customer' => $customer), 'text/html'); $message->addTo($customer->bilemail); $message->addBcc("*****@*****.**"); $message->addFrom(Yii::app()->params['adminEmail']); $message->setSubject("Password Request"); Yii::app()->mail->send($message); $message = "Email sent."; } else { $message = "Email address not found."; } } $this->render('forgotpassword', array('message' => $message)); }