Source for file mail-defs.php

Documentation is available at mail-defs.php

  1. <?php
  2. /* ******************************************************************** */
  3. /* CATALYST PHP Source Code */
  4. /* -------------------------------------------------------------------- */
  5. /* This program is free software; you can redistribute it and/or modify */
  6. /* it under the terms of the GNU General Public License as published by */
  7. /* the Free Software Foundation; either version 2 of the License, or */
  8. /* (at your option) any later version. */
  9. /* */
  10. /* This program is distributed in the hope that it will be useful, */
  11. /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
  12. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
  13. /* GNU General Public License for more details. */
  14. /* */
  15. /* You should have received a copy of the GNU General Public License */
  16. /* along with this program; if not, write to: */
  17. /* The Free Software Foundation, Inc., 59 Temple Place, Suite 330, */
  18. /* Boston, MA 02111-1307 USA */
  19. /* -------------------------------------------------------------------- */
  20. /* */
  21. /* Filename: mail-defs.php */
  22. /* Author: Paul Waite */
  23. /* Description: Various mail definitions. */
  24. /* */
  25. /* ******************************************************************** */
  26. /** @package email *//**
  27. * Limit to the number of e-mails to send in one sitting.
  28. * This is used in LIMIT statements to queries which return
  29. * individuals to be e-mailed with one thing or another..
  30. * NOTE: A value of 0 means "no limit".
  31. */
  32. define("EMAIL_BULK_LIMIT", 0);
  33.  
  34. // MIME Encodings
  35. /** 7-bit Encoding */
  36. ("ENC_BIT7", "7bit");
  37. /** Base-64 Encoding */
  38. ("ENC_BASE64", "base64");
  39. /** Quoted-Printable Encoding */
  40. ("ENC_QUOTP", "quoted-printable");
  41.  
  42. // MIME Message Content Types
  43. /** Mixture of content: text/html/etc. */
  44. ("MIXED", "multipart/mixed");
  45. /** Alternative formats of same content */
  46. ("ALTERNATIVE", "multipart/alternative");
  47. /** Parts intended to be viewed all at once */
  48. ("PARALLEL", "multipart/parallel");
  49. /** A digest of multiple attachments */
  50. ("DIGEST", "multipart/digest");
  51.  
  52. // Misc internal constants
  53. /** No email subject string
  54. * @access private */
  55. define('NOSUBJECT', "(No Subject)");
  56. /** MIME warning message
  57. * @access private */
  58. define('MIME_WARNING', "This is a multi-part message in MIME format.");
  59. /** The default character set
  60. * @access private */
  61. define("DEFAULT_CHARSET", "us-ascii");
  62. /** MIME content is in-line
  63. * @access private */
  64. define("INLINE", "inline");
  65. /** MIME content is an attachment
  66. * @access private */
  67. define("ATTACH", "attachment");
  68. /** Carriage-return Linefeed sequence
  69. * @access private */
  70. define('CRLF', "\r\n");
  71. /** The body of the e-mail
  72. * @access private */
  73. define("BODY", CRLF . "BODY" . CRLF);
  74.  
  75. // -------------------------------------------------------------------------
  76. /**
  77. * email class
  78. * A class which encapsulates all the functions required to compose
  79. * and send an e-mail message. Also caters for MIME attachments.
  80. * @package email
  81. */
  82. class email {
  83. // Public
  84. /** e-mail From address */
  85.  
  86. var $from = "";
  87. /** Address to send e-mail */
  88.  
  89. var $to = array();
  90. /** Cc: (copies to) header */
  91.  
  92. var $cc = array();
  93. /** Bcc: (blind copies to) header */
  94.  
  95. var $bcc = array();
  96. /** e-mail ReplyTo address */
  97.  
  98. var $replyto = "";
  99. /** Subject of the e-mail */
  100.  
  101. var $subject = "";
  102. /** e-mail body text */
  103.  
  104. var $body = "";
  105.  
  106. // Private
  107. /** Accumulated errors
  108. @access private */
  109. var $errors = array();
  110. /** Extra ad-hoc e-mail headers added from external
  111. calls. Use this if you need to add a header not
  112. covered by To(), From(), ReplyTo() etc. methods
  113. @access private */
  114. var $extra_headers = array();
  115. /** All e-mail headers end up here, apart from To: This
  116. array is a transient place to build all headers
  117. prior to sending the email
  118. @access private */
  119. var $email_headers = array();
  120. /** If !specified use PHP's base64
  121. @access private */
  122. var $base64_func = "";
  123. /** None at this time
  124. @access private */
  125. var $qp_func = "";
  126. /** E-mail body + headers minus From: and Subject:
  127. @access private */
  128. var $content = "";
  129. /** MIME content type for the e-mail
  130. @access private */
  131. var $mimecontenttype = CONTENT_TEXT;
  132. /** MIME boundary marker to use
  133. @access private */
  134. var $mimeboundary = "";
  135. /** character set to use for the e-mail
  136. @access private */
  137. var $charset = DEFAULT_CHARSET;
  138. /** Assembled mime attachments
  139. @access private */
  140. var $mimeparts = array();
  141. //.....................................................................
  142. /**
  143. * Constructor
  144. * Creates the basic email object.
  145. * @param string $from From: email address
  146. * @param string $to To: email address
  147. * @param string $subject Subject line of the e-mail
  148. * @param string $body Body text of the e-mail
  149. * @param string $headers Extra headers to include for this e-mail
  150. * @param string $mimecontenttype Mime content type
  151. * @param string $mimeboundary Pattern designating mime boundary
  152. */
  153. function email(
  154. $from="",
  155. $to="",
  156. $subject="",
  157. $body="",
  158. $headers="",
  159. $mimecontenttype=CONTENT_TEXT,
  160. $mimeboundary=""
  161. ) {
  162. debug_trace($this);
  163. $this->From($from);
  164. $this->To($to);
  165. $this->Subject($subject);
  166. $this->Body($body);
  167.  
  168. // The headers can be passed as an array, or as a
  169. // string of comma-delimited headers..
  170. if (is_array($headers)) {
  171. $this->extra_headers = $headers;
  172. }
  173. elseif ($headers != "") {
  174. $this->extra_headers = explode(",", $headers);
  175. }
  176.  
  177. // MIME settings..
  178. $this->mimeparts[] = "";
  179. $this->mimecontenttype = $mimecontenttype;
  180. if (empty($mimeboundary)) {
  181. $this->mimeboundary = "catit_" . chr(rand(65, 91)) . '------' . md5(uniqid(rand()));
  182. }
  183. else {
  184. $this->mimeboundary = $mimeboundary;
  185. }
  186. debug_trace();
  187. return;
  188. } // email
  189. // .........................................................................
  190. /** Set subject
  191. * Set the e-mail Subject: header
  192. * @param string $subject Subject for this email
  193. */
  194. function Subject($subject) {
  195. $this->subject = $subject;
  196. } // Subject
  197. // .........................................................................
  198. /** Set body
  199. * Set the e-mail body content
  200. * @param string $body Body content for this email
  201. */
  202. function Body($body) {
  203. $this->body = $body;
  204. } // Body
  205. // .........................................................................
  206. /** Set from
  207. * Set the e-mail From: e-mail addresses.
  208. * @param string $from e-mail address e-mail comes from
  209. */
  210. function From($from) {
  211. $this->from = $from;
  212. } // From
  213. // .........................................................................
  214. /** Set replyto
  215. * Set the e-mail ReplyTo: e-mail address.
  216. * @param string $replyto e-mail address recipient replies to
  217. */
  218. function ReplyTo($replyto) {
  219. $this->replyto = $replyto;
  220. } // ReplyTo
  221. // .........................................................................
  222. /** Set to
  223. * Set the e-mail To: e-mail addresses.
  224. * The supplied e-mail addresses can be a comma-delimited list.
  225. * NB: Every time this method is called, addresses are appended.
  226. * @param string $to List of e-mail addresses to send e-mail to
  227. */
  228. function To($to) {
  229. $this->add_array_or_list($to, $this->to);
  230. } // To
  231. // .........................................................................
  232. /** Set copies-to
  233. * Set the e-mail Cc: e-mail addresses for copies to.
  234. * The supplied e-mail addresses can be a comma-delimited list.
  235. * NB: Every time this method is called, addresses are appended.
  236. * @param string $cc List of e-mail addresses to copy e-mail to
  237. */
  238. function Cc($cc) {
  239. $this->add_array_or_list($cc, $this->cc);
  240. } // Cc
  241. // .........................................................................
  242. /** Set blind copies-to
  243. * Set the e-mail Bcc: e-mail addresses for blind copies to.
  244. * The supplied e-mail addresses can be a comma-delimited list.
  245. * NB: Every time this method is called, addresses are appended.
  246. * @param string $bcc List of e-mail addresses to blind copy e-mail to
  247. */
  248. function Bcc($bcc) {
  249. $this->add_array_or_list($bcc, $this->bcc);
  250. } // Bcc
  251. // .........................................................................
  252. /** Add an array or list of email addresses to the given variable
  253. * passed in by reference.
  254. * @param mixed $addrs Array or comma-delimited list of addresses to add
  255. * @param mixed $addrvar Reference to address var to assign addresses
  256. * @access private
  257. */
  258. function add_array_or_list($addrs, &$addrvar) {
  259. if (!is_array($addrs)) {
  260. $newads = explode(",", $addrs);
  261. }
  262. foreach ($newads as $newad) {
  263. if ($newad != "") {
  264. $addrvar[] = $newad;
  265. }
  266. }
  267. } // add_array_or_list
  268. // .........................................................................
  269. /**
  270. * Append new content to the body of the email.
  271. * @param string $content New content to add to the existing email body.
  272. */
  273. function add_content($content) {
  274. $this->body .= $content;
  275. } // add_content
  276. // .........................................................................
  277. /** Set the character set encoding for the email.
  278. * @param string $charset_code Code of the characterset to use for the email
  279. */
  280. function charset($charset_code) {
  281. debug_trace($this);
  282. $this->charset = $charset_code;
  283. debug_trace();
  284. } // charset
  285. // .........................................................................
  286. /**
  287. * Generic function to add a header. We store our headers in an associative
  288. * array, keyed on the proper-cased header name, so we avoid duplicates.
  289. * @param string $header Header to add to e-mail in 'Headername: value' format
  290. * @deprecated the new function extra_header() is now preferred
  291. */
  292. function add_header($header) {
  293. debug_trace($this);
  294. $bits = explode(":", $header);
  295. $header_name = ucfirst(strtolower(trim($bits[0])));
  296. $header_value = trim(trim($bits[1]));
  297. $this->extra_headers[$header_name] = $header_value;
  298. debug_trace();
  299. } // add_header
  300. // .........................................................................
  301. /**
  302. * Generic method to add an extra header. This method is now preferred over
  303. * the depreceted 'add_header()' method above. We store our headers in an
  304. * associative array, keyed on the proper-cased header name.
  305. * @param string $headername Name of the Header to add in this build
  306. * @param string $headervalue Value of the Header to add in this build
  307. */
  308. function extra_header($headername, $headervalue) {
  309. debug_trace($this);
  310. if (trim($headervalue) != "") {
  311. $headername = ucfirst(strtolower($headername));
  312. $this->extra_headers[$headername] = $headervalue;
  313. }
  314. debug_trace();
  315. } // extra_header
  316. // .........................................................................
  317. /**
  318. * Method to build the header array when building the e-mail to send it. We
  319. * store our headers in an associative array, keyed on the header name.
  320. * This method is generally for internal use, and is called every time
  321. * the email is built for sending.
  322. * @param string $headername Name of the Header to add in this build
  323. * @param string $headervalue Value of the Header to add in this build
  324. * @access private
  325. */
  326. function build_header($headername, $headervalue) {
  327. debug_trace($this);
  328. if (trim($headervalue) != "") {
  329. $headername = ucfirst(strtolower($headername));
  330. $this->email_headers[$headername] = $headervalue;
  331. }
  332. debug_trace();
  333. } // build_header
  334. // .........................................................................
  335. /**
  336. * Attaches a 'file' to the e-mail message. Pass a file pathname to attach.
  337. * This function returns a success/failure code/key of current
  338. * attachment in array (+1). @see attach()
  339. * @param string $path Path to the file to attach
  340. * @param string $contenttype Mime content type of this attachment
  341. * @param string $encoding Encoding type for this attachment
  342. * @param string $disp Content disposition
  343. */
  344. function attach_file($path, $description="", $contenttype=CONTENT_OCTET, $encoding=ENC_BASE64, $disp="") {
  345. debug_trace($this);
  346. $this->mimecontenttype = MIXED;
  347. if (!file_exists($path)) {
  348. $this->errors[] = "attach_file: file '$path' does not exist";
  349. return false;
  350. }
  351. // Read in file
  352. $fp = fopen($path, "rb"); # (b)inary for Win compatability
  353. if (!$fp) {
  354. $this->errors[] = "attach_file: could not open '$path' for reading";
  355. return false;
  356. }
  357. $contenttype .= ";\r\n\tname=" . basename($path);
  358. $data = fread($fp, filesize($path));
  359. debug_trace();
  360. return $this->attach($data,
  361. $description,
  362. $contenttype,
  363. $encoding,
  364. $disp
  365. );
  366. } // attach_file
  367. // .........................................................................
  368. /**
  369. * Just a convenient wrapper for adding HTML attachments. Note that with
  370. * this call we are assuming that we are going to be sending an e-mail
  371. * with a plain text and an HTML equivalent. This is why we set the
  372. * MIME content type to "multipart/alternative" here. This can be
  373. * over-ridden using the parameter in the send(0 function.
  374. * @param string $data The HTML data to attach
  375. * @param string $encoding Encoding type for this attachment
  376. */
  377. function attach_html($data, $encoding=ENC_BASE64) {
  378. $this->mimecontenttype = ALTERNATIVE;
  379. return $this->attach_raw(
  380. $data,
  381. "",
  382. CONTENT_HTML,
  383. $encoding
  384. );
  385. } // attach_html
  386. // .........................................................................
  387. /**
  388. * Wrapper for general binary attachments. We assume a MIME content
  389. * type of multipart/mixed for these..
  390. * @param string $data The binary data to attach
  391. * @param string $contenttype Mime content type of this attachment
  392. * @param string $encoding Encoding type for this attachment
  393. * @param string $disp Content disposition
  394. */
  395. function attach($data, $description="", $contenttype=CONTENT_OCTET, $encoding=ENC_BASE64, $disp="") {
  396. $this->mimecontenttype = MIXED;
  397. return $this->attach_raw(
  398. $data,
  399. $description,
  400. $contenttype,
  401. $encoding,
  402. $disp
  403. );
  404. } // attach
  405. // .........................................................................
  406. /** Attach raw
  407. * The raw routine for attaching content to the e-mail. This method is
  408. * used by the other 'friendlier' attachment methods.
  409. * @param string $data The binary data to attach
  410. * @param string $description Forms the content-description header
  411. * @param string $contenttype Mime content type of this attachment
  412. * @param string $encoding Encoding type for this attachment
  413. * @param string $disp Content disposition
  414. * @access private
  415. */
  416. function attach_raw($data, $description="", $contenttype=CONTENT_OCTET, $encoding=ENC_BASE64, $disp="") {
  417. if (empty($data)) {
  418. $this->errors[] = "attach_raw: no data to be attached";
  419. return false;
  420. }
  421. // Handle default encodings..
  422. if (trim($contenttype) == "") $contenttype = OCTET;
  423. if (trim($encoding) == "") $encoding = ENC_BASE64;
  424.  
  425. // Ascii text 7-Bit standard..
  426. if ($encoding == ENC_BIT7) {
  427. $emsg = $data;
  428. }
  429. // User-defined function..
  430. elseif ($encoding == ENC_QUOTP) {
  431. $emsg = $$this->qp_func($data);
  432. }
  433. // Good ol' Base-64..
  434. elseif ($encoding == ENC_BASE64) {
  435. // Check if there is user-defined function..
  436. if (!$this->base64_func) {
  437. $emsg = base64_encode($data);
  438. }
  439. else {
  440. $emsg = $$this->base64_func($data);
  441. }
  442. // Splits data stream into 76 char lines
  443. // to fit RFC2045 semantics..
  444. $emsg = chunk_split($emsg);
  445. }
  446.  
  447. //Check if content-type is text/plain and if charset is not specified append default CHARSET
  448. if (strstr($contenttype, CONTENT_TEXT) && !strstr(contenttype, "/;charset=/i")) {
  449. $contenttype .= ";\r\n\tcharset=" . $this->charset;
  450. }
  451. $msg = "";
  452. $msg .= "Content-Type: $contenttype" . CRLF;
  453. $msg .= "Content-Transfer-Encoding: $encoding" . CRLF;
  454. if ($disp != "") {
  455. $msg .= "Content-Disposition: $disp";
  456. if ($description != "") {
  457. $msg .= "; filename=\"$description\"";
  458. }
  459. $msg .= CRLF;
  460. }
  461. elseif ($description != "" && BODY != $description) {
  462. $msg .= "Content-Description: $description" . CRLF;
  463. }
  464. $msg .= CRLF . $emsg . CRLF;
  465. BODY == $description ? $this->mimeparts[0] = $msg : $this->mimeparts[] = $msg;
  466.  
  467. return count($this->mimeparts);
  468. } // attach_raw
  469. // .........................................................................
  470. /**
  471. * Build the message body.
  472. * Construct mail message body and any MIME attachments. This also includes
  473. * assignment of the relevant headers, depending on the attachments which
  474. * have been defined (or not).
  475. * @access private
  476. */
  477. function build_body() {
  478. debug_trace($this);
  479. $msg = "";
  480. $nparts = count($this->mimeparts);
  481.  
  482. // Case 1: Attachment list is there. Therefore MIME Message header must have multipart/mixed
  483. if (is_array($this->mimeparts) && ($nparts > 1)) {
  484. $this->build_header("MIME-Version", "1.0");
  485. $this->build_header("Content-Type", "$this->mimecontenttype;" . CRLF . "\tboundary=\"$this->mimeboundary\"");
  486. $this->build_header("Content-Transfer-Encoding", ENC_BIT7);
  487. $msg .= CRLF . MIME_WARNING . CRLF . CRLF ;
  488.  
  489. // Since we are here, it means we do have attachments and
  490. // the body must become an attachment too..
  491. if (!empty($this->body)) {
  492. $this->attach($this->body, BODY, CONTENT_TEXT, ENC_BIT7);
  493. }
  494. // Now create the MIME parts of the email
  495. foreach ($this->mimeparts as $mimepart) {
  496. if (!empty($mimepart)) {
  497. $msg .= CRLF . '--' . $this->mimeboundary . CRLF . $mimepart . CRLF;
  498. }
  499. }
  500. $msg .= "--" . $this->mimeboundary . "--" . CRLF;
  501. }
  502. else {
  503. $this->build_header("Content-Type", "$this->mimecontenttype;" . CRLF . "\tcharset=" . $this->charset);
  504. if (!empty($this->body)) {
  505. $msg .= CRLF . $this->body . CRLF . CRLF;
  506. }
  507. }
  508. debug_trace();
  509. return $msg;
  510. } // build_body
  511. // .........................................................................
  512. /**
  513. * Generate message content
  514. * Now Generate the entire Mail Message, header and body et al.
  515. * Note that this leaves out the To: and Subject: which are passed
  516. * as separate parameters when mailing the e-mail with 'mail()'.
  517. * @return string The full email content including headers and body
  518. * @access private
  519. */
  520. function generate_content() {
  521. $this->email_headers = $this->extra_headers;
  522. if (empty($this->subject)) {
  523. $this->subject = NOSUBJECT;
  524. }
  525. if (!empty($this->from)) {
  526. $this->build_header("From", $this->from);
  527. }
  528. if (!empty($this->replyto)) {
  529. $this->build_header("ReplyTo", $this->replyto);
  530. }
  531. if (is_array($this->cc) && count($this->cc) > 0) {
  532. $this->build_header("Cc", implode(",", $this->cc));
  533. }
  534. if (is_array($this->bcc) && count($this->bcc) > 0) {
  535. $this->build_header("Bcc", implode(",", $this->bcc));
  536. }
  537. $this->build_header("X-Mailer", "Catalyst-IT/AXYL");
  538. $this->content = $this->build_body();
  539. return $this->content;
  540. } // generate_content
  541. // .........................................................................
  542. /**
  543. * Return Printable Content
  544. * Returns a printable version of the e-mail. Just returns the content
  545. * as well as all the headers, and if for HTML, then it wraps it all in
  546. * some (pre) tags. Useful for debugging.
  547. * @param string $format Format of output, either 'text' (default) or 'html'
  548. */
  549. function printable($format="text") {
  550. $email = $this->generate_content();
  551. $eol = "\n";
  552. $email = "";
  553. $email .= "Subject: $this->subject" . $eol;
  554. $email .= "To: " . implode(",", $this->to) . $eol;
  555. $headers = array();
  556. foreach ($this->email_headers as $headername => $headervalue) {
  557. $headers[] = "$headername: $headervalue";
  558. }
  559. $email .= implode($eol, $headers);
  560. $email .= $this->content;
  561. if ($format == "html") {
  562. $email = "<pre>$email</pre>";
  563. }
  564. return $email;
  565. } // printable
  566. // .........................................................................
  567. /**
  568. * Return error messages. These may have accumulated during the email
  569. * assembly or during the send process.
  570. * @return string Error message(s) which have accumulated.
  571. */
  572. function error_message() {
  573. $errmsg = "";
  574. if (count($this->errors) > 0) {
  575. foreach ($this->errors as $err) {
  576. $errmsg .= "$err\n";
  577. }
  578. }
  579. return $errmsg;
  580. } // error_message
  581. // .........................................................................
  582. /**
  583. * Send the email
  584. * Send mail via local mailer. This is usually the end-result of
  585. * an e-mail sequence and results in the e-mail being sent.
  586. * @param string $mimecontenttype Override for the email MIME content type
  587. * @param string $charset Override for the email character set
  588. * @return boolean True if email was sent successfully
  589. */
  590. function send($mimecontenttype="", $charset="") {
  591. debug_trace($this);
  592. $sentok = false;
  593.  
  594. // Allow them to set MIME content type late..
  595. if ($mimecontenttype != "") {
  596. $this->mimecontenttype = $mimecontenttype;
  597. }
  598. $this->generate_content();
  599. // Must have a To address..
  600. if (count($this->to) == 0) {
  601. $this->errors[] = "send: To: header was not specified";
  602. return false;
  603. }
  604. // Unfurl all the headers..
  605. $headers = array();
  606. foreach ($this->email_headers as $headername => $headervalue) {
  607. $headers[] = "$headername: $headervalue";
  608. }
  609.  
  610. // Send the e-mail on its way..
  611. if (!empty($this->from)) {
  612. // The -f parameter sets who the mail is from, by setting the email
  613. // address on the 'envelope' of the mail. This can only be done by a
  614. // user 'trusted' by sendmail, so make sure the user the webserver
  615. // runs as (eg. www-data) is marked as trusted in this way.
  616. $sentok = mail(
  617. implode(",", $this->to),
  618. $this->subject,
  619. $this->content,
  620. implode(CRLF, $headers),
  621. "-f$this->from"
  622. );
  623. }
  624. else {
  625. $sentok = mail(
  626. implode(",", $this->to),
  627. $this->subject,
  628. $this->content,
  629. implode(CRLF, $headers)
  630. );
  631. }
  632. // Debug output..
  633. if (debugging()) {
  634. debugbr( $this->printable("html"), DBG_DUMP );
  635. }
  636. debug_trace();
  637. if (!$sentok) {
  638. $this->errors[] = "send: mail() function returned fail status";
  639. }
  640. return $sentok;
  641. } // send
  642.  
  643. } // Class email
  644. // -------------------------------------------------------------------------
  645.  
  646. /**
  647. * Function to send an email using the simple Php mail() call. This is a
  648. * very simplistic wrapper which is kept for its cuteness, but for no
  649. * other reason than that.
  650. * @param string $eto The To: email address
  651. * @param string $efrom The From: email address
  652. * @param string $esubject The Subject: line
  653. * @param string $ebody The email body content
  654. * @param string $emailformat Format of e-mail 'plain', 'html' or 'mixed'
  655. * @param string $mime_boundary The mime boundary pattern
  656. */
  657. function emailthem($eto, $eCc, $efrom, $esubject, $ebody, $emailformat="plain", $mime_boundary="") {
  658. $headers = "From: $efrom\n";
  659. if ($eCc != "") $headers .= "Cc: $eCc\n";
  660. $headers .= "Reply-To: $efrom\n";
  661. $headers .= "Errors-To: $efrom\n";
  662.  
  663. switch ($emailformat) {
  664. case "html":
  665. $headers .= "Content-Type: text/html\n";
  666. break;
  667. case "plain":
  668. $headers .= "Content-Type: text/plain\n";
  669. break;
  670. case "mixed":
  671. $headers .= "MIME-Version: 1.0\n";
  672. $headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n";
  673. break;
  674. default:
  675. $headers .= "Content-Type: text/plain\n";
  676. } // switch
  677.  
  678. $headers .= "X-Mailer: PHP/" . phpversion();
  679. mail($eto, $esubject, $ebody, $headers);
  680. } // emailthem
  681. // -------------------------------------------------------------------------
  682.  
  683. /**
  684. * Make a 'friendly' name from a full one. Good for "Dear... ,"
  685. * @param string $fullname The full name to make a friendly version of
  686. * @return string The friendly name
  687. */
  688. function friendlyName($fullname) {
  689. $splitname = explode(" ", $fullname);
  690. $mate = trim($splitname[0]);
  691. if ($mate == "") $mate = $fullname;
  692. return $mate;
  693. } // friendlyName
  694. // -------------------------------------------------------------------------
  695.  
  696. ?>

Documentation generated by phpDocumentor 1.3.0RC3