RE: [PHP-DB] Attachment
Can you explain more to me about RFC1341? Please tell me where can I get more info about this function? Actually what I want is to send a mail with a list of attachment files. Thanks. -Original Message- From: Patrice Garbe [SMTP:[EMAIL PROTECTED]] Sent: Thursday, August 09, 2001 7:42 PM To: WNLeong Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Attachment You must look at the RFC1341 (if you have not already did so) to learn about mime types. It is also very useful to send (you) messages with attached files and the look at the source. A tip : to send you own forged mail you must use the mail() function like this : maiil($to,$subject,,$your_forged_content); If you don't want to develop your own solution look at www.freshmeat.net, I'm sure you will find something. That's it ! Patrice Le jeu, 09 aoû 2001, vous avez écrit : I would like to send attachment file through mail by using php. Please help me.!! Thanks. Wen Ni Leong -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Attachment
I have actually done several projects with different kinds or e-mailing features. In a nutshell, you need the appropriate MIME headers for the type of mail, and sections of body divided by MIME Boundaries. (You also need to encode any files you are sending as attachments. Check the base64_encode function at php.net for this) RFC1341 and the revised version: RFC1521 give you all the specifics you need to do this in almost any situation. I would suggest skimming through 1521, paying special attention to the section on Multipart/Mixed (as that is what you would usually use for an e-mail with attachments) I would also suggest sending yourself a couple of e-mails with attachments, and then telneting to your mail server and viewing them there. Doing this has probably helped more more than anything when working on a complex mail program. Don't reinvent the wheel, see how the other guys made theirs =P If you have any specific questions let me know. Sheridan Saint-Michel Website Administrator FoxJet, an ITW Company www.foxjet.com - Original Message - From: WNLeong [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, August 10, 2001 2:55 AM Subject: RE: [PHP-DB] Attachment Can you explain more to me about RFC1341? Please tell me where can I get more info about this function? Actually what I want is to send a mail with a list of attachment files. Thanks. -Original Message- From: Patrice Garbe [SMTP:[EMAIL PROTECTED]] Sent: Thursday, August 09, 2001 7:42 PM To: WNLeong Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Attachment You must look at the RFC1341 (if you have not already did so) to learn about mime types. It is also very useful to send (you) messages with attached files and the look at the source. A tip : to send you own forged mail you must use the mail() function like this : maiil($to,$subject,,$your_forged_content); If you don't want to develop your own solution look at www.freshmeat.net, I'm sure you will find something. That's it ! Patrice Le jeu, 09 aoû 2001, vous avez écrit : I would like to send attachment file through mail by using php. Please help me.!! Thanks. Wen Ni Leong -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Attachment
You must look at the RFC1341 (if you have not already did so) to learn about mime types. It is also very useful to send (you) messages with attached files and the look at the source. A tip : to send you own forged mail you must use the mail() function like this : maiil($to,$subject,,$your_forged_content); If you don't want to develop your own solution look at www.freshmeat.net, I'm sure you will find something. That's it ! Patrice Le jeu, 09 aoû 2001, vous avez écrit : I would like to send attachment file through mail by using php. Please help me.!! Thanks. Wen Ni Leong -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Attachment
First of all. Take a look at MIME tutorial @ http://www.zend.com its great.. read all 3. i wrote a perl script after that tutorial.. it attach a .log file.. take a look im 100% sure you can port it to php using mail() function just build up $header and insert into the function. - #!/usr/bin/perl use strict; use MIME::Base64; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time + 0 * 24 * 60 * 60); $year += 1900; $mon++; if ($mday 10) { $mday = 0$mday; } if ($mon 10) { $mon = 0$mon; } my $baseDir = /home/mysqlBackup; my $baseFileName = mysql-$year-$mon-$mday; # mysql--mm-dd.tar(.gz) my $backupFile = $baseFileName.tar; my $backupFileType = application/octet-stream; # mysql--mm-dd.log my $logFile = $baseFileName.log; my $logFileType =text/plain; # Where mysql database are located. my $DBFileDir = /var/lib/mysql; doBackup($baseDir/$logFile, $baseDir/$backupFile, $DBFileDir); my $encBackupFile = _encodeFile($baseDir/$backupFile.gz); my $encLogFile = _encodeFile($baseDir/$logFile); sendMail( Backup completed ($year-$mon-$mday) , admin\@sineleven.nu , $logFile , $logFileType , $encLogFile ); sub sendMail { my ($subject, $to, $File, $FileType, $Base64) = @_; my $priority = normal; my $mailprog = /usr/local/bin/sendmail; my $mime_text = This part of the E-mail should never be seen. If you ar e reading this, consider upgrading your e-mail client to a MIME-compatible clien t.\n; if ($to ne ) { my $status = open (MAIL,|$mailprog -t); if ($status) { print MAIL To: $to\n; print MAIL Subject: $subject\n; print MAIL Importance: $priority\n; print MAIL MIME-Version: 1.0\n; print MAIL Content-Type: multipart/mixed;\n\tboundary=\ ZEND-12345\;; print MAIL $mime_text\n; print MAIL --ZEND-12345\n; print MAIL Content-Type: text/plain;\n\n; print MAIL Backup on sineleven.nu completed.\n\nFiles a re located at /home/mysqlBackup\n\nLook at attached logfile for info\n; print MAIL --ZEND-12345\n; print MAIL Content-Type: $FileType;\n\tname=\$File\\n ; print MAIL Content-Transfer-Encoding: base64\n; print MAIL Content-Disposition: attachment\n\tfilename= \$File\\n\n; print MAIL $Base64\n; print MAIL --ZEND-12345--\n; close(MAIL); } } } sub doBackup { my ($logFile, $backupFile, $backupDir) = @_; `tar cvvf $backupFile $backupDir $logFile`; `gzip $backupFile`; `chmod 400 $logFile $backupFile.gz`; } sub _encodeFile { my ($file) = @_; my ($buf, $encoded); open(FILE, $file) or die $!; while (read(FILE, $buf, 60*57)) { $encoded.= encode_base64($buf); } return $encoded; } /Mattias aka BoNzO http://bonzo.sineleven.nu -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]