Main Page | Directories | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages | Examples

t3lib_readmail Class Reference

List of all members.

Public Member Functions

 find_MIDfromReturnPath ($to)
 Returns special TYPO3 Message ID (MID) from input TO header (the return address of the sent mail from Dmailer.
 find_XTypo3MID ($content)
 Returns special TYPO3 Message ID (MID) from input mail content (used by Dmailer, return mails).
 getMessage ($mailParts)
 Returns the text content of a mail which has previously been parsed by eg.
 getTextContent ($content)
 Returns the body part of a raw mail message (including headers) Probably obsolete since the function fullParse() is more advanced and safer to use.
 getMailBoundaryParts ($boundary, $content)
 Splits the body of a mail into parts based on the boundary string given.
 getCType ($str)
 Returns Content Type plus more.
 analyseReturnError ($c)
 Analyses the return-mail content for the Dmailer module - used to find what reason there was for rejecting the mail Used by the Dmailer, but not exclusively.
 decodeHeaderString ($str)
 Decodes a header-string with the =?....?= syntax including base64/quoted-printable encoding.
 extractNameEmail ($str)
 Extracts name/email parts from a header field (like 'To:' or 'From:' with name/email mixed up.

Public Attributes

 $dateAbbrevs
 $serverGMToffsetMinutes = 60

Member Function Documentation

t3lib_readmail::analyseReturnError c  ) 
 

Analyses the return-mail content for the Dmailer module - used to find what reason there was for rejecting the mail Used by the Dmailer, but not exclusively.

Parameters:
string message body/text
Returns:
array key/value pairs with analysis result. Eg. "reason", "content", "reason_text", "mailserver" etc.

Definition at line 271 of file class.t3lib_readmail.php.

References header(), and message().

00271                                     {
00272       $cp=array();
00273       if (strstr($c,'--- Below this line is a copy of the message.'))   {     // QMAIL
00274          list($c)=explode('--- Below this line is a copy of the message.',$c);   // Splits by the QMAIL divider
00275          $cp['content']=trim($c);
00276          $parts = explode('>:',$c,2);
00277          $cp['reason_text']=trim($parts[1]);
00278          $cp['mailserver']='Qmail';
00279          if (eregi('550|no mailbox|account does not exist',$cp['reason_text']))  {
00280             $cp['reason']=550;   // 550 Invalid recipient
00281          } elseif (stristr($cp['reason_text'],'couldn\'t find any host named')) {
00282             $cp['reason']=2;  // Bad host
00283          } elseif (eregi('Error in Header|invalid Message-ID header',$cp['reason_text'])) {
00284             $cp['reason']=554;
00285          } else {
00286             $cp['reason']=-1;
00287          }
00288       } elseif (strstr($c,'The Postfix program'))  {     // Postfix
00289          $cp['content']=trim($c);
00290          $parts = explode('>:',$c,2);
00291          $cp['reason_text']=trim($parts[1]);
00292          $cp['mailserver']='Postfix';
00293          if (stristr($cp['reason_text'],'550')) {
00294             $cp['reason']=550;   // 550 Invalid recipient, User unknown
00295          } elseif (stristr($cp['reason_text'],'553')) {
00296             $cp['reason']=553;   // No such user
00297          } elseif (stristr($cp['reason_text'],'551')) {
00298             $cp['reason']=551;   // Mailbox full
00299          } else {
00300             $cp['reason']=-1;
00301          }
00302       } else { // No-named:
00303          $cp['content']=trim($c);
00304          $cp['reason_text']=trim(substr($c,0,1000));
00305          $cp['mailserver']='unknown';
00306          if (eregi('Unknown Recipient|Delivery failed 550|Receiver not found|User not listed|recipient problem|Delivery to the following recipients failed|User unknown|recipient name is not recognized',$cp['reason_text']))   {
00307             $cp['reason']=550;   // 550 Invalid recipient, User unknown
00308          } elseif (eregi('over quota|mailbox full',$cp['reason_text'])) {
00309             $cp['reason']=551;
00310          } elseif (eregi('Error in Header',$cp['reason_text']))   {
00311             $cp['reason']=554;
00312          } else {
00313             $cp['reason']=-1;
00314          }
00315       }
00316 
00317       return $cp;
00318    }

t3lib_readmail::decodeHeaderString str  ) 
 

Decodes a header-string with the =?....?= syntax including base64/quoted-printable encoding.

Parameters:
string A string (encoded or not) from a mail header, like sender name etc.
Returns:
string The input string, but with the parts in =?....?= decoded.

Definition at line 326 of file class.t3lib_readmail.php.

00326                                        {
00327       $parts = explode('=?',$str,2);
00328       if (count($parts)==2)   {
00329          list($charset,$encType,$encContent)=explode('?',$parts[1],3);
00330          $subparts =explode('?=',$encContent,2);
00331          $encContent=$subparts[0];
00332 
00333          switch(strtolower($encType))  {
00334             case 'q':
00335                $encContent = quoted_printable_decode($encContent);
00336                $encContent = str_replace('_',' ',$encContent);
00337             break;
00338             case 'b':
00339                $encContent=base64_decode($encContent);
00340             break;
00341          }
00342 
00343          $parts[1]=$encContent.$this->decodeHeaderString($subparts[1]); // Calls decodeHeaderString recursively for any subsequent encoded section.
00344       }
00345       return implode('',$parts);
00346    }

t3lib_readmail::extractNameEmail str  ) 
 

Extracts name/email parts from a header field (like 'To:' or 'From:' with name/email mixed up.

Parameters:
string Value from a header field containing name/email values.
Returns:
array Array with the name and email in. Email is validated, otherwise not set.

Definition at line 354 of file class.t3lib_readmail.php.

t3lib_readmail::find_MIDfromReturnPath to  ) 
 

Returns special TYPO3 Message ID (MID) from input TO header (the return address of the sent mail from Dmailer.

Used by Dmailer, return mails)

Parameters:
string email address, return address string
Returns:
mixed array with 'mid', 'rtbl' and 'rid' keys are returned.

Definition at line 122 of file class.t3lib_readmail.php.

References $out.

00122                                           {
00123       $parts = explode('mid',strtolower($to));
00124       $moreParts=explode('_',$parts[1]);
00125       $out=array(
00126          'mid' => $moreParts[0],
00127          'rtbl' => substr($moreParts[1],0,1),
00128          'rid' => intval(substr($moreParts[1],1))
00129       );
00130       if ($out['rtbl']=='p')     $out['rtbl']='P';
00131 
00132       return($out);
00133    }

t3lib_readmail::find_XTypo3MID content  ) 
 

Returns special TYPO3 Message ID (MID) from input mail content (used by Dmailer, return mails).

Parameters:
string Mail (header) content
Returns:
mixed If "X-Typo3MID" header is found and integrity is OK, then an array with 'mid', 'rtbl' and 'rid' keys are returned. Otherwise void.

Definition at line 142 of file class.t3lib_readmail.php.

References $out.

00142                                        {
00143       if (strstr($content,'X-Typo3MID:')) {
00144          $p=explode('X-Typo3MID:',$content,2);
00145          $l=explode(chr(10),$p[1],2);
00146          list($mid,$hash)=t3lib_div::trimExplode('-',$l[0]);
00147          if (md5($mid)==$hash)   {
00148             $moreParts=explode('_',substr($mid,3));
00149             $out=array(
00150                'mid' => $moreParts[0],
00151                'rtbl' => substr($moreParts[1],0,1),
00152                'rid' => substr($moreParts[1],1)
00153             );
00154             return($out);
00155          }
00156       }
00157    }

t3lib_readmail::getCType str  ) 
 

Returns Content Type plus more.

Obsolete, use fullParse()

Parameters:
string "ContentType" string with more
Returns:
array parts in key/value pairs

Definition at line 248 of file class.t3lib_readmail.php.

Referenced by getMessage().

00248                            {
00249       $parts = explode(';',$str);
00250       $cTypes=array();
00251       $cTypes['ContentType']=$parts[0];
00252       next($parts);
00253       while(list(,$ppstr)=each($parts))   {
00254          $mparts = explode('=',$ppstr,2);
00255          if (count($mparts)>1)   {
00256             $cTypes[strtolower(trim($mparts[0]))]=ereg_replace('^"','',trim(ereg_replace('"$','',trim($mparts[1]))));
00257          } else {
00258             $cTypes[]=$ppstr;
00259          }
00260       }
00261       return $cTypes;
00262    }

t3lib_readmail::getMailBoundaryParts boundary,
content
 

Splits the body of a mail into parts based on the boundary string given.

Obsolete, use fullParse()

Parameters:
string Boundary string used to split the content.
string BODY section of a mail
Returns:
array Parts of the mail based on this

Definition at line 228 of file class.t3lib_readmail.php.

Referenced by getMessage().

00228                                                       {
00229       $mParts = explode('--'.$boundary,$content);
00230       unset($mParts[0]);
00231       reset($mParts);
00232       $new=array();
00233       while(list(,$val)=each($mParts)) {
00234          if (trim($val)=='--') break;
00235          $new[] = ltrim($val);
00236       }
00237       return $new;
00238    }

t3lib_readmail::getMessage mailParts  ) 
 

Returns the text content of a mail which has previously been parsed by eg.

extractMailHeader() Probably obsolete since the function fullParse() is more advanced and safer to use.

Parameters:
array Output from extractMailHeader()
Returns:
string The content.

Definition at line 188 of file class.t3lib_readmail.php.

References getCType(), getMailBoundaryParts(), and getTextContent().

00188                                     {
00189       if ($mailParts['content-type'])  {
00190          $CType = $this->getCType($mailParts['content-type']);
00191          if ($CType['boundary']) {
00192             $parts = $this->getMailBoundaryParts($CType['boundary'],$mailParts['CONTENT']);
00193             $c=$this->getTextContent($parts[0]);
00194          } else {
00195             $c=$this->getTextContent(
00196                'Content-Type: '.$mailParts['content-type'].'
00197                '.$mailParts['CONTENT']
00198             );
00199          }
00200       } else {
00201          $c = $mailParts['CONTENT'];
00202       }
00203       return $c;
00204    }

t3lib_readmail::getTextContent content  ) 
 

Returns the body part of a raw mail message (including headers) Probably obsolete since the function fullParse() is more advanced and safer to use.

Parameters:
string Raw mail content
Returns:
string Body of message

Definition at line 213 of file class.t3lib_readmail.php.

Referenced by getMessage().

00213                                        {
00214       $p=$this->extractMailHeader($content);
00215       // Here some decoding might be needed...
00216       // However we just return what is believed to be the proper notification:
00217       return $p['CONTENT'];
00218    }


Member Data Documentation

t3lib_readmail::$dateAbbrevs
 

Initial value:

 array(
      'JAN' => 1,
      'FEB' => 2,
      'MAR' => 3,
      'APR' => 4,
      'MAY' => 5,
      'JUN' => 6,
      'JUL' => 7,
      'AUG' => 8,
      'SEP' => 9,
      'OCT' => 10,
      'NOV' => 11,
      'DEC' => 12
   )

Definition at line 88 of file class.t3lib_readmail.php.

t3lib_readmail::$serverGMToffsetMinutes = 60
 

Definition at line 102 of file class.t3lib_readmail.php.


The documentation for this class was generated from the following file:
Generated on Sun Oct 3 01:07:08 2004 for TYPO3core 3.7.0 dev by  doxygen 1.3.8-20040913