That file doesn't exist. Is the path correct "/etc/valiase/mydomain.com"? Or should I create a new one to put that code in it?
Typo alart!
The file resides in /etc/valiases/ (I missed an "s"). If you do not have such a file, simply add a filter in cPanel. You will then have the file in /etc/valiases that you can overwrite as neeeded.
Is there any specific part of that MAIL pear package that I need to look at? I find the PEAR library in general quite a bloated one (which serves the purpose it is meant for, I guess) so I wouldn't want to install the whole thing.
Maybe it's bloated, maybe it's just very comprehensive. It's a matter of opinion
The PEAR packages are generally small smiles; it will not really hurt of you install a few packages that you do not really need.
Mail_mimeDecode is the package you want to use. Below is an example; it is an abstract from an actual script we use. I do not suggest that it is the best way of doing things or that the script is complete. Please test and use at your own risk 
PHP Code:
// Mail_mimeDecode example by Stephen @ ANNO
// Read the piped message
$pipe = fopen('php://stdin', 'r');
while (!feof($pipe)) {
$buffer = fgets($pipe, 4096);
$input.= $buffer;
}
fclose($pipe);
// DeMIME with Pear packages
$params['include_bodies'] = true;
$params['decode_bodies'] = true;
$params['decode_headers'] = true;
$params['input'] = $input;
$structure = Mail_mimeDecode::decode($params);
// Message headers
$mail_from = strip_address($structure->headers['from']);
$mail_return = strip_address($structure->headers['return-path']);
$mail_to = strip_address($structure->headers['to']);
$mail_date = $structure->headers['date'];
$mail_delivered = $structure->headers['delivery-date'];
$mail_subject = $structure->headers['subject'];
// Check message format
if ( ($structure->ctype_primary=='text') and ($structure->ctype_secondary=='plain') )
$mail_body = $structure->body;
elseif (isset($structure->parts)) { // HTML email; get plain text part
foreach ($structure->parts as $part) {
if ( (isset($part->body)) and ($part->ctype_primary=="text") and ($part->ctype_secondary=="plain") )
$mail_body = $part->body;
} // end foreach
} // end elseif
To pipe the email into this script, set up forwarder for the relevant email address to
Code:
|/usr/bin/php -q /home/username/pipescript.php >/dev/null 2>&1