本文整理汇总了PHP中Mail_mimePart::encodeToFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Mail_mimePart::encodeToFile方法的具体用法?PHP Mail_mimePart::encodeToFile怎么用?PHP Mail_mimePart::encodeToFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mail_mimePart
的用法示例。
在下文中一共展示了Mail_mimePart::encodeToFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Builds the multipart message.
*
* @param array $params Build parameters that change the way the email
* is built. Should be associative. See $_build_params.
* @param resource $filename Output file where to save the message instead of
* returning it
* @param boolean $skip_head True if you want to return/save only the message
* without headers
*
* @return mixed The MIME message content string, null or PEAR error object
*/
public function get($params = null, $filename = null, $skip_head = false)
{
if (isset($params)) {
while (list($key, $value) = each($params)) {
$this->build_params[$key] = $value;
}
}
$this->checkParams();
if ($this->type == self::PGP_SIGNED) {
$params = array('preamble' => "This is an OpenPGP/MIME signed message (RFC 4880 and 3156)", 'content_type' => "multipart/signed; micalg=pgp-sha1; protocol=\"application/pgp-signature\"", 'eol' => $this->build_params['eol']);
$message = new Mail_mimePart('', $params);
if (!empty($this->body)) {
$headers = $this->message->headers();
$params = array('content_type' => $headers['Content-Type']);
if ($headers['Content-Transfer-Encoding']) {
$params['encoding'] = $headers['Content-Transfer-Encoding'];
}
$message->addSubpart($this->body, $params);
}
if (!empty($this->signature)) {
$message->addSubpart($this->signature, array('filename' => 'signature.asc', 'content_type' => 'application/pgp-signature', 'disposition' => 'attachment', 'description' => 'OpenPGP digital signature'));
}
} else {
if ($this->type == self::PGP_ENCRYPTED) {
$params = array('preamble' => "This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)", 'content_type' => "multipart/encrypted; protocol=\"application/pgp-encrypted\"", 'eol' => $this->build_params['eol']);
$message = new Mail_mimePart('', $params);
$message->addSubpart('Version: 1', array('content_type' => 'application/pgp-encrypted', 'description' => 'PGP/MIME version identification'));
$message->addSubpart($this->encrypted, array('content_type' => 'application/octet-stream', 'description' => 'PGP/MIME encrypted message', 'disposition' => 'inline', 'filename' => 'encrypted.asc'));
}
}
// Use saved boundary
if (!empty($this->build_params['boundary'])) {
$boundary = $this->build_params['boundary'];
} else {
$boundary = null;
}
// Write output to file
if ($filename) {
// Append mimePart message headers and body into file
$headers = $message->encodeToFile($filename, $boundary, $skip_head);
if ($this->isError($headers)) {
return $headers;
}
$this->headers = array_merge($this->headers, $headers);
return null;
} else {
$output = $message->encode($boundary, $skip_head);
if ($this->isError($output)) {
return $output;
}
$this->headers = array_merge($this->headers, $output['headers']);
return $output['body'];
}
}