Re: [PHP] mail() with mailing lists problem
Rudolph, Mail() is v.finicky! Windows machines need more than the \n - what are you running? Have you tried putting some string of characters into the (text) msg body? Can you send us a copy of the actual email msg showing the headers etc (output as received at the POP/IMAP server) - after clipping all/most of the encoded contents please? =dn - Original Message - From: "Rudolf Visagie" <[EMAIL PROTECTED]> To: "TD - Sales International Holland B.V." <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: 13 November 2001 08:40 Subject: RE: [PHP] mail() with mailing lists problem > True. I had the attachment outside of the function (encoding once) but this > is a leftover of debugging and trying to get it to work. I hadn't thought of > Bcc-ing everybody. I'll try that, thanks. Still doesn't solve the problem, > though. Maybe a socket is the answer. > > -Original Message- > From: TD - Sales International Holland B.V. [mailto:[EMAIL PROTECTED]] > Sent: 12 November 2001 04:15 > To: Rudolf Visagie > Subject: Re: [PHP] mail() with mailing lists problem > > > If you send the same message over and over wouldn't it be a LOT wiser to BCC > > the rest of the people? This way you are MIME-encoding the attachment over > and over which consumes a lot of resources. MIME-encoding a 10MB file will > suck up a P-III 600 for 20 to 30 secs or so depending on other background > processes and diskspeed. MIME encoding the same attachment a 1000 times > doesn't appear really fast to me. Also, with all the headers you use, you > could just as well open a socket to the SMTP service, then you could have > additional error checking I guess... > > > Just some thoughts.. > > regards > > On Monday 12 November 2001 13:47, you wrote: > > Hi All, > > > > While everybody is on this topic, here's a problem I have been having. I > > use mail() in a function in a loop to send e-mail with an attachment. The > > e-mails get sent out to the different recipients but only the last one > gets > > sent correctly. The rest loses the 'From:' somewhere so that the message > > ends up with the server name as from who and with the encoded attachment > > inside of the message body. Here's the function: > > > > function mail_attachment ($to, $subject, $message, $addr_from, > $attachment, > > $filename) { > > > > /* > > This function sends an e-mail with a file attachment using the > > standard > > PHP mail function with parameters $to, $subject and $message. > > The $attachment parameter is a string with the attachment file > > content with > > filename $filename. > > */ > > > > $boundary = "b".md5(uniqid(time())); > > $mime = "From: $addr_from\n"; > > $mime .= "Reply-To: $addr_from\n"; > > $mime .= "X-Mailer: Digital Healthcare Solutions\n"; > > $mime .= "X-Sender: $addr_from\n"; > > $mime .= "Content-type: multipart/mixed; "; > > $mime .= "boundary = $boundary\n\n"; > > $mime .= "This is a MIME encoded message.\n\n"; > > // First the regular message > > $mime .= "--$boundary\n"; > > $mime .= "Content-type: text/plain\n"; > > $mime .= "Content-Transfer-Encoding: base64"; > > $mime .= "\n\n".chunk_split(base64_encode($message))."\n"; > > // Now the attachment > > $mime .= "--$boundary\n"; > > $mime .= "Content-type: text/plain\n"; > > $mime .= "Content-Transfer-Encoding: base64\n"; > > $mime .= "Content-Disposition: attachment; "; > > $mime .= "filename = ".chr(34).$filename.chr(34); > > $mime .= "\n\n".chunk_split(base64_encode($attachment))."\n"; > > $mime .= "--$boundary--"; > > > > mail ($to, $subject, "", $mime); > > } > > > > and here's the loop in which it gets called: > > > > $i = 0; > > while (isset($EmailAddress[$i])) { > > mail_attachment ($EmailAddress[$i], "URGENT Communication", > > $message, $addr_from, $attachment, $filename); > > $i++; > > } > > > > Does anybody have any ideas? > > > > Rudolf Visagie > > Principal Software Developer > > Digital Healthcare Solutions > > Tel. +27(0)11 266 6946 > > Fax. +27(0)11 266 5080 > > Cell: +27(0)82 895 1598 > > E-mail: [EMAIL PROTECTED] > > -- > PHP General 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 General 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] mail() with mailing lists problem
True. I had the attachment outside of the function (encoding once) but this is a leftover of debugging and trying to get it to work. I hadn't thought of Bcc-ing everybody. I'll try that, thanks. Still doesn't solve the problem, though. Maybe a socket is the answer. -Original Message- From: TD - Sales International Holland B.V. [mailto:[EMAIL PROTECTED]] Sent: 12 November 2001 04:15 To: Rudolf Visagie Subject: Re: [PHP] mail() with mailing lists problem If you send the same message over and over wouldn't it be a LOT wiser to BCC the rest of the people? This way you are MIME-encoding the attachment over and over which consumes a lot of resources. MIME-encoding a 10MB file will suck up a P-III 600 for 20 to 30 secs or so depending on other background processes and diskspeed. MIME encoding the same attachment a 1000 times doesn't appear really fast to me. Also, with all the headers you use, you could just as well open a socket to the SMTP service, then you could have additional error checking I guess... Just some thoughts.. regards On Monday 12 November 2001 13:47, you wrote: > Hi All, > > While everybody is on this topic, here's a problem I have been having. I > use mail() in a function in a loop to send e-mail with an attachment. The > e-mails get sent out to the different recipients but only the last one gets > sent correctly. The rest loses the 'From:' somewhere so that the message > ends up with the server name as from who and with the encoded attachment > inside of the message body. Here's the function: > > function mail_attachment ($to, $subject, $message, $addr_from, $attachment, > $filename) { > > /* > This function sends an e-mail with a file attachment using the > standard > PHP mail function with parameters $to, $subject and $message. > The $attachment parameter is a string with the attachment file > content with > filename $filename. > */ > > $boundary = "b".md5(uniqid(time())); > $mime = "From: $addr_from\n"; > $mime .= "Reply-To: $addr_from\n"; > $mime .= "X-Mailer: Digital Healthcare Solutions\n"; > $mime .= "X-Sender: $addr_from\n"; > $mime .= "Content-type: multipart/mixed; "; > $mime .= "boundary = $boundary\n\n"; > $mime .= "This is a MIME encoded message.\n\n"; > // First the regular message > $mime .= "--$boundary\n"; > $mime .= "Content-type: text/plain\n"; > $mime .= "Content-Transfer-Encoding: base64"; > $mime .= "\n\n".chunk_split(base64_encode($message))."\n"; > // Now the attachment > $mime .= "--$boundary\n"; > $mime .= "Content-type: text/plain\n"; > $mime .= "Content-Transfer-Encoding: base64\n"; > $mime .= "Content-Disposition: attachment; "; > $mime .= "filename = ".chr(34).$filename.chr(34); > $mime .= "\n\n".chunk_split(base64_encode($attachment))."\n"; > $mime .= "--$boundary--"; > > mail ($to, $subject, "", $mime); > } > > and here's the loop in which it gets called: > > $i = 0; > while (isset($EmailAddress[$i])) { > mail_attachment ($EmailAddress[$i], "URGENT Communication", > $message, $addr_from, $attachment, $filename); > $i++; > } > > Does anybody have any ideas? > > Rudolf Visagie > Principal Software Developer > Digital Healthcare Solutions > Tel. +27(0)11 266 6946 > Fax. +27(0)11 266 5080 > Cell: +27(0)82 895 1598 > E-mail: [EMAIL PROTECTED] -- PHP General 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] mail() with mailing lists problem
Hi All, While everybody is on this topic, here's a problem I have been having. I use mail() in a function in a loop to send e-mail with an attachment. The e-mails get sent out to the different recipients but only the last one gets sent correctly. The rest loses the 'From:' somewhere so that the message ends up with the server name as from who and with the encoded attachment inside of the message body. Here's the function: function mail_attachment ($to, $subject, $message, $addr_from, $attachment, $filename) { /* This function sends an e-mail with a file attachment using the standard PHP mail function with parameters $to, $subject and $message. The $attachment parameter is a string with the attachment file content with filename $filename. */ $boundary = "b".md5(uniqid(time())); $mime = "From: $addr_from\n"; $mime .= "Reply-To: $addr_from\n"; $mime .= "X-Mailer: Digital Healthcare Solutions\n"; $mime .= "X-Sender: $addr_from\n"; $mime .= "Content-type: multipart/mixed; "; $mime .= "boundary = $boundary\n\n"; $mime .= "This is a MIME encoded message.\n\n"; // First the regular message $mime .= "--$boundary\n"; $mime .= "Content-type: text/plain\n"; $mime .= "Content-Transfer-Encoding: base64"; $mime .= "\n\n".chunk_split(base64_encode($message))."\n"; // Now the attachment $mime .= "--$boundary\n"; $mime .= "Content-type: text/plain\n"; $mime .= "Content-Transfer-Encoding: base64\n"; $mime .= "Content-Disposition: attachment; "; $mime .= "filename = ".chr(34).$filename.chr(34); $mime .= "\n\n".chunk_split(base64_encode($attachment))."\n"; $mime .= "--$boundary--"; mail ($to, $subject, "", $mime); } and here's the loop in which it gets called: $i = 0; while (isset($EmailAddress[$i])) { mail_attachment ($EmailAddress[$i], "URGENT Communication", $message, $addr_from, $attachment, $filename); $i++; } Does anybody have any ideas? Rudolf Visagie Principal Software Developer Digital Healthcare Solutions Tel. +27(0)11 266 6946 Fax. +27(0)11 266 5080 Cell: +27(0)82 895 1598 E-mail: [EMAIL PROTECTED] -- PHP General 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]