function backupMysql() { $createBackup = "mysqldump -u " . DB_USER . " --password="******" " . BACKUP_DBS . " > " . CURRENT_MYSQL_BACKUP_PATH . CURRENT_MYSQL_BACKUP_NAME; $createZip = "tar cvzf " . EXTENDED_MYSQL_BACKUP_NAME . ' ' . CURRENT_MYSQL_BACKUP_NAME; exec($createBackup); exec($createZip); $headers = array('From' => EMAIL_FROM . '<' . EMAIL_SEND . '>', 'Subject' => EMAIL_SUBJECT); $textMessage = EXTENDED_MYSQL_BACKUP_NAME; $htmlMessage = "This is a nightly backup run."; $mime = new Mail_Mime("\n"); $mime->setTxtBody($textMessage); $mime->setHtmlBody($htmlMessage); $mime->addAttachment(EXTENDED_MYSQL_BACKUP_NAME, 'text/plain'); $body = $mime->get(); $hdrs = $mime->headers($headers); $mail =& Mail::factory('mail'); $mail->send(EMAIL_REC, $hdrs, $body); unlink(CURRENT_MYSQL_BACKUP_NAME); unlink(EXTENDED_MYSQL_BACKUP_NAME); }
$message .= '<p>Hello ' . $to_name . ',</p>'; $message .= '<p>You have just received a new message from ' . $name . '! '; $message .= '<a href="' . BASE_URI . '/messages">Click here</a> to see it.</p>'; $message .= '<br/><p><small>You are receiving this email because you enabled Semantic Pingback notification '; $message .= '(with email as notification mechanism) for your Personal Profile on <a href="' . BASE_URI . '">' . BASE_URI . '</a>. '; $message .= 'If you would like to stop receiving email notifications, please check your '; $message .= ' <a href="' . BASE_URI . '/subscription.php">subscription settings</a>.</small></p>'; $message .= '<p><small>You do not need to respond to this automated email.</small></p>'; $message .= '</body></html>'; $crlf = "\n"; $mime = new Mail_Mime(array('eol' => $crlf)); $mime->setHTMLBody($message); $mimeparams = array(); $mimeparams['html_charset'] = "UTF-8"; $mimeparams['head_charset'] = "UTF-8"; $headers = $mime->headers($headers); $body = $mime->get($mimeparams); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { $ret .= error('Sendmail: ' . $mail->getMessage()); } } // Everything is OK, return a proper HTTP response success code $ret .= header("HTTP/1.1 201 Created"); $ret .= header("Status: 201 Created"); $ret .= "<html><body>\n"; $ret .= "Your message has been successfully delivered!\n"; $ret .= "</body></html>\n"; } } }
$anh = false; if ($anz > 0) { for ($o = 0; $o < $anz; $o++) { if ($_FILES["Datei"]["name"][$o] != "") { //move_uploaded_file($_FILES["Datei"]["tmp_name"][$o],$tmpdir.$_FILES["Datei"]["name"][$o]); copy($_FILES["Datei"]["tmp_name"][$o], 'tmp/' . $_FILES["Datei"]["name"][$o]); $mime->addAttachment('tmp/' . $_FILES["Datei"]["name"][$o], $_FILES["Datei"]["type"][$o], $_FILES["Datei"]["name"][$o]); unlink('tmp/' . $_FILES["Datei"]["name"][$o]); $anh = true; } } } else { $headers["Content-Type"] = "text/plain; charset=" . $_SESSION["charset"]; } $body = $mime->get(array("text_encoding" => "quoted-printable", "text_charset" => $_SESSION["charset"])); $hdr = $mime->headers($headers); $mail->_params = "-f " . $user["email"]; $rc = $mail->send($to, $hdr, $body); if ($_SESSION['logmail']) { $f = fopen('log/maillog.txt', 'a'); if ($rc) { fputs($f, date("Y-m-d H:i") . ';ok;' . $TO . ';' . $CC . ';' . $user["name"] . ' <' . $user["email"] . '>;' . $Subject . ";\n"); } else { fputs($f, date("Y-m-d H:i") . ';error;' . $_POST["TO"] . ';' . $_POST["CC"] . ';' . $user["name"] . ' <' . $user["email"] . '>;' . $_POST["Subject"] . ';' . PEAR_Error::getMessage() . "\n"); } } if ($rc) { if (!$anh) { $_FILES = false; } $data["CRMUSER"] = $_SESSION["loginCRM"];
/** * Send the email out. * @return err 0 if no error; otherwise a PEAR_Error object with the error. */ function send() { // sanity check required pieces if (empty($this->to_email)) { return PEAR::raiseError('to email cannot be empty.'); } if (empty($this->from_email)) { return PEAR::raiseError('from email cannot be empty.'); } // set up all headers $headers = array(); $recipients = $this->getRecipients(); $headers["To"] = join(", ", $recipients['To']); if (count($recipients['Cc'])) { $headers["Cc"] = join(", ", $recipients['Cc']); } if (count($recipients['Bcc'])) { $headers["Bcc"] = join(", ", $recipients['Bcc']); } // FROM if ($this->from_name != '') { $headers["From"] = "\"{$this->from_name}\" <{$this->from_email}>"; } else { $headers["From"] = "{$this->from_email}"; } // REPLY-TO if ($this->reply_to_email != '') { $headers["Reply-To"] = "{$this->reply_to_email}"; } // PRIORITY $headers["X-Priority"] = "{$this->priority}"; // SUBJECT $headers["Subject"] = $this->subject; // ENVELOPE ADDRESS - make things bounce to the right place $headers["Return-Path"] = $headers["Errors-To"] = "{$this->from_email}"; $headers["Errors-To"] = "{$this->from_email}"; // Add an x-mailer; reduces chance of being flagged as SPAM $headers["X-Mailer"] = "PHOCOA Web Framework Mailer"; // Right before we pull the body text/html, HTMLify the message if it // meets the criteria for HTMLification. This function does nothing // if htmlify_plain_text_only_messages is turned off. $this->htmlify(); // use PEAR::Mail_Mime to format message $mm = new Mail_Mime(); @$mm->setTXTBody($this->raw_message_text); if ($this->raw_message_html) { @$mm->setHTMLBody($this->raw_message_html); } // add attachments foreach ($this->attachments as $attachment_info) { $err = @$mm->addAttachment($attachment_info['file'], $attachment_info['type'], $attachment_info['name'], $attachment_info['isfile']); if (PEAR::isError($err)) { return $err; } } $mm_body = @$mm->get(); $mm_headers = @$mm->headers($headers); if (is_null($this->pear_mailer_config)) { $mailer =& Mail::factory($this->pear_mailer_driver); } else { $mailer =& Mail::factory($this->pear_mailer_driver, $this->pear_mailer_config); } if (PEAR::isError($mailer)) { return $mailer; } $err = @$mailer->send(array_keys($recipients['All']), $mm_headers, $mm_body); if (PEAR::isError($err)) { return $err; } return 0; }
*/ $subject = "Heartweb Subscription"; $mime = new Mail_Mime(); $text = "Hi<BR><BR>"; $text .= "Your subscription to the Heartweb application is due for renewal in 7days. TIf you would liek to carry on with your subscription then you will need renew through the application.<BR>"; $text .= "====== IMPORTANT INFORMATION =========<BR>"; $text .= "Please Note <BR>"; $text .= "The information contained within this report is of a confidential nature and should not be shared with any other person."; // text and html versions of email. $html = '<html><body>' . $text . '</body></html>'; $mime->setTXTBody($text); $mime->setHTMLBody($html); $mime->setFrom(SMTP_USER); $mime->setSubject($subject); $body = $mime->get(); $headers = $mime->headers(); $smtp = Mail::factory('smtp', array('host' => SMTP_HOST, 'port' => SMTP_PORT, 'auth' => true, 'username' => SMTP_USER, 'password' => SMTP_PASSWORD)); foreach ($return as $row) { $mailto = $row['username']; if (TRIM($mailto) != '') { $mailto = $smtp->send($mailto, $header, $body); } if (PEAR::isError($mail)) { echo 'Mail not send'; } else { echo 'Mail has sent successfully'; } } /* end */ /* if ($return) {
function recover($webid) { // hexa string of 20 chars $hash = sha1(trim($webid) . uniqid(microtime(true), true)); $webid = trim($webid); // find if a recovery email exists or not for the given WebID $query = "SELECT email FROM recovery WHERE webid='" . mysql_real_escape_string($webid) . "'"; $result = mysql_query($query); if (!$result) { die('Unable to connect to the database!'); } else { if (mysql_num_rows($result) > 0) { $row = mysql_fetch_assoc($result); $email = $row['email']; mysql_free_result($result); // set the hash $query = "UPDATE recovery SET " . "recovery_hash='" . $hash . "' " . "WHERE webid='" . mysql_real_escape_string($webid) . "'"; $result = mysql_query($query); if (!$result) { return error('Unable to connect to the database!'); } else { // send the email $person = new MyProfile(trim($webid), BASE_URI, SPARQL_ENDPOINT); $person->load(); $to_name = $person->get_name(); $from = 'MyProfile Recovery System <' . SMTP_USERNAME . '>'; $to = '"' . $to_name . '" <' . clean_mail($email) . '>'; $subject = 'Instructions to recover your account on ' . BASE_URI . '.'; $headers = array('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array('host' => SMTP_SERVER, 'auth' => SMTP_AUTHENTICATION, 'username' => SMTP_USERNAME, 'password' => SMTP_PASSWORD)); $message = '<html><body>'; $message .= '<p>Hello ' . $to_name . ',</p>'; $message .= '<p>You have requested to recover your personal account on ' . BASE_URI . '. '; $message .= 'Please click <a href="' . BASE_URI . '/recovery?recovery_code=' . $hash . '">' . BASE_URI . '/recovery?recovery_code=' . $hash . '</a> to proceed.</p>'; $message .= '<p>Alternatively, you can recover your account by visiting this page: <a href="' . BASE_URI . '/recovery">' . BASE_URI . '/recovery</a> and typing or pasting the following recovery code:</p>'; $message .= '<p>'; $message .= '<strong>' . $hash . '</strong> '; $message .= '</p>'; $message .= '<p>Important! Do not forget that once you are logged in, you can obtain a new certificate by going to your <a href="https://my-profile.eu/view">profile page</a> and then clicking on the "Certificate" icon under "Actions for this profile".</p>'; $message .= '<br /><p><hr /></p>'; $message .= '<p><small>This is an automated email generate by <a href="https://my-profile.eu/">MyProfile</a> and you do not need to respond to it.</small></p>'; $message .= '</body></html>'; $crlf = "\n"; $mime = new Mail_Mime(array('eol' => $crlf)); $mime->setHTMLBody($message); $mimeparams = array(); $mimeparams['html_charset'] = "UTF-8"; $mimeparams['head_charset'] = "UTF-8"; $headers = $mime->headers($headers); $body = $mime->get($mimeparams); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { $ret .= error('Sendmail: ' . $mail->getMessage()); } return success('An email has been sent to the recovery address you have specified.'); } } else { return error('You did not provide a recovery email address!'); } } }