You are here

function PHPMailer::EncodeFile in SMTP Authentication Support 5

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

Encodes attachment in requested format. Returns an empty string on failure. @access private

Return value

string

1 call to PHPMailer::EncodeFile()
PHPMailer::AttachAll in ./smtp.module
Attaches all fs, string, and binary attachments to the message. Returns an empty string on failure. @access private

File

./smtp.module, line 1558
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 EncodeFile($path, $encoding = "base64") {
  if (!@($fd = fopen($path, "rb"))) {
    $this
      ->SetError($this
      ->Lang("file_open") . $path);
    return "";
  }
  $magic_quotes = get_magic_quotes_runtime();
  set_magic_quotes_runtime(0);
  $file_buffer = fread($fd, filesize($path));
  $file_buffer = $this
    ->EncodeString($file_buffer, $encoding);
  fclose($fd);
  set_magic_quotes_runtime($magic_quotes);
  return $file_buffer;
}