Well, I've never used pear to send email, but here's my stab at it anyway.
- To send to addresses via cc or bcc, you simply have to add these headers to your message. With pear you just add it in your send line. I'll modify the example from pear's website slightly to illustrate.
<?php
include('Mail.php');
$recipients = 'joe@example.com';
$headers['From'] = 'richard@example.com';
$headers['To'] = 'joe@example.com';
$headers['BCC'] = 'boss@example.com'; // Send a copy to the boss secretly.
$headers['Subject'] = 'Test message';
$body = 'Test message';
$params['sendmail_path'] = '/usr/lib/sendmail';
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory('sendmail', $params);
$mail_object->send($recipients, $headers, $body);
?>
To send an attachment you should use the Mail_Mime pear class. And example can be found here.
The factory method will let you select smtp or sendmail. The example above uses sendmail. Here's one using smtp.
$params['host'] = '192.168.100.201'; // Internal smtp server
$params['auth'] = true; // Use smtp auth
$params['username'] = 'phpuser';
$params['password'] = 'secret';
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory('smtp', $params);
- Setting the priority is just a matter of setting more headers. In theory the only header you have to set is "X-Priority", where 1 is highest, 3 is normal, and 5 is lowest. I understand microsoft outlook sets two additional headers, "X-MSMail-Priority" and "Importance", both with a value of "High". Can't hurt to set these two extra headers, so you might as well. I assume the first example is adequate to demonstrate setting headers.