Exemple #1
0
 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);
 }
Exemple #2
0
                    $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";
            }
        }
    }
} else {
Exemple #3
0
 $anz = $_FILES["Datei"]["name"][0] != "" ? count($_FILES["Datei"]["name"]) : 0;
 $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;
     }
Exemple #4
0
 /**
  * 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;
 }
     $pdf->SetFont('Arial', '', 10);
     $pdf->AddPage();
     $pdf->SetTitle('Packliste ab ' . $datum);
     $pdf->Titel('Packliste ab ' . $datum);
     $pdf->SetDrawColor(255, 255, 255);
     $pdf->BasicTable($data);
     $pdf->Output($dir . $filepdf, "F");
     if (file_exists($dir . $filepdf)) {
         if ($_POST['weg'] == 2) {
             $headers = array("From" => $_SESSION['email'], "X-Mailer" => "PHP/" . phpversion(), "Subject" => 'Packliste ab ' . $datum);
             $mime = new Mail_Mime(array('eol' => "\n"));
             $csv = $mime->addAttachment($dir . $filecsv, mime_content_type($dir . $filecsv), $filecsv);
             $pdf = $mime->addAttachment($dir . $filepdf, mime_content_type($dir . $filepdf), $filepdf);
             $mime->setTXTBody('Packliste');
             $hdrs = $mime->headers($headers);
             $body = $mime->get();
             $mail = Mail::factory("mail");
             $mail->_params = "-f " . $_SESSION['email'];
             $rc = $mail->send($_SESSION['email'], $hdrs, $body);
             $output = 'E-Mail verschickt';
             #unlink($dir.$filepdf);
         } else {
             header('Content-type: application/pdf');
             header('Content-Disposition: attachment; filename="packliste.pdf"');
             readfile($dir . $filepdf);
             #unlink($dir.$filepdf);
         }
     } else {
         $output .= 'Konnte kein PDF erstellen.<br>';
     }
 } else {
<?php

$from = '*****@*****.**';
$to = '*****@*****.**';
// $to = '*****@*****.**';
$subject = 'Test Sub';
$htmlBody = 'Test Message';
echo '<br>--------------------------';
include_once 'Mail.php';
include_once 'Mail/mime.php';
$em = Mail::factory('sendmail');
$headers = array('From' => $from, 'To' => $to, 'Subject' => $subject);
$mime = new Mail_Mime();
//$mime->setTxtBody($plainBody);
$mime->setHtmlBody($htmlBody);
$message = $mime->get();
$headers = $mime->headers($headers);
$mail = $em->send($to, $headers, $message);
var_dump($mail);
/* include_once("class.phpmailer.php");
	
$mail = new PHPMailer();
	
$mail->IsSMTP();  // telling the class to use SMTP
// $mail->Host     = "relay-hosting.secureserver.net"; // SMTP server

$mail->Host = 'tls://smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = '******';
$mail->Password = '******';
	
Exemple #7
0
 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!');
         }
     }
 }