Odoslanie emailu s prílohou
Funkcia používa triedu t3lib_htmlmail.
/**
* Extended mail function
*
* @param string $toEMail: recipient email address
* @param string $subject: subject
* @param string $message: mail text
* @param string $attachment: attachment
*/
function sendMailExtend( $toEMail, $subject, $message, $attachment = '' ) {
global $TYPO3_CONF_VARS;
include_once( PATH_t3lib.'class.t3lib_htmlmail.php' );
$cls = t3lib_div::makeInstanceClassName( 't3lib_htmlmail' );
if( class_exists( $cls ) ) {
$Typo3_htmlmail = t3lib_div::makeInstance('t3lib_htmlmail');
$Typo3_htmlmail->start();
$Typo3_htmlmail->subject = $subject;
$Typo3_htmlmail->from_email = $this->conf['mailFrom'];
$Typo3_htmlmail->from_name = $this->conf['nameFrom'];
$Typo3_htmlmail->replyto_email = $Typo3_htmlmail->from_email;
$Typo3_htmlmail->replyto_name = $Typo3_htmlmail->from_name;
$Typo3_htmlmail->organisation = '';
if( $attachment != '' )
$Typo3_htmlmail->addAttachment( $attachment );
$Typo3_htmlmail->addPlain( $message );
$Typo3_htmlmail->setHeaders();
$Typo3_htmlmail->setContent();
$Typo3_htmlmail->setRecipient( explode( ',', $toEMail ) );
$Typo3_htmlmail->sendTheMail();
}
}
Volanie predchádzajúcej funkcie. Príloha sa vytvorí priamo zo stránky ($this->pid), ktorá sa formátuje ako PDF (vďaka URL parametru type=123, na export do PDF je použitý extension pdf_generator2):
// Create mail from template
if( file_exists( $this->conf['templateMail'] ) ) {
$template = file_get_contents( $this->conf['templateMail'] );
$patterns = array(
0 => '/###ORDER_UID###/',
1 => '/###PRODUCTS###/',
);
$replacements = array(
0 => $order['uid'],
1 => $products,
);
$text = preg_replace( $patterns, $replacements, $template );
}
$this->url = 'http://www.sitename.at/index.php?id='.$this->pid.'&tracking='.$order['code'].'&type=123';
$file = $this->conf['folderVoucher'].'voucher_'.$order['code'].'.pdf';
if( !file_exists( $file ) )
if( !@copy( $this->url, $file ) ) /* empty */;
$this->sendMailExtend( $order['email'], 'Order No: '.$order['uid'], $text, $file );
Podobný kód bol použitý v module mproducts.
| Žiadne dokumenty ani odkazy k tejto stránke. | ||
Generátor typoscriptu
Vytvára typoscript pre bežné použitie. Generátor je jednoduchý na obsluhu, stačí vyplniť zopár položiek formulára.