Jump to content

ragsr@ix.netcom.com

Members
  • Posts

    29
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ragsr@ix.netcom.com's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. This problem has been solved. The php script was find. The inabilty to receive emails sent by the script was isolated to my EarthLink email server. Earthlink's SpamBlocker SW stopped working correctly and would not allow email sent from my "From" email address in my MIME email script to get through to my desktop. This was the case despite the fact that I had tagged that address as non-Spam in Earthlink's SpamBlocker. Earthlink escalated the problem. My work around, until this is permantely fixed, is to turn Earthlinks SpamBlocker.
  2. Correction....The link to run the script should be http://www.unitresearch03.com/Admin/SendUserEmailPHP01.php although the link in my Post is nearly identical. The only difference is how extensively I commented out the more complex case. Sorry, Bob G.
  3. Thanks in advance for any help you can provide on this. Bob G. BACKGROUND: I have an app that is hosted on Host Monster and its script includes a Class that is supposed to send MIME emails with or without attachments using only MIME types text, html, and image. It was working fine. I hadn't worked with or on it for about two months then found, last week, that it would no longer send emails even though the script runs without any Warnings. I've worked on this for several days now and I'm stuck. EXPECTED BEHAVIOR: When the script runs, it should send a simple text only email to a given email address and an more complex email that requires html and an in-line image in the body and an attachment with the same image. The image type is jpeg. ACTUAL BEHAVIOR: The script runs to completion with no Warning but sends neither of the two emails. CODE: Attached and cc'd below is a script which mimics the code in my app and the actual behavior described above but only for the simple email mentioned above. To simplify debug I've commented out that part of the script that should send out the more complex email mentioned above. Note: You can run the script by going to http://www.unitresearch03.com/Admin/SendUserEmailHM01.php Note: Line 6 can be changed to your own email address for testing BEGIN CODE: <?php //TOP LINE CODE ////SIMPLE MIME EMAIL CODE - NO ATTACHMENTS ////////////////////////////////////////////// $mail = new mime_mail ; $mail->from = "ragsr@ix.netcom.com" ; $mail->to = "ragsr@ix.netcom.com" ; $mail->subject = "SIMPLE MIME EMAIL - NO ATTACHMENTS" ; $mail->body = "SIMPLE MIME EMAIL BODY" ; $mail->send() ; ////END OF SIMPLE MIME EMAIL CODE //////////////////////////////////////////////////////// ////START MIME EMAIL CODE - ALLOWS ATTACHEMENTS ///////////////////////////////////////////////// //SIMPLE SEND EMAIL PG.448 PHP REFERENCE PLUS ATTACHMENT EXAMPLE FROM SAME PAGE //include "mime_mail.inc"; //THIS CAUSED A WARNING AND, APPARENTLY, IS NOT REQUIRED. CODE OK W/O IT //READ FILE $filename="/home1/unitcons/public_html/unitresearch03/TCStripComposition-27Cb.jpg" ; $content_type="image/jpeg" ; //OPEN, EXTRACT DATA, THEN CLOSE FILE $fd=fopen($filename, "r") ; $data=fread($fd, filesize($filename)) ; fclose($fd) ; $fileX="/home1/unitcons/public_html/unitresearch03TCStripComposition-27Cb.jpg" ; $ftype=filetype ($filename) ; $fsize=filesize($filename) ; //echo "FILE TYPE :"."$ftype"."<br>" ; //echo "FD FILE TYPE :"."$fdltype"."<br>" ; //echo "DATA :"."$data"." END DATA"."<br>" ; //echo "FSIZE :"."$fsize"."<br>" ; //echo "FDSIZE :"."$fsize"."<br>" ; //echo "FD :"."$fd"."<br>" ; //CREATE OBJECT INSTANCE $mail = new mime_mail ; //SET ALL DATA SLOTS $mail->from = "thromptmweeklycs@unitresearch03.com" ; $mail->to = "ragsr@ix.netcom.com" ; $mail->subject = "XXXThrompTM Weekly Comic Strip - Week of 6/20/201" ; $mail->body = "<html>Hope you enjoy your ThrompTM today! <br> <br> <br> <img src=http://www.unitresearch03.com/TCStripComposition-27Cb.jpg height='197' width='500' > </html>"; //DEFINE ATTACHMENT $name = $fileX ; $message = $data ; //ADD ATTACHEMENT //$mail->add_attachment ($data, $filename, $content_type) ; //SEND EMAIL //$mail->send() ; ////EBD SEND EMAIL WITH ATTACHMENT ////MIME CLASS class mime_mail { var $parts; var $to; var $from; var $headers; var $subject; var $body ; /* * void mime_mail() * class constructor */ function mime_mail () { $this->parts = array() ; $this->to = "" ; $this->from = "" ; $this->subject = "" ; $this->body = "" ; $this->headers = "" ; } /* * void add_attachement (string message, [string name], [string ctype]) * Add an attachment to the mail object */ function add_attachment ($message, $name = "", $ctype = "text/html jpeg" ) //function add_attachment ($data, $fileX, $content_type ) { echo "CTYPE IN AA :"."$ctype"."<br>" ; //echo "MESSAGE IN AA :"."$message"."<br>" ; echo "ENCODE IN AA: "."$encode"."<br>" ; echo "NAME IN AA :"."$name"."<br>" ; //echo "DATA IN AA :"."$data"."<br>" ; $partsd = $this->parts[] = array ( "ctype" => $ctype, "message" => $message, "encode" => $encode, "name" => $name, ); echo ("ARRAY#1 CTYPE :"."$partsd[ctype]"."<br>") ; //echo ("ARRAY#2 MESSAGE :"."$partsd[message]"."<br>") ; echo ("ARRAY#3 ENCODE :"."$partsd[encode]"."<br>") ; echo ("ARRAY#4 NAME :"."$partsd[name]"."<br>") ; //echo ("ARRAY#5 DATA :"."$partsd[data]"."<br>") ; $sizeX=sizeof($this->parts) ; echo "SIZE OF ARRAY IN ADD ATTACHMENT:"."$sizeX"."<br>" ; } /* * void build_message (array part= * Build message parts of an multipart mail */ function build_message ($part ) { $message = $part[ "message"]; //echo "MESSAGE IN BUILD:"."$message"."<br>" ; $message = chunk_split(base64_encode($message)) ; //echo "MESSAGE :"."$message"."<br>" ; $encoding = "base64" ; $partctype = $part["ctype"] ; $partname = $part["name"] ; echo "PART CTYPE :"."$partctype"."<br>" ; echo "PART NAME :"."$partname"."<br>" ; return "Content-Type: ".$part["ctype"]. ($part["name"]?" ; name =\"". $part["name"]. "\"":""). "\nContent-Transfer-Encoding: $encoding\n\n$message\n" ; } /* * void build_multipart() * Build a multipart mail */ function build_multipart() { $boundary = "b".md5(uniqid(time())) ; $multipart = "Content-Type: multipart/mixed; boundary = $boundary\n\nThis is a MIME encoded message.\n\n--$boundary" ; //$sizeX=sizeof($this->parts) ; //echo "SIZE OF ARRAY :"."$sizeX"."<br>" ; for ($i = sizeof($this->parts)-1; $i >= 0; $i--) { $multipart .= "\n".$this->build_message($this->parts[$i])."--$boundary" ; //echo "MULTIPART :"."$multipart"."<br>" ; } return $multipart.= "--\n" ; } /* * string get_mail() * returns the constructed mail */ function get_mail($complete = true) { $complete = true ; echo "COMPLETE :"."$complete"."<br>" ; ////STAEMENT ADDED TO FORCE IF ($COMPLETE) {} BELOW TO RUN //echo "MESSAGE IN GET MAIL:"."$message"."<br>" ; $mime = "" ; if (!empty($this->from)) $mime .= "From: ".$this->from. "\n" ; echo "MIME 1:"."$mime"."<br>"; if (!empty($this->headers)) $mime .= $this->headers. "\n" ; echo "MIME 2:"."$mime"."<br>"; if ($complete) { echo "MIME 3:"."$mime"."<br>"; if (!empty($this->to)) { $mime .= "To: $this->to\n" ; echo "MIME 4:"."$mime"."<br>"; } if (!empty($this->subject)) { $mime .= "Subject: $this->subject\n" ; echo "MIME 5:"."$mime"."<br>"; } } if (!empty($this->body)) $this->add_attachment($this->body, "", "text/html"); echo "MIME 55:"."$mime"."<br>"; $mime .= "MIME-Version: 1.0\n".$this->build_multipart() ; echo "MIME 6:"."$mime"."<br>"; return $mime; } /* * void send() * Send the mail (last class-function to be called) */ //function send ($message, $data, $fileX, $content_type) function send () { //$bodyY=$this->body ; //echo "BODYY :"."$bodyY"."<br>" ; $mime=$this->get_mail () ; echo "MIME 7:"."$mime"."<br>" ; mail($this->to, $this->subject, "" , $mime) ; //mail($this->to, $this->subject, $this->body, $mime) ; } } ; ////END OF MIME CLASS CODE ///////////////////////////////////////////////////////////////// ?> END CODE: 17525_.txt
  4. Ironmask, Thanks for the offer to help but I managed to muscle my way to getting my code to work. I kinda wish I had started with PHP Mailer in the first place but I don't have time to go back and start over at this point. I should have flagged this problem as Solved last week but will do that as soon as I finish this post. Cheers, Bob G.
  5. What is the best reference, hardcopy or web based, for understanding how to implement Mime based emails w attachments???? I have a script from an old reference (Professional PHP Programming - WROX publisher - 2000) partially working (email sent with correct To: From: Subject: and attachment but, for some reason, no body!!) Thanks in advance for your suggestions. Cheers, Bob G.
  6. dreamwest, Thanks for the reply. I appreciate the effort. What you sent me is another script for sending email with attachment using MIME. I already have a script that is supposed to do the same thing and seems to work but it is an example for which the file is assumed to be on a local disk. My file is on the web and my problem is actually quite simple. What I need help on is figuring out, after getting the attachment using a web address, exactly how to feed the attachment file to the send () script of the example I already have. I can narrow that down further. I've now read that fopen will operating on regular files, http files, and ftp files so I was able to use the fopen function to get the attachment file from the web. The sample code that I have first does a fopen to get the file then it does an fread to get the data. I'm having diffculty with the latter. Those two lines are... $fd=fopen('http://abccompany/testimagefile.jpg', 'r') ; //This works fine $data=fread($fd, filesize($filename)) ; Unfortunately, I get in trouble with the "$filename" part of the second line. If, for $filename, I use "testimagefile.jpg" or http://abcompany/testimagefile.jpg or $fd, the file is not found. I think this is due to the fact that the file is not local and I don't know what form or format the value for the variable $filename should be. I'm not at all experienced in dealing with file system ops so this is difficult for me but it should be dead simple for you. Cheers, Bob G.
  7. Hopefully this item is pretty simple for a person experienced with MIME email code BACKGROUND: I host a php application on Host Monster and I've added MIME email code to it that, by and large, is working. From a php reference, I have the example, "CODE EXAMPLE", below which is from a reference text. I need to send attachments from a different source than the example which happens to be an attached disk. I want to source the attachment from a network address such as "http://www.abccompany/images/testfile.jpg" instead of a local disk. REQUEST: Please give me an example of how the code example below can be modified to source the image file from a network address vs. from a local disk. NOTE: I've attached a Notepad file with the example cc'd into it. CODE EXAMPLE: <?php //include "mime_mail.inc" ; Not needed on Host Monster $filename = "testfile.jpg" ; $content_type = "image/jpeg" ; #read a JPEG picture from the disk $fd = fopen($filename, "r") ; $data = fread($fd, filesize($filename)) ; fclose($fd) ; #create object instance $mail = new mime_mail ; #set all data slots $mail->from = "your@address.com" ; $mail->to = "recipient@remote.net" ; $mail->subject = "welcome!" ; $mail->body = "Hello" ; #append the attachment $mail->add_attachment ($data, $filename, $content_type) ; #send e-mail $mail->send() ; ////MIME EMAIL CODE - ALLOWS ATTACHEMENTS ///////////////////////////////////////////////// // store as "mime_mail.inc" class mime_mail { var $parts; var $to; var $from; var $headers; var $subject; var $body ; /* * void mime_mail() * class constructor */ function mime_mail () { $this->parts = array() ; $this->to = "" ; $this->from = "" ; $this->subject = "" ; $this->body = "" ; $this->headers = "" ; } /* * void add_attachement (string message, [string name], [string ctype]) * Add an attachment to the mail object */ function add_attachment ($message, $name= "", $ctype = "application/octetstream") { $this->parts[] = array ( "ctype" => $ctype, "message" => $message, "encode" => $encode, "name" => $name, ); } /* * void build_message (array part= * Build message parts of an multipart mail */ function build_message ($part) { $message = $part[ "message"]; $message = chunk_split(base64_encode($message)) ; $encoding = "base64" ; return "Content-Type: ".$part["ctype"]. ($part["name"]?" ; name =\"". $part["name"]. "\"":""). "\nContent-Transfer-Encoding: $encoding\n\n$message\n" ; } /* * void build_multipart() * Build a multipart mail */ function build_multipart() { $boundary = "b".md5(uniqid(time())) ; $multipart = "Content-Type: multipart/mixed; boundary = $boundary\n\nThis is a MIME encoded message.\n\n--$boundary" ; for ($i = sizeof($this->parts)-1; $i >+ 0; $i--) { $multipart .= "\n".$this->build_message($this->parts[$i])."--$boundary" ; } } /* * string get_mail() * returns the constructed mail */ function get_mail($complete = true) { $mime = "" ; if (!empty($this->from)) $mime .= "From: ".$this->from. "\n" ; if (!empty($this->headers)) $mime .= $this->headers. "\n" ; if ($complete) { if (!empty($this->to)) { $mime .= "To: $this->to\n" ; } if (!empty($this->subject)) { $mime .= "Subject: $this->subject\n" ; } } if (!empty($this->body)) $this->add_attachment($this->body, "", "text/plane"); $mime .= "MIME-Version: 1.0\n".$this->build_multipart(); return $mime; } /* * void send() * Send the mail (last class-function to be called) */ function send () { $mime=$this->get_mail (false) ; mail($this->to, $this->subject, $this->body, $mime) ; } } ; ////END OF MIME CODE ///////////////////////////////////////////////////////////////// ?> [attachment deleted by admin]
  8. teamatomic, laffin... Thanks again for trying but I tested all of your suggestions previously and they did not change the behavior. However, I did find a change that eliminated the problem. I don't know why the problem was eliminated by this. Maybe you can explain. Here's the story... I got into this fix when I found example code for counting the times a session is invoked. That code is in my prior samples but repeated below in part. I thought the Warning might have something to do with a session variable and the only one I had, other than sessionid(), was $_SESSION['count']. Experience told me to change something so I changed the term 'count' to 'visitcount' in all instances and the Warnings stopped and the code worked as I expected it should in the first place. Note that the code was the same in TESTD as it was in TESTE but TESTD never generated the Warning. I changed the term 'count' in both of the files but I may not have needed to do that in TESTD. CODE EXCERPT ....if (empty($_SESSION['count'])) { $_SESSION['count']=1 ; } else { $_SESSION['count']++; ) ..... NOTE: I'll leave this item open for a bit to see if anyone can explain why my change elimianted the problem. Cheers, Bob G
  9. laffin, Thanks for trying but your diagnosis is incorrect. None of your recommendations corrected the problem. 1. Re. Warning: The line it references is "session_start () ;" and it states "Cannot send session cache limiter - headers already sent" so it is related to a session variable, not generic variables. I don't know how to deal with the headers mentioned. 2. Re. error reporting: I did not realize that I could turn off error reporting but I actually don't want to turn it off. So, I still need help. Php Freaks....Please chime in. Cheers, Bob G.
  10. Sorry...there are two typo's in the code examples that I included in the attachment PHPFreakshelp-02.txt that I attached to my post. They are missing brackets needed to close a function. The file attached to this reply, PHPFreakshelp-02b.txt corrects the error. Bob G. [attachment deleted by admin]
  11. I'm just starting to use PHP Sessions. I have a simple test case to see how Sessions behave which was derived using an example from a reference text. I have two scripts (Code samples below), TESTD.php and TESTE.php, each of which has a link pointing to the other. I use start sessionstart () in each of them. Using the links, I can toggle back and forth and the Session ID remains the same and a test variable which counts the toggles keeps the correct count as I toggle back and forth. PROBLEM: When script TESTE.php runs, I gets a Warning Signal (Sample below) that I don't understand. HELP NEEDED: I need to understand what I'm doing wrong that is causing the warning signal and how to eliminate it. Samples are attached as follows.... In attached file PHPFreakshelp-02.txt 1. TESTD.php CODE 2. TESTE.php CODE 3. TESTD display 4. TESTE display which includes the Warning The Warning is as follows... Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/unitcons/public_html/unitresearch02/TESTE.php:2) in /home/unitcons/public_html/unitresearch02/TESTE.php on line 9 All help is greatly appreciated. Bob G. [attachment deleted by admin]
  12. Mchl....AWESOME!! Thanks for being so patient with me. I was stuck for a couple of days on this one. Your help is greatly appreciated. Thanks again. Cheers, Bob G.
  13. Mchl, Try this simple test to see what I'm talking about. If I run this code I get no value between ...FBlemail= and ENDOFTESTSTRING when the second echo is executed. I should get EMAILADDRESS. TEST CODE: $FBluseremailaddress="EMAILADDRESS" ; echo "FBl: "."$FBluseremailaddress"."<br>" ; echo "ECHO: "."TESTSTRING=LOGINOK&FBlemail=<?php echo ($FBluseremailaddress) ; ?>ENDOFTESTSTRING" ;
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.