Mail_Mime::setTxtBody() – set plain text part


require_once 'Mail/mime.php';

boolean setTxtBody ( string $data , boolean $isfile = false )


Sets the plain text part of a message


  • string $data - The text to set or, if $isfile is TRUE a valid filename. An URL as argument is not allowed.

  • boolean $isfile - If TRUE, the content of given file $data is used as message text.

Return value

boolean - Returns TRUE on success, PEAR_Error on failure.


Possible PEAR_Error values
Error code Error message Reason Solution
NULL "File is not readable file_name" The file was not found or the script has not enough rights to access the file. Check the file name and path. Check user and file permissions.
NULL "Could not open file_name" The file is already opened and exclusivly locked by another application. In the most cases a programm opens the file for writing. setTxtBody() does no file locking, so this problem is not caused by competitve callings of this function.


This function can not be called statically.

set HTML part (Previous) encode header value (Next)
Last updated: Fri, 27 Nov 2015 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

Note by:
this is what everyone want to know.
update document asap.

@param string $data Either a string or the file name with the contents
@param bool $isfile If true the first param should be treated
as a file name, else as a string (default)
@param bool $append If true the text or file is appended to
the existing body, else the old body is

@return mixed True on success or PEAR_Error object