Re: What is wrong with this function please?
| From: | Robin Wilson | Date: | Sun, 25 Mar 2007 18:25:17 +0000 |
| Subject: | Re: What is wrong with this function please? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-251336@lists.php.net to get a copy of this message | ||
Thanks for the help
The line returns are specified as "\r\n" but in the echo they seem to all be on one line. Could that be related to the problem. Also the addresses are specified but seem to have been removed???
This is what I specified:
$eol="\r\n";
$mime_boundary=md5(time());
# Common Headers
$headers .= 'From: '.$fromName.'<'.$fromaddress.'>'.$eol;
$headers .= 'Reply-To: '.$fromName.'<'.$fromaddress.'>'.$eol;
$headers .= 'Return-Path: '.$fromName.'<'.$fromaddress.'>'.$eol; // these two to set reply address$headers .= "Message-ID: <".time()."@".$_SERVER['SERVER_NAME'].">".$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol; // These two to help avoid spam-filtersI followed some tutorials and they all seemed to tell me to do it this way. The emails seem to work with other clients and only Exchange doesn't like them. Tested with Squirrel Mail and they were recieved with the attachment etc. Do you have any more ideas please? Thanks for the help Robin ""Jake McHenry"" <linux@nittanytravel.com> wrote in message news:124f01c76e47$9ee59d50$6401a8c0@jsdjlaptop...
No sorry, both messages are the same. Didn't mean to post it twice. Sorry. Below is what prints out when I echo the message: $to robinwilson@rwsbetas.com $subject Proposal Submission $headers From: 2HostMe Mailer Reply-To: Robin Wilson Return-Path: 2HostMe Mailer Message-ID: X-Mailer: PHP v4.4.2 MIME-Version: 1.0 Content-Type: multipart/related; boundary="d49718178131ebc038c576f007a40642"Are these all on the same lines just because of echo? Or are they on their own lines? Like this: From: 2HostMe Mailer Reply-To: Robin Wilson Return-Path: 2HostMe Mailer Message-ID: X-Mailer: PHP v4.4.2 MIME-Version: 1.0 Content-Type: multipart/related; boundary="d49718178131ebc038c576f007a40642" From: should have a from email address, same with reply-to and return-path
$msg --d49718178131ebc038c576f007a40642 Content-Type: image/gif; name="betaresource.gif" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="betaresource.gif"Same with these, are there any line returns?
R0lGODlhWgAeAPcAAAAAAP///25scFNdc1tkc0tcclpibWNpcTtbgi1CWzJIY0 BaeyU0RjpRbCw9 UUFXci8/UkxbbUpUYGdwe3Z7gRMqQxg1VB5AZh0+YjpWdjhTcjVNaTBGXjRLZS Y3Si1BVzxVcUpn iE1rizpQaTJEWTZJXzlNYzFCVUBUajhGVVJlezdDUGNyglNdaBUvShEmPBo5Wh 9EaiBGbBs7XCFI byNMdCJJcR9CZxw8XSFFaiJHbCNJbiBCZChReiZOdSVLcSBBYR8+XSRHaSJDYy pQdSdKbSVGZiI3 TSU6UDtcfSk/VkNliUVkhD9bdyk6TENeekpmgkNbdDxPY1NtiEhedTtNXzhJWk 1ke0theEVXajA9 SkJTZE5hdGx+kFxremx2gH6DiBYxSyVNcxo2USlUfB9AXh08WCpWfidQdSJGZh cvRSlTeSpUeh06 VB89WRozShkxRyZJaS1VeylOcCpQchkvRC1UeCVFYi1SdTBYfCM/Wi1QcStNbD BUdUVqi0Riflt5 lFdzjEZbb1t1jT9OXGJ2iUJPW1dlcoiVoSxagitZgC9gii5dhjNlkTdtmjVqlT RjjDtvmTptljFb fyRDXi9XeTlpkDVhhTlmjCpKZkBulD1lh05yj01rhF55j1NqfWuHnmN8kmmBlU paZ4aaq32PnniI loKPmiVIYj53oz5ym0R8pS5SbUN2nWGFoG6SrVZvgltzhlJndzxLV2V7jJKqvI KVpGx7hoqbqJGg q46bpTFadkuDqoahtHSCjImUnKGstJylq8THyTlQX2KAk1txfcDL0ayxtIadqZ ieobS6vbzFyLe/ wcXJyrG2t7i8vJaXl4eIiL/Bv7y+vLW2tbCxsLu8uqusqrq7uMfIwtDQzM3Nyd jY1cTEwo6Ojbe2 saSjoMC+uePh3MnGv83KxO7q4+3o4MPAu726teLazujh1+bf1erk2+nj2tzUyd fPxOTc0ezm3uvl 3dTKvszBttHGu/Hs58G1q8e7sb6wp6ubkrKimbipoJSMiKCSjD1MWCH5BAEAAP 8ALAAAAABaAB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EKIAjMMwImsgGXYgKGkGBXIA hVcAIQEEyTgAkK pAm5Rwy2UAl9wAdMOAdzwAfJJQQYiAbgUAYYgAOmgAHgAAMzAANcaAFuIANdIw ZrkAiKwAplAA7A gQNBAARGoABw2AEnAgIFwAVTsC9McAXXgAV/oAJe4AquYC8ggDxZcAgGYABZQG CxAAufIAhr/wMJ 0mAJk7AHtNAf01AEp4ALnQAMcrAJ14AGbMBS2DBVpoBT1MA1UxAMGKAB1cAD75 ADlxAMK6YIPhAV p2AKnxAMRhAF1aAA79ABYAANWRABXnAOwbAwwNAJ0oAFriIA2QCInRAMpvAE48 AF5yAABgAOXBAL tNAHebAL0lA0cUALuZAfc1AgoqAN3SANwNAILWUJS9ADNZBTOyUDNfAg1KVT03 ADQzANKgZU0uBO HnJUfBAOG3AOctgAUYACWNANU+AiwEAK6dAN3TAOhUAOtAAKoDANyfAL6UAFp3 AO6ZAzBBABexAf wYAIFFYNpZAfe1AgnhAMeaAJ2ZAKjaAIUP/gDAcSCMewIDQwDYGgiqx4Ae+AAR ngDGdABHSwBtJg B2KgA6lYBE9ADRkgDcQDAg/QACHgkCEQCM9gClcVAtsQAuPwBQizDcBFDhFwDl HwAOfwAANAAEEj NJOYAHdQCZPINHZgB3SQB5bAC7zQCGxwBlZjOjKQBjewAzZwNWHDAxhgDd30A1 SjCGTQB3uAXEEQ BJSQCZeyCyMwDCawBSNQACqgAlhABVEgGIKBBS0SAhQ3AbfwChrJOI7zOA8wB2 jAXHIwBwkABHPw A0WQXMr1A2ygCI3gCI3QAz9AA28zXQPDA9N1AY4ZBBiQhRiQAz9QA6NTBHKQA9 6JAU6SAEYmsAEb wAcKIIMasADqmQFzwxHumQR3gwJxaQBesF2DoAIoQJ4bEBAAOw== Content-Type: multipart/alternative --d49718178131ebc038c576f007a40642 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Dear Robin Wilson Below are the details of the Proposal Submission Form you filled in at 2HostMe Media Services Logo / produktnaam test Thema / slogan: Steekwoorden* Aantal (ca.): Kleur item: Budget (minimum en maximum prijs in euros) tussen euro en euro per produkt item Gewenste leverdatum 27-01-2007 Streef Datum Eventueel eigen produkt ideeën Opmerkingen / aanvullende info Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Dear Robin Wilson Below are the details of the Proposal Submission Form you filled in at 2HostMe Media Services Logo / produktnaam test Thema / slogan: Steekwoorden* Aantal (ca.): Kleur item: Budget (minimum en maximum prijs in euros) tussen euro en euro per produkt item Gewenste leverdatum 27-01-2007 Streef Datum Eventueel eigen produkt ideeën Opmerkingen / aanvullende info --d49718178131ebc038c576f007a40642-- ""Jake McHenry"" <linux@nittanytravel.com> wrote in message news:083e01c76dbf$f5627500$6401a8c0@jsdjlaptop... I take it there are no errors... And your using windows... Sending to exchange... I guess with seeing what you posted, I would start by echoing out what you have in $to, $subject, $msg, $headers. Are there any errors in Exchange logs? Do you see the message coming into Exchange queue? Jake-- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.446 / Virus Database: 268.18.17/731 - Release Date: 3/23/2007 3:27 PMI send it-----Original Message----- From: Robin Wilson [mailto:robinwilson@rwsbetas.com] Sent: Friday, March 23, 2007 9:53 PM To: php-general@lists.php.net Subject: [PHP] What is wrong with this function please? Hello I'm trying to do a function that emails users and sends an attachment. But I think something is in the wrong order or something as whenvarious sources:Exchange discards it. This is the function which I have put together from$subject, $message,I would really appreciate any help as I have been up half the night and got nowhere! Thanks Robin function sendMail($to, $toName, $from, $fromName,$message)).$eol.$eol;$uploadfile, $fileName, $fileType, $fileSize) { $eol="\r\n"; $mime_boundary=md5(time()); # Common Headers $headers .= 'From: '. $fromName .' <'. $from .'>'.$eol; $headers .= 'Reply-To: '. $toName .' <'. $to .'>'.$eol; $headers .= 'Return-Path: '. $fromName.' <'. $from.'>'.$eol; // thesetwo to set reply address $headers .= "Message-ID: <".$mime_boundary."@".$_SERVER['SERVER_NAME'].">".$eol; $headers .= "X-Mailer: PHP v".phpversion().$eol; // These two to help avoid spam-filters # Boundry for marking the split & Multitype Headers $headers .= 'MIME-Version: 1.0'.$eol; $headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"".$eol; $msg = " "; if ($uploadfile != "") { # File for Attachment$file_name = substr($uploadfile, (strrpos($uploadfile,"/")+1));$handle=fopen($uploadfile, 'rb'); $f_contents=fread($handle, $fileSize); $f_contents=chunk_split(base64_encode($f_contents));//Encode The Data For Transition using base64_encode();fclose($handle);# Attachment $msg .= "--".$mime_boundary.$eol; $msg .= "Content-Type: ".$fileType.";name=\"".$file_name."\"".$eol;$msg .= "Content-Transfer-Encoding: base64".$eol; $msg .= "Content-Disposition: attachment;filename=\"".$file_name."\"".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !!$msg .= $f_contents.$eol.$eol;} # Setup for text OR html $msg .= "Content-Type: multipart/alternative".$eol; # Text Version $msg .= "--".$mime_boundary.$eol; $msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol; $msg .= "Content-Transfer-Encoding: 8bit".$eol; $msg .= strip_tags(str_replace("<br>", "\n",-- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.446 / Virus Database: 268.18.17/730 - Release Date: 3/22/2007 7:44 AM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.446 / Virus Database: 268.18.17/731 - Release Date: 3/23/2007 3:27 PM# HTML Version $msg .= "Content-Type: text/html; charset=iso-8859-1".$eol; $msg .= "Content-Transfer-Encoding: 8bit".$eol; $msg .= $message.$eol.$eol; # Finished $msg .= "--".$mime_boundary."--".$eol.$eol; // finish with two eol's for better security. see Injection. // Mail it mail($to, $subject, $msg, $headers); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.446 / Virus Database: 268.18.17/730 - Release Date: 3/22/2007 7:44 AM