public function testAddMail() { // Some cheating $_SERVER["SERVER_NAME"] = '127.0.0.1'; $emailSubject = 'Test'; $emailText = 'Text of the mail'; $recipient = 'test@localhost'; // Add email to mail queue $added = MailQueue::addMail($recipient, $emailSubject, $emailText); // Ensure added $this->assertTrue($added); }
/** * This method sends an email to bug owner and reporter. * The email contains bug change information. * @return boolean true on success. */ public function sendBugChangeNotificationEmail($bugChange) { $emailSubject = "[CrashFix] Bug #" . $bugChange->bug->id . " Has Been Changed"; $emailText = "Bug #" . $bugChange->bug_id . " " . $bugChange->bug->summary . "\r\n"; $emailText .= "URL: " . Yii::app()->createAbsoluteUrl('bug/view', array('id' => $bugChange->bug_id)); $emailText .= "\r\n"; $emailText .= "Changed by " . $bugChange->user->username . " on " . date('j F Y, G:i', $bugChange->timestamp) . "\r\n"; $emailText .= "\r\n"; if ($bugChange->comment != null) { $emailText .= "Comment has been entered:\r\n"; $emailText .= wordwrap($bugChange->comment->text, 70) . "\r\n"; $emailText .= "\r\n"; } if ($bugChange->statuschange != null) { if (isset($bugChange->statuschange->status)) { $emailText .= "Status:" . Lookup::item('BugStatus', $bugChange->statuschange->status) . "\r\n"; if ($bugChange->statuschange->status == Bug::STATUS_DUPLICATE) { $emailText .= "Merged into bug: #" . $bugChange->statuschange->merged_into . "\r\n"; } } if (isset($bugChange->statuschange->priority)) { $emailText .= "Priority: " . Lookup::item('BugPriority', $bugChange->statuschange->priority) . "\r\n"; } if (isset($bugChange->statuschange->reproducability)) { $emailText .= "Reproducibiliity: " . Lookup::item('BugReproducability', $bugChange->statuschange->reproducability) . "\r\n"; } if (isset($bugChange->statuschange->owner)) { $emailText .= "Owner: " . $bugChange->statuschange->owner->username . "\r\n"; } $emailText .= "\r\n"; } foreach ($bugChange->attachments as $attachment) { $emailText .= "File attached: " . $attachment->filename; $emailText .= "\r\n"; } $emailText .= "\r\n"; // Send an email to bug reporter $add1 = MailQueue::addMail($bugChange->bug->reporter->email, $emailSubject, $emailText); $add2 = false; // Send an email to bug owner if ($bugChange->bug->owner != null && $bugChange->bug->owner->id != $bugChange->bug->reporter->id) { $add2 = MailQueue::addMail($bugChange->bug->owner->email, $emailSubject, $emailText); } return $add1 && $add2; }
/** * This method adds an email to pending mail queue. The email contains * new user account activation link. * @return boolean True on success. */ public function sendEmailWithAccountActivationLink() { // Send an E-mail with account activation link $emailFrom = "no-reply@" . Yii::app()->request->serverName; $emailSubject = "[CrashFix] Account Activation"; $emailText = "This message has been sent to you, because someone has created\r\n"; $emailText .= "a CrashFix account for you.\r\n\r\n"; $emailText .= "IMPORTANT: If you did not request to create a CrashFix account for you,\r\n"; $emailText .= "tell your administrator about this letter.\r\n\r"; $emailText .= "If you did request to create an account for you, then please follow\r\n"; $emailText .= "this link to login into your CrashFix account and enter your new password:\r\n"; $emailText .= Yii::app()->createAbsoluteUrl('site/login', array('prt' => $this->pwd_reset_token)); $emailText .= "\r\n"; $headers = "From: {$emailFrom}\r\nReply-To: {$emailFrom}"; // Add an email to mail queue. return MailQueue::addMail($this->email, $emailSubject, $emailText); }