I'm just amending someone else's code to do that at the moment.
function out($fptr,$s)
{
if ($fptr==false) echo("$s");
else fputs($fptr,$s);
}
function mysqlbackup($host,$dbname, $uid, $pwd, $output, $structure_only)
{
//from [url]http://codewalkers.com/seecode/46.html[/url]
$sendSave = false;
if (strval($output)!="")
{
if ($output == "email")
{
$fptr = fopen("bup/bupemail.txt","w");
$sendSave = true;
}
else $fptr=fopen($output,"w");
}
else $fptr=false;
// lots more code which calls a function called out() - see above
//close the file if we aren't echoing
if ($fptr!=false)
{
fclose($fptr);
// do we need to email it?
if ($sendSave == true)
{
include('includes/class.html.mime.mail.inc');
$mail = new html_mime_mail('X-Mailer: Html Mime Mail Class');
$body = "<h3>Attachment</h3><p>MySite</p></body></html>";
$text = strip_tags ($body , "a");
$attachment = fread($fp = fopen($fptr, 'r'), filesize($fname));
fclose($fp);
$mail->add_html($body, $text);
$mail->set_charset('iso-8859-1', TRUE);
$mail->add_attachment($attachment, $filename, 'application/octet-stream');
$mail->build_message();
$email = "support@mysite.com";
$mail->send($email, $email, 'MySite', $email, $filename . " from [url]http://www.mysite.com[/url]");
//should also delete the file! here, code to be written
}//end of email file check
}//end of close file check
I haven't put the delete bit in yet but once it's attached it can be deleted. I haven't finished testing either.
good luck