Re: Mail and attachments

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Miles Beck
Date:  
To: Main PLUG discussion list
Subject: Re: Mail and attachments
On 8/19/06, Alex Dean <> wrote:
> If you have PHP available, you could try the following. It requires
> the HTMLMimeMail class from phpguru.org. http://www.phpguru.org/
> static/mime.mail.html That's the PHP4 version. There's a rewritten
> version that takes advantage of the new PHP5 object model, but most
> shared hosts are still using PHP4 (unfortunately).
>
> I just bashed this out, so there may be typos, but it should be
> something to get started with. I've used the htmlMimeMail class in
> several projects and it works very well. This won't work well with
> large files, since the file will be read into memory before being sent.


Hm, I tried using the script and it hangs when I execute it. I'm not
sure I filled everything out the way it should be. Below is the script
as I filled it out. One thing to note, I am using $date so I can name
the file with the current date. Can this be used in your script? I've
added it to the beginning of the script.

DATE=`date +%Y%m%d`
# /usr/local/bin/php -q
php -q
<?
require_once 'htmlMimeMail.class.php';

// add as many recipients as you want
$to = array('');

$mail =& new htmlMimeMail();
$attachment = $mail->getFile('/home/bluntmon/$DATE-dailybackup.tgz');
$mail->addAttachment($attachment,'filename','mime/type');
$mail->setText('');
$mail->setFrom('');
$mail->setSubject('$DATE Daily Backup');
$result = $mail->send($to);

// simple check to see that mail was accepted for delivery
if($result) {
// ok
exit(0);
} else {
// something went wrong
exit(1);
}
?>
---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss