You are here

function PHPMailer::AddrFormat in SMTP Authentication Support 5

Same name and namespace in other branches
  1. 7.2 smtp.phpmailer.inc \PHPMailer::AddrFormat()
  2. 7 smtp.phpmailer.inc \PHPMailer::AddrFormat()

Formats an address correctly. @access private

Return value

string

1 call to PHPMailer::AddrFormat()
PHPMailer::AddrAppend in ./smtp.module
Creates recipient headers. @access private

File

./smtp.module, line 1090
Enables drupal to send email directly to an SMTP server using authentication. Uses the PHPMailer class by Brent R. Matzelle.

Class

PHPMailer
PHPMailer - PHP email transport class @package PHPMailer @author Brent R. Matzelle @copyright 2001 - 2003 Brent R. Matzelle

Code

function AddrFormat($addr) {
  if (empty($addr[1])) {
    $formatted = $addr[0];
  }
  else {

    // If the from address already contains a name and address, as indicated
    // by the angle brackets, then ignore the FromName and simply use
    // the From field as it was provided.  This allows per-call override
    // of the From field when using the smtp module, important to modules
    // such as OG
    if (strpos($addr[0], "<") !== false && strpos($addr[0], ">") !== false) {
      $formatted = $addr[0];
    }
    else {
      $formatted = $this
        ->EncodeHeader($addr[1], 'phrase') . " <" . $addr[0] . ">";
    }
  }
  return $formatted;
}