|
Posted by Paul on 06/04/05 03:09
Hi Joseph,
I know what you mean... echo is my best troubleshooting tool :) ... but
my mind is my worst :) ... I was echoing the right variable.. I just did
not notice that I was sending the wrong variable to mail() :)
take care
paul
Joseph Melnick wrote:
> Hello Paul,
>
> Happy that you found your solution.
>
> I have been bitten by this sort of bug before :)
>
> Usually I echo the variables just before the function call as a test just to
> make sure that everything is in line.
>
> Joseph Melnick
> JM Web Consultants
> http://www.jphp.com/
>
>
> "Paul" <freelance@dezignage.net> wrote in message
> news:0alne.1534423$8l.969206@pd7tw1no...
>
>>Joseph Melnick wrote:
>>
>>>Hello Paul,
>>>
>>>Check your boundaries.
>>>
>>>change:
>>>$headers .= "Content-Type: multipart/mixed;{$br}";
>>>$headers .= " boundary=\"{$boundary}\"{$br}";
>>>$headers .= "MIME-Version: 1.0{$br}{$br}";
>>>to:
>>>$headers .= "Content-Type: multipart/mixed;";
>>>$headers .= " boundary=\"{$boundary}\"{$br}";
>>>$headers .= "MIME-Version: 1.0{$br}{$br}";
>>>
>>>Since you want to say this:
>>>
>>>$message = "This is a multi-part message.{$br}";
>>>
>>>you need to prepend a boundary, a content type and a carriage return:
>>>
>>>$message .= "--".$boundary."{$br}";
>>>$message .= "Content-Type: text/plain{$br}{$br}";
>>>
>>>$message = "This is a multi-part message.{$br}";
>>>
>>>
>>>Joseph Melnick
>>>JM Web Consultants
>>>http://www.jphp.com/
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>"Paul" <freelance@dezignage.net> wrote in message
>>>news:CGbne.1531870$8l.1151004@pd7tw1no...
>>>
>>>
>>>>Hi guys.... running into a weird problem that doesn't seem to make sense
>>>>to me. Anyone care to shed some light on this issue? Here's my code...
>>>>
>>>>function sendMail($emailRcpt, $att = null) {
>>>>
>>>>if(empty($emailRcpt)) { return false; }
>>>>$emailFrom = "me@notu.com";
>>>>$emailSubj =& $_POST['emailSubj'];
>>>>$emailBody = str_replace("\n", "", $_POST['emailBody']);
>>>>
>>>>if(!empty($att)) {
>>>>$attPath = "include/";
>>>>$attFullPath = $attPath.$att;
>>>>
>>>>$fp = fopen($attFullPath, "rb");
>>>>$file_contents = fread($fp,filesize($attFullPath));
>>>>fclose($fp);
>>>>$encodedFile = chunk_split(base64_encode($file_contents));
>>>>
>>>>}
>>>>
>>>>$rand = md5(time());
>>>>$boundary = "==Multipart_Boundary_x{$rand}x";
>>>>
>>>>$br = "\r\n";
>>>>
>>>>$headers = "From: Me<$emailFrom>{$br}";
>>>>$headers .= "Reply-To: Me<{$emailFrom}>{$br}";
>>>>$headers .= "Date: ".date("d/m/Y H:i")."{$br}";
>>>>$headers .= "Return-Path: {$emailFrom}{$br}";
>>>>$headers .= "X-Mailer: PHP{$br}";
>>>>
>>>>$headers .= "Content-language: en{$br}";
>>>>$headers .= "X-Priority: 3 (Normal){$br}";
>>>>$headers .= "Content-Transfer-Encoding: 7bit{$br}";
>>>>$headers .= "Content-Type: multipart/mixed;{$br}";
>>>>$headers .= " boundary=\"{$boundary}\"{$br}";
>>>>$headers .= "MIME-Version: 1.0{$br}{$br}";
>>>>
>>>>
>>>>$message = "This is a multi-part message.{$br}";
>>>>
>>>>if(!empty($encodedFile)) {
>>>>$message .= "--".$boundary."{$br}"; $message .= "Content-Type:
>>>>application/octet-stream; name=\"{$att}\"{$br}";
>>>>
>>>>$message .= "Content-Transfer-Encoding: base64{$br}";
>>>>$message .= "Content-Disposition: attachment; filename=\"{$att}\"{$br}";
>>>>
>>>>$message .= $encodedFile."{$br}";
>>>>
>>>>}
>>>>
>>>>$message .= "--".$boundary."{$br}";
>>>>$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"{$br}";
>>>>
>>>>$message .= "Content-Transfer-Encoding: 7bit{$br}{$br}";
>>>>
>>>>$message .= $emailBody."{$br}";
>>>>
>>>>$message .= "--".$boundary."--{$br}";
>>>>
>>>>$emailRcpt = "me@notu.com";
>>>>if(mail($emailRcpt, $emailSubj, $emailBody, $headers)) {
>>>>return $emailRcpt;
>>>>}
>>>>else {
>>>>return false;
>>>>}
>>>>}/*----------------------------------sendMail()--------------------------*/
>>>>
>>>>I do not know what this is not working as expected... I get the
>>>>message... apparently all the right headers, but no message body.. and no
>>>>attachments.... I know it some small detail I am missing... just can't
>>>>figure out what it is :) ..
>>>>
>>>>I've tried setting $br to "\r", "\r\n", "\n" ... same results....
>>>>
>>>>thanks!
>>>>
>>>>Paul
>>>
>>>
>>>
>>Hi Joseph,
>>
>>Thank you for your reply. I actually don't think that is the problem. That
>>line is only there to be displayed for older email clients that don't s
>>upport multipart messages. I figured out my problem shortly after I posted
>>for help. As my original post said.. it is something small I was
>>overlooking :) in this case my problem was on the line where I call the
>>mail function ... instead of passing it the $message variable.. I was
>>passing it the $emailBody variable... (which was set as well, just to the
>>wrong thing) ... :) Now it works...!!
>>
>>thanks for your help!
>>
>>Paul
>
>
>
Navigation:
[Reply to this message]
|