Esempio n. 1
0
 * |                                                                              |
 * |                  http://www.phpguru.org/static/license.html                  |
 * o------------------------------------------------------------------------------o
 *
 * © Copyright 2008,2009 Richard Heyes
 */
/**
 * This example shows you how to create an email with another email attached
 */
require_once 'Rmail.php';
/**
 * Create the attached email
 */
$attachment = new Rmail();
$attachment->setFrom('Bob <*****@*****.**>');
$attachment->setText('This email is attached.');
$attachment->setSubject('This email is attached.');
$body = $attachment->getRFC822(array('*****@*****.**'));
/**
 * Now create the email it will be attached to
 */
$mail = new Rmail();
$mail->addAttachment(new StringAttachment($body, 'Attached message', 'message/rfc822', new SevenBitEncoding()));
$mail->addAttachment(new FileAttachment('example.zip'));
$mail->setFrom('Richard <*****@*****.**>');
$mail->setSubject('Test email');
$mail->setText('Sample text');
$result = $mail->send(array('*****@*****.**'));
?>

Message has been sent
Esempio n. 2
0
function mail_report($log)
{
    /*
    	Mail detailed reports on what has been done.
    */
    global $cfg, $log_header, $log_footer, $total_error_count;
    // Get configuration options
    $email_report = $cfg['email_report'];
    $email_archive = $cfg['email_archive'];
    $email_from = $cfg['email_from'];
    $email_to = $cfg['email_to'];
    $email_agent = $cfg['email_agent'];
    $email_smtp_host = $cfg['email_smtp_host'];
    $email_smtp_port = $cfg['email_smtp_port'];
    $ftp_upload = $cfg['ftp_upload'];
    $archive_tar = $cfg['archive_tar'];
    $archive_prefix = $cfg['archive_prefix'];
    $archive_gzip = $cfg['archive_gzip'];
    require_once dirname(__FILE__) . '/Rmail.php';
    $mail = new Rmail();
    // HTML Part of the Message
    $html = $log_header . $log['html'] . $log_footer;
    // Plain Vanilla Text Version of Message
    // $text = strip_tags(html_entity_decode($log));
    $text = $log['text'];
    // Do we have to send the backup-archive too?
    if ($email_archive == TRUE && $archive_tar == TRUE) {
        foreach ($cfg['db'] as $db_i => $db_name) {
            if ($cfg['db'][$db_i]['db_name'] != '') {
                $db_name = $cfg['db'][$db_i]['db_name'];
                $db_backup_fname = $archive_prefix . $db_name . ".tar";
                // Is the backup-archive compressed?
                if ($archive_gzip == TRUE) {
                    $db_backup_fname .= ".gz";
                    $db_backup_ftype = 'application/x-gzip';
                } else {
                    $db_backup_ftype = 'application/x-tar';
                }
                // if ($db_backup_gzip == TRUE)
                if (file_exists(DB_BACKUP_PATH . "/" . $db_backup_fname)) {
                    log_msg(date("H:i:s") . ": Preparing file attachment {$db_backup_fname} \n", 10);
                    // Add an attachment to the email
                    $mail->addAttachment(new fileAttachment(DB_BACKUP_PATH . "/" . $db_backup_fname, $db_backup_ftype));
                } else {
                    log_msg(date("H:i:s") . ": Error: File {$db_backup_fname} for mail attachement not found!\n", 20);
                }
                // if (file_exists($db_backup_fname))
            }
            // if ($cfg['db'][$db_i]['db_name'] != '')
        }
        // foreach ($db_backup_dbnames as $db_name)
    }
    // if (($db_backup_email == TRUE) && ($db_backup_tar == TRUE))
    /*
     * Add the text, html and embedded images.
     * The name (background.gif in this case)
     * of the image should match exactly
     * (case-sensitive) to the name in the html.
     */
    $mail->setHTML($html);
    $mail->setText($text);
    /*
     * Set the return path of the message
     */
    if (ini_get('safe_mode') == "") {
        $mail->setReturnPath($email_from);
    }
    /**
     * Set some headers
     */
    $mail->setFrom('"MySQL Database Backup" <' . $email_from . '>');
    $mail->setSubject('MySQL Backup on ' . DB_BACKUP_HOST . ' of ' . date("D j. F Y"));
    $mail->setHeader('Date', date("r"));
    $mail->setHeader('X-Mailer', 'MySQL Database Backup $Revision: 1.4 $');
    if ($total_error_count > 0) {
        $mail->setHeader('Importance', 'High');
        $mail->setHeader('X-Priority', '1 (Highest)');
        $mail->setHeader('X-MSMail-Priority', 'High');
        $mail->setHeader('X-Message-Flag', 'There were errors! Review the protocol');
        $mail->setHeader('Reply-By', date("r"));
    } else {
        $mail->setHeader('Importance', 'Low');
        $mail->setHeader('X-Priority', '5 (Lowest)');
        $mail->setHeader('X-MSMail-Priority', 'Low');
        $mail->setHeader('Expires', date("r", time() + UNIX_DAY * 7));
        $mail->setHeader('Expiry-Date', date("r", time() + UNIX_DAY * 7));
    }
    /**
     * If you're using Windows you should *always* use
     * the smtp method of sending, as the mail() function is buggy.
     */
    if ($email_agent == 'smtp') {
        // Send by connecting to an STMP server of choice.
        $mail->setSMTPParams($email_smtp_host, $email_smtp_port, DB_BACKUP_HOST);
        $result = $mail->send(array($email_to), 'smtp');
        // These errors are only set if you're using SMTP to send the message
        if (!$result) {
            $msg = "Mail sending failed with the following error(s):\n";
            foreach ($mail->errors as $str) {
                $msg .= $str . "\n";
            }
        } else {
            $msg = 'Mail was sent succesfully!';
        }
    } else {
        if ($email_agent == 'mail') {
            // Send using the built-in mail() function of PHP and Operating System
            $result = $mail->send(array($email_to), 'mail');
            if (!$result) {
                $msg = "Error: Mail sending failed!\n";
            } else {
                $msg = 'Mail was sent succesfully!';
            }
        } else {
            $msg = "Error: Unknown mail agent option {$email_agent}";
        }
    }
    // if ($email_agent == 'smtp')
    return $msg;
}
Esempio n. 3
0
            echo "<p>Die Datei " . basename($_FILES['file']['name']) . " wurde erfolgreich hochgeladen!</p>";
            /* echo "<p><img src='./uploads/".basename( $_FILES['file']['name'])."' alt='".basename( $_FILES['file']['name'])."' width='' height='' class='uploadedimage' /></p>"; */
        } else {
            echo "<p>Beim Hochladen der Datei ist ein Fehler aufgetreten, bitte versuchen Sie es erneut!</p>";
        }
    }
    /*	E-Mail ersstellen	*/
    require_once './Rmail/Rmail.php';
    $mail = new Rmail();
    $mail->setHTMLCharset('UTF-8');
    $mail->setFrom('Anzeigenbestellformular <*****@*****.**>');
    $mail->setSubject('regimmo :: Anzeigenbestellung');
    $mail->setHTML($mailtext);
    $mail->setReceipt('*****@*****.**');
    if (isset($_FILES['file']['name']) && $_FILES['file']['name'] != "") {
        $mail->addAttachment(new FileAttachment('./uploads/' . basename($_FILES['file']['name']) . ''));
    }
    $result = $mail->send(array('*****@*****.**', '*****@*****.**', $email));
    /*	Bild wieder löschen	*/
    /*
    if(isset($_FILES['file']['name']) && $_FILES['file']['name']!=""){						
    					    	unlink('./uploads/'.basename( $_FILES['file']['name']).'');
    					    }
    */
} else {
    ?>
				
				<h1>Hiermit bestelle ich verbindlich folgende Anzeigenschaltung</h1>
			
				<form class="ad-orderform" action="index.php" method="post" enctype="multipart/form-data">
					<p>
Esempio n. 4
0
 * This example shows you how to create an email with another email attached
 */
require_once 'Rmail.php';
/**
 * Create the attached email
 */
/*
   $attachment = new Rmail();
$attachment->setFrom('Bob <*****@*****.**>');
$attachment->setText('This email is attached.');
$attachment->setSubject('This email is attached.');
$body = $attachment->getRFC822(array('*****@*****.**'));

/**
* Now create the email it will be attached to
*/
$mail = new Rmail();
//$mail->addAttachment(new StringAttachment($body, 'Attached message', 'message/rfc822', new SevenBitEncoding()));
// this will attach documents.
$mail->addAttachment(new FileAttachment('example.zip'));
$mail->addAttachment(new FileAttachment('My Job.doc'));
//who is send the email
$mail->setFrom('Richard <*****@*****.**>');
$mail->setSubject('Test email');
// body of the text
$mail->setText('Sample text');
$result = $mail->send($addresses = array('*****@*****.**'));
?>

Message has been sent to: <?php 
echo implode(', ', $addresses);
Esempio n. 5
0
 */
$mail->setText('Sample text');
/**
 * Set the HTML of the email. Any embedded images will be automatically found as long as you have added them
 * using addEmbeddedImage() as below.
 */
$mail->setHTML('<b>Sample HTML</b> <img src="background.gif">');
/**
 * Set the delivery receipt of the email. This should be an email address that the receipt should be sent to.
 * You are NOT guaranteed to receive this receipt - it is dependent on the receiver.
 */
$mail->setReceipt('*****@*****.**');
/**
 * Add an embedded image. The path is the file path to the image.
 */
$mail->addEmbeddedImage(new fileEmbeddedImage('background.gif'));
/**
 * Add an attachment to the email.
 */
$mail->addAttachment(new fileAttachment('example.zip'));
/**
 * Send the email. Pass the method an array of recipients.
 */
$address = '*****@*****.**';
$result = $mail->send(array($address));
?>

Email has been sent to <?php 
echo $address;
?>
. Result: <?var_dump($result)?>