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); }
$to = '"' . $to_name . '" <' . clean_mail($to_email) . '>'; $subject = 'You have received a new personal message!'; $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 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";
} } else { if ($_SESSION['email'] != '') { $abs = $Name . ' <' . $_SESSION["email"] . '>'; $rc = chkMailAdr($_SESSION["email"]); if ($rc != "ok") { $okA = false; $msg .= " Abs:" . $rc; } } else { $okA = false; $msg .= " Kein Absender"; } } if ($okT && $okC && $okA) { $mime = new Mail_Mime("\n"); $mail =& Mail::factory("mail"); $Subject = preg_replace("/(content-type:|bcc:|cc:|to:|from:)/im", "", $_POST["Subject"]); $SubjectMail = mb_encode_mimeheader($Subject, $_SESSION["charset"], 'Q', ''); $headers = array("Return-Path" => $abs, "Reply-To" => $abs, "From" => $abs, "X-Mailer" => "PHP/" . phpversion(), "Subject" => $SubjectMail); $to = $TO ? $TO : $CC; if (strpos($to, ",") > 0) { $tmp = explode(",", $to); $to = array(); foreach ($tmp as $row) { $to[] = trim($row); } } if ($TO && $CC) { if ($_POST["bcc"]) { $headers["Bcc"] = $CC;
/** * Send an automated response. * * @param object $mailing * The mailing object. * @param int $queue_id * The queue ID. * @param string $replyto * Optional reply-to from the reply. * * @return void */ private static function autoRespond(&$mailing, $queue_id, $replyto) { $config = CRM_Core_Config::singleton(); $contacts = CRM_Contact_DAO_Contact::getTableName(); $email = CRM_Core_DAO_Email::getTableName(); $queue = CRM_Mailing_Event_DAO_Queue::getTableName(); $eq = new CRM_Core_DAO(); $eq->query("SELECT {$contacts}.preferred_mail_format as format,\n {$email}.email as email,\n {$queue}.job_id as job_id,\n {$queue}.hash as hash\n FROM {$contacts}\n INNER JOIN {$queue} ON {$queue}.contact_id = {$contacts}.id\n INNER JOIN {$email} ON {$queue}.email_id = {$email}.id\n WHERE {$queue}.id = " . CRM_Utils_Type::escape($queue_id, 'Integer')); $eq->fetch(); $to = empty($replyto) ? $eq->email : $replyto; $component = new CRM_Mailing_BAO_Component(); $component->id = $mailing->reply_id; $component->find(TRUE); $message = new Mail_Mime("\n"); $domain = CRM_Core_BAO_Domain::getDomain(); list($domainEmailName, $_) = CRM_Core_BAO_Domain::getNameAndEmail(); $emailDomain = CRM_Core_BAO_MailSettings::defaultDomain(); $headers = array('Subject' => $component->subject, 'To' => $to, 'From' => "\"{$domainEmailName}\" <do-not-reply@{$emailDomain}>", 'Reply-To' => "do-not-reply@{$emailDomain}", 'Return-Path' => "do-not-reply@{$emailDomain}"); /* TODO: do we need reply tokens? */ $html = $component->body_html; if ($component->body_text) { $text = $component->body_text; } else { $text = CRM_Utils_String::htmlToText($component->body_html); } $bao = new CRM_Mailing_BAO_Mailing(); $bao->body_text = $text; $bao->body_html = $html; $tokens = $bao->getTokens(); if ($eq->format == 'HTML' || $eq->format == 'Both') { $html = CRM_Utils_Token::replaceDomainTokens($html, $domain, TRUE, $tokens['html']); $html = CRM_Utils_Token::replaceMailingTokens($html, $mailing, NULL, $tokens['html']); $message->setHTMLBody($html); } if (!$html || $eq->format == 'Text' || $eq->format == 'Both') { $text = CRM_Utils_Token::replaceDomainTokens($text, $domain, FALSE, $tokens['text']); $text = CRM_Utils_Token::replaceMailingTokens($text, $mailing, NULL, $tokens['text']); $message->setTxtBody($text); } $b = CRM_Utils_Mail::setMimeParams($message); $h = $message->headers($headers); CRM_Mailing_BAO_Mailing::addMessageIdHeader($h, 'a', $eq->job_id, queue_id, $eq->hash); $mailer = $config->getMailer(); if (is_object($mailer)) { $errorScope = CRM_Core_TemporaryErrorScope::ignoreException(); $mailer->send($to, $h, $b); unset($errorScope); } }
/** * 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; }
fputs($f, '"###' . $_POST['notiz'] . '"'); } fclose($f); $pdf = new PDF(); $data = $pdf->LoadData($dir . $filecsv); $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);
// email address of the recipient $to = "*****@*****.**"; // email address of the sender $from = "*****@*****.**"; // subject of the email $subject = "Hello world from coolersport"; // email header format complies the PEAR's Mail class // this header includes sender's email and subject $headers = array('From' => $from, 'Subject' => $subject); // We will send this email as HTML format // which is well presented and nicer than plain text // using the heredoc syntax // REMEMBER: there should not be any space after PDFMAIL keyword $htmlMessage = "ho"; // create a new instance of the Mail_Mime class $mime = new Mail_Mime(); // set HTML content $mime->setHtmlBody($htmlMessage); // IMPORTANT: add pdf content as attachment // build email message and save it in $body $body = $mime->get(); // build header $hdrs = $mime->headers($headers); // create Mail instance that will be used to send email later $mail =& Mail::factory('mail'); // Sending the email, according to the address in $to, // the email headers in $hdrs, // and the message body in $body. $mail->send($to, $hdrs, $body); if (PEAR::isError($mail)) { echo "<p>" . $mail->getMessage() . "</p>";
/** * Send an automated response * * @param object $mailing The mailing object * @param int $queue_id The queue ID * @param string $replyto Optional reply-to from the reply * @return void * @access private * @static */ private static function autoRespond(&$mailing, $queue_id, $replyto) { $config = CRM_Core_Config::singleton(); $contacts = CRM_Contact_DAO_Contact::getTableName(); $email = CRM_Core_DAO_Email::getTableName(); $queue = CRM_Mailing_Event_DAO_Queue::getTableName(); $eq = new CRM_Core_DAO(); $eq->query("SELECT {$contacts}.preferred_mail_format as format,\n {$email}.email as email\n FROM {$contacts}\n INNER JOIN {$queue} ON {$queue}.contact_id = {$contacts}.id\n INNER JOIN {$email} ON {$queue}.email_id = {$email}.id\n WHERE {$queue}.id = " . CRM_Utils_Type::escape($queue_id, 'Integer')); $eq->fetch(); $to = empty($replyto) ? $eq->email : $replyto; $component = new CRM_Mailing_BAO_Component(); $component->id = $mailing->reply_id; $component->find(true); $message = new Mail_Mime("\n"); require_once 'CRM/Core/BAO/Domain.php'; $domain =& CRM_Core_BAO_Domain::getDomain(); list($domainEmailName, $_) = CRM_Core_BAO_Domain::getNameAndEmail(); require_once 'CRM/Core/BAO/MailSettings.php'; $emailDomain = CRM_Core_BAO_MailSettings::defaultDomain(); $headers = array('Subject' => $component->subject, 'To' => $to, 'From' => "\"{$domainEmailName}\" <do-not-reply@{$emailDomain}>", 'Reply-To' => "do-not-reply@{$emailDomain}", 'Return-Path' => "do-not-reply@{$emailDomain}"); /* TODO: do we need reply tokens? */ $html = $component->body_html; if ($component->body_text) { $text = $component->body_text; } else { $text = CRM_Utils_String::htmlToText($component->body_html); } require_once 'CRM/Mailing/BAO/Mailing.php'; $bao = new CRM_Mailing_BAO_Mailing(); $bao->body_text = $text; $bao->body_html = $html; $tokens = $bao->getTokens(); if ($eq->format == 'HTML' || $eq->format == 'Both') { require_once 'CRM/Utils/Token.php'; $html = CRM_Utils_Token::replaceDomainTokens($html, $domain, true, $tokens['html']); $html = CRM_Utils_Token::replaceMailingTokens($html, $mailing, null, $tokens['html']); $message->setHTMLBody($html); } if (!$html || $eq->format == 'Text' || $eq->format == 'Both') { require_once 'CRM/Utils/Token.php'; $text = CRM_Utils_Token::replaceDomainTokens($text, $domain, false, $tokens['text']); $text = CRM_Utils_Token::replaceMailingTokens($text, $mailing, null, $tokens['text']); $message->setTxtBody($text); } $b =& CRM_Utils_Mail::setMimeParams($message); $h =& $message->headers($headers); $mailer =& $config->getMailer(); PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array('CRM_Core_Error', 'nullHandler')); if (is_object($mailer)) { $mailer->send($to, $h, $b); CRM_Core_Error::setCallback(); } }
// set file name if ($_POST["icalart"] == "client") { $v->returnCalendar(); } else { if ($_POST["icalart"] == "mail") { $user = getUserStamm($_SESSION["loginCRM"]); $abs = sprintf("%s <%s>", $user["name"], $user["email"]); $Subject = "LxO-Kalender"; $v->setConfig('directory', "/tmp/"); // identify directory $v->saveCalendar(); // save calendar to file include_once "Mail.php"; include_once "Mail/mime.php"; $headers = array("Return-Path" => $abs, "Reply-To" => $abs, "From" => $abs, "X-Mailer" => "PHP/" . phpversion(), "Subject" => $Subject); $mime = new Mail_Mime("\n"); $mime->setTXTBody(""); echo "!" . $v->getConfig('directory') . "/" . $v->getConfig('filename') . "!" . $v->getConfig('filename') . "!"; $mime->addAttachment($v->getConfig('directory') . "/" . $v->getConfig('filename'), "text/plain", $v->getConfig('filename')); $body = $mime->get(array("text_encoding" => "quoted-printable", "text_charset" => $_SESSION["charset"])); $hdr = $mime->headers($headers); $mail =& Mail::factory("mail"); $mail->_params = "-f " . $user["email"]; $rc = $mail->send($_POST["icaldest"], $hdr, $body); } else { if (strtoupper($_POST["icaldest"]) == "HOME") { $_POST["icaldest"] = "dokumente/" . $_SESSION["dbname"] . "/" . $_SESSION["login"] . "/"; } $v->setConfig('directory', $_POST["icaldest"]); // identify directory $v->saveCalendar();
<?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 = '******';
$message = $mime->get(); $header = $mime->headers($header); $mail = $smtp->send($mailto, $header, $message); if (PEAR::isError($mail)) { echo 'Mail not send'; } else { echo 'Mail has sent successfully'; } } */ $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) {
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!'); } } }
<?php //mb_internal_encoding("UTF-8"); require_once "inc/stdLib.php"; include_once "inc/UserLib.php"; require_once "inc/crmLib.php"; include_once "Mail.php"; include_once "Mail/mime.php"; mb_internal_encoding($_SESSION["charset"]); $offset = $_GET["offset"] ? $_GET["offset"] : 1; $mime = new Mail_Mime("\n"); $mail =& Mail::factory("mail"); $headers = $_SESSION["headers"]; $user = getUserStamm($_SESSION["loginCRM"]); $mail->_params = "-f " . $user["email"]; $subject = $headers["Subject"]; $betreff = $_SESSION["Subject"]; $bodytxt = $_SESSION["bodytxt"]; $limit = $_SESSION["limit"]; $abs = $headers["Return-Path"]; if ($_SESSION['logmail']) { $f = fopen("log/maillog.txt", "a"); } $dateiname = $_SESSION["dateiname"]; if ($dateiname) { $ftmp = fopen("./dokumente/" . $_SESSION["dbname"] . "/" . $_SESSION["login"] . "/SerMail/" . $dateiname, "rb"); $filedata = fread($ftmp, filesize("./dokumente/" . $_SESSION["dbname"] . "/" . $_SESSION["login"] . "/SerMail/" . $dateiname)); fclose($ftmp); $mime->addAttachment($filedata, $_SESSION["type"], $_SESSION["dateiname"], false); } $sql = "select * from tempcsvdata where uid = '" . $_SESSION["loginCRM"] . "' and id < 1";