function email_notify($check,$check_result,$subscription) { global $status_array; $user = new User($subscription->getUserId()); echo 'email plugin!'; $email = new fEmail(); // This sets up fSMTP to connect to the gmail SMTP server // with a 5 second timeout. Gmail requires a secure connection. $smtp = new fSMTP('smtp.gmail.com', 465, TRUE, 5); $smtp->authenticate('*****@*****.**', 'example'); $email->addRecipient($user->getEmail(), $user->getUsername()); // Set who the email is from $email->setFromEmail('*****@*****.**','Tattle'); // Set the subject include UTF-8 curly quotes $email->setSubject('Tattle : Alert for ' . $check->prepareName()); // Set the body to include a string containing UTF-8 $state = $status_array[$check_result->getStatus()]; $email->setHTMLBody("<p>$state Alert for {$check->prepareName()} </p><p>The check returned {$check_result->prepareValue()}</p><p>Warning Threshold is : ". $check->getWarn() . "</p><p>Error Threshold is : ". $check->getError() . '</p><p>View Alert Details : <a href="' . $fURL::getDomain() . '/' . CheckResult::makeURL('list',$check_result) . '">'.$check->prepareName()."</a></p>"); $email->setBody(" $state Alert for {$check->prepareName()} The check returned {$check_result->prepareValue()} Warning Threshold is : ". $check->getWarn() . " Error Threshold is : ". $check->getError() . " "); try { $message_id = $email->send($smtp); } catch ( fConnectivityException $e) { fCore::debug("email send failed",FALSE); } }
function email_plugin_notify($check,$check_result,$subscription,$alt_email=false) { global $status_array; $user = new User($subscription->getUserId()); $email = new fEmail(); // This sets up fSMTP to connect to the gmail SMTP server // with a 5 second timeout. Gmail requires a secure connection. $smtp = new fSMTP(sys_var('smtp_server'), sys_var('smtp_port'), TRUE, 5); $smtp->authenticate(sys_var('smtp_user'), sys_var('smtp_pass')); if ($alt_email) { $email_address = usr_var('alt_email',$user->getUserId()); } else { $email_address = $user->getEmail(); } $email->addRecipient($email_address, $user->getUsername()); // Set who the email is from $email->setFromEmail(sys_var('email_from'), sys_var('email_from_display')); // Set the subject include UTF-8 curly quotes $email->setSubject(str_replace('{check_name}', $check->prepareName(), sys_var('email_subject'))); // Set the body to include a string containing UTF-8 $state = $status_array[$check_result->getStatus()]; $email->setHTMLBody("<p>$state Alert for {$check->prepareName()} </p><p>The check returned {$check_result->prepareValue()}</p><p>Warning Threshold is : ". $check->getWarn() . "</p><p>Error Threshold is : ". $check->getError() . '</p><p>View Alert Details : <a href="' . fURL::getDomain() . '/' . CheckResult::makeURL('list',$check_result) . '">'.$check->prepareName()."</a></p>"); $email->setBody(" $state Alert for {$check->prepareName()} The check returned {$check_result->prepareValue()} Warning Threshold is : ". $check->getWarn() . " Error Threshold is : ". $check->getError() . " "); try { $message_id = $email->send($smtp); } catch ( fConnectivityException $e) { fCore::debug("email send failed",FALSE); } }
public function testSendHtmlAndAttachment() { $token = $this->generateSubjectToken(); $email = new fEmail(); $email->setFromEmail('*****@*****.**'); $email->addRecipient(EMAIL_ADDRESS, 'Test User'); $email->setSubject($token . ': Testing Attachment/HTML'); $email->setBody('This is a test of sending an attachment with an HTML body'); $email->setHTMLBody('<h1>Attachment/HTML Body Test</h1> <p> This is a test of sending both an HTML alternative, while also sending an attachment. </p>'); $bar_gif_contents = file_get_contents('./resources/images/bar.gif'); $email->addAttachment('bar.gif', 'image/gif', $bar_gif_contents); $message_id = $email->send(); $message = $this->findMessage($token); $this->assertEquals($message_id, $message['headers']['Message-ID']); $this->assertEquals('*****@*****.**', $message['headers']['From']); $this->assertEquals($token . ': Testing Attachment/HTML', $message['headers']['Subject']); $this->assertEquals('This is a test of sending an attachment with an HTML body', $message['plain']); $this->assertEquals('<h1>Attachment/HTML Body Test</h1> <p> This is a test of sending both an HTML alternative, while also sending an attachment. </p>', $message['html']); $this->assertEquals(array(array('filename' => 'bar.gif', 'mimetype' => 'image/gif', 'contents' => $bar_gif_contents)), $message['attachments'], 'The attachment did not match the original file contents'); }
die("sendmail_error"); }*/ //$to=$_POST["email_to"]; $to = "*****@*****.**"; $to_name = "Ivan"; $subject = "Recomendación"; try { /* Envia email -------------------------------------------------------------- */ $message_html = $_POST["html"]; $message_plaintext = " "; $email = new fEmail(); $email->addRecipient($to, $_SESSION["name"]); // Destinatario $email->setFromEmail($_SESSION["username"], $_SESSION["name"]); // Remitente $email->setBounceToEmail($to); // En caso de que rebote llegara a la direccion ingresada. $email->setSubject($subject); // Asunto $email->setBody($message_plaintext); // Cuerpo del mensaje (texto plano) $email->setHTMLBody($message_html); // Cuerpo del mensaje (texto html) $email->send(); } catch (fValidationException $e) { $message = $e->getMessage(); die($message); } ?>
function notify_multiple_users($user_from, $recipients, $subject, $body) { $email = new fEmail(); // This sets up fSMTP to connect to the gmail SMTP server // with a 5 second timeout. Gmail requires a secure connection. $smtp = new fSMTP(sys_var('smtp_server'), sys_var('smtp_port'), sys_var('require_ssl') === 'true' ? TRUE : FALSE, 5); if (sys_var('require_auth') === 'true') { $smtp->authenticate(sys_var('smtp_user'), sys_var('smtp_pass')); } // Add the recipients foreach ($recipients as $rec) { $email->addRecipient($rec['mail'], $rec['name']); } // Set who the email is from $email->setFromEmail($user_from->getEmail(), $user_from->getUsername()); // Set the subject $email->setSubject($subject); // Set the body $email->setHTMLBody($body); $email->setBody($body); try { $message_id = $email->send($smtp); } catch (fConnectivityException $e) { fCore::debug($e, FALSE); fCore::debug("email send failed", FALSE); $e->printMessage(); $e->printTrace(); } }