Public Member Functions | |
| start ($V, $base64=1) | |
| Start function This class is able to generate a mail in formmail-style from the data in $V Fields:. | |
| addAttachment ($file, $filename) | |
| Adds an attachment to the mail. | |
Public Attributes | |
| $reserved_names = 'recipientrecipient_copyauto_respond_msgredirectsubjectattachmentfrom_emailfrom_namereplyto_emailreplyto_nameorganisationpriorityhtml_enabledquoted_printablesubmit_xsubmit_y' | |
|
||||||||||||
|
Adds an attachment to the mail.
Definition at line 166 of file class.t3lib_formmail.php. References $content, t3lib_htmlmail::getURL(), and t3lib_htmlmail::split_fileref(). Referenced by start(). 00166 {
00167 $content = $this->getURL($file); // We fetch the content and the mime-type
00168 $fileInfo = $this->split_fileref($filename);
00169 if ($fileInfo['fileext'] == 'gif') {$content_type = 'image/gif';}
00170 if ($fileInfo['fileext'] == 'bmp') {$content_type = 'image/bmp';}
00171 if ($fileInfo['fileext'] == 'jpg' || $fileInfo['fileext'] == 'jpeg') {$content_type = 'image/jpeg';}
00172 if ($fileInfo['fileext'] == 'html' || $fileInfo['fileext'] == 'htm') {$content_type = 'text/html';}
00173 if (!$content_type) {$content_type = 'application/octet-stream';}
00174
00175 if ($content) {
00176 $theArr['content_type']= $content_type;
00177 $theArr['content']= $content;
00178 $theArr['filename']= $filename;
00179 $this->theParts['attach'][]=$theArr;
00180 return true;
00181 } else { return false;}
00182 }
|
|
||||||||||||
|
Start function This class is able to generate a mail in formmail-style from the data in $V Fields:. [recipient]: email-adress of the one to receive the mail. If array, then all values are expected to be recipients [attachment]: .... [subject]: The subject of the mail [from_email]: Sender email. If not set, [email] is used [from_name]: Sender name. If not set, [name] is used [replyto_email]: Reply-to email. If not set [from_email] is used [replyto_name]: Reply-to name. If not set [from_name] is used [organisation]: Organisation (header) [priority]: Priority, 1-5, default 3 [html_enabled]: If mail is sent as html [quoted_printable]: if set, quoted-printable will be used instead of base 64
Definition at line 95 of file class.t3lib_formmail.php. References $a, $val, addAttachment(), t3lib_htmlmail::addPlain(), t3lib_htmlmail::setContent(), t3lib_htmlmail::setHeaders(), t3lib_htmlmail::setRecipient(), table(), and t3lib_htmlmail::useBase64(). 00095 {
00096 if ($base64 && !$V['quoted_printable']) {$this->useBase64();}
00097
00098 if (isset($V['recipient'])) {
00099 // Sets the message id
00100 $this->messageid = md5(microtime()).'@domain.tld';
00101
00102 $this->subject = ($V['subject']) ? $V['subject'] : 'Formmail on '.t3lib_div::getIndpEnv('HTTP_HOST');
00103 $this->from_email = ($V['from_email']) ? $V['from_email'] : (($V['email'])?$V['email']:'');
00104 $this->from_name = ($V['from_name']) ? $V['from_name'] : (($V['name'])?$V['name']:'');
00105 $this->replyto_email = ($V['replyto_email']) ? $V['replyto_email'] : $this->from_email;
00106 $this->replyto_name = ($V['replyto_name']) ? $V['replyto_name'] : $this->from_name;
00107 $this->organisation = ($V['organisation']) ? $V['organisation'] : '';
00108 $this->priority = ($V['priority']) ? t3lib_div::intInRange($V['priority'],1,5) : 3;
00109
00110 // Auto responder.
00111 $this->auto_respond_msg = (trim($V['auto_respond_msg']) && $this->from_email) ? trim($V['auto_respond_msg']) : '';
00112
00113 $Plain_content = '';
00114 $HTML_content = '<table border="0" cellpadding="2" cellspacing="2">';
00115
00116 // Runs through $V and generates the mail
00117 if (is_array($V)) {
00118 reset($V);
00119 while (list($key,$val)=each($V)) {
00120 if (!t3lib_div::inList($this->reserved_names,$key)) {
00121 $space = (strlen($val)>60)?chr(10):'';
00122 $val = (is_array($val) ? implode($val,chr(10)) : $val);
00123 $Plain_content.= strtoupper($key).': '.$space.$val."\n".$space;
00124 $HTML_content.='<tr><td bgcolor="#eeeeee"><font face="Verdana" size="1"><b>'.strtoupper($key).'</b></font></td><td bgcolor="#eeeeee"><font face="Verdana" size="1">'.nl2br(HTMLSpecialChars($val)).' </font></td></tr>';
00125 }
00126 }
00127 }
00128 $HTML_content.= '</table>';
00129
00130
00131 if ($V['html_enabled']) {
00132 $this->setHTML($this->encodeMsg($HTML_content));
00133 }
00134 $this->addPlain($Plain_content);
00135
00136 for ($a=0;$a<10;$a++) {
00137 $varname = 'attachment'.(($a)?$a:'');
00138 $theFile = t3lib_div::upload_to_tempfile($_FILES[$varname]['tmp_name']);
00139 $theName = $_FILES[$varname]['name'];
00140
00141 if ($theFile && @file_exists($theFile)) {
00142 if (filesize($theFile) < 250000) {
00143 $this->addAttachment($theFile, $theName);
00144 }
00145 }
00146 t3lib_div::unlink_tempfile($theFile);
00147 }
00148
00149 $this->setHeaders();
00150 $this->setContent();
00151 $this->setRecipient($V['recipient']);
00152 if ($V['recipient_copy']) {
00153 $this->recipient_copy = trim($V['recipient_copy']);
00154 }
00155 }
00156 }
|
|
|
Definition at line 70 of file class.t3lib_formmail.php. |
1.3.8-20040913