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); }
// 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>"; } else { echo "<p>Message successfully sent!</p>";
<?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 = '******';