From: "Gary" on 26 Jun 2010 08:10 "Bastien Koert" <phpster(a)gmail.com> wrote in message news:AANLkTilfXsbs83zAAa6iX32yHUrQDg9Azd6TWQ_HnQx1(a)mail.gmail.com... On Fri, Jun 25, 2010 at 9:59 AM, Ashley Sheridan <ash(a)ashleysheridan.co.uk> wrote: > On Fri, 2010-06-25 at 09:51 -0400, Gary wrote: > >> I am trying to have an attachment to an email from a form. Email is >> working >> fine, am unable to get attachment. The attachment will be a word.doc. >> >> I am getting error message >> >> Warning: file_get_contents(attachment.zip) [function.file-get-contents]: >> failed to open stream: No such file or directory in >> /home/oneonel1/public_html/emailreminderresult.inc.php on line 24 >> Mail failed >> >> Line 24 reads: >> >> $attachment = >> chunk_split(base64_encode(file_get_contents('attachment.zip'))); >> >> here is the all of the code that I have removed the email addresses & >> such. >> >> Can someone point me in the right direction? >> >> Thank you >> >> Gary >> >> <?php >> $fname=stripslashes($_POST['fname']); >> $lname=stripslashes($_POST['lname']); >> $email=stripslashes($_POST['email']); >> $comments=stripslashes($_POST['comments']); >> $ip= $_SERVER['REMOTE_ADDR']; >> $attachment = $_POST['attachment']; >> >> $attachment = $_FILES['attachment']['name']; >> $attachment_type = $_FILES['attachment']['type']; >> $attachment_size = $_FILES['attachment']['size']; >> >> //create a boundary string. It must be unique >> //so we use the MD5 algorithm to generate a random hash >> $random_hash = md5(date('r', time())); >> //define the headers we want passed. Note that they are separated with >> \r\n >> $headers = "From: myemail\r\nReply-To: myemail.com"; >> //add boundary string and mime type specification >> $headers .= "\r\nContent-Type: multipart/mixed; >> boundary=\"PHP-mixed-".$random_hash."\""; >> //read the atachment file contents into a string, >> //encode it with MIME base64, >> //and split it into smaller chunks >> $attachment = >> chunk_split(base64_encode(file_get_contents('attachment.zip'))); //line >> 24 >> //define the body of the message. >> ob_start(); >> >> //Turn on output buffering >> >> //--PHP-mixed- >> echo $random_hash; >> //Content-Type: multipart/alternative; boundary="PHP-alt- >> echo $random_hash; >> >> //--PHP-alt- >> echo $random_hash; >> >> /* Content-Type: text/plain; charset="iso-8859-1" >> Content-Transfer-Encoding: 7bit */ >> >> >> >> //--PHP-alt- >> echo $random_hash; >> /* Content-Type: text/html; charset="iso-8859-1" >> Content-Transfer-Encoding: 7bit */ >> >> >> //--PHP-alt- >> >> echo $random_hash; >> >> //--PHP-mixed- >> >> >> echo $random_hash; >> >> /* Content-Type: application/zip; name="attachment.zip" >> Content-Transfer-Encoding: base64 >> Content-Disposition: attachment */ >> >> echo $attachment; >> //--PHP-mixed- >> >> echo $random_hash; >> >> >> //copy current buffer contents into $message variable and delete current >> output buffer >> $message = ob_get_clean(); >> //send the email >> $mail_sent = @mail( $to, $subject, $message, $headers ); >> //if the message is sent successfully print "Mail sent". Otherwise print >> "Mail failed" >> echo $mail_sent ? "Mail sent" : "Mail failed"; >> >> >> >> echo "Thank you for contacting <b>888!</b><br /><br />"; >> echo "You have submitted the following information:<br /><br />"; >> echo "Name: $fname $lname<br />"; >> echo "E-Mail Address: $email<br />"; >> echo "Your comments or request: $comments<br /><br /><br />"; >> >> >> >> >> echo "We have also sent you an e-mail to $email with the submitted >> information as well as our contact information for your convienience. <br >> /><br /> >> Thank you for the opportunity to serve you!"; >> >> >> /*This is the email message to submitter*/ >> $contact="888\n 888\n 888"; >> $from_d="$email"; >> $to_d="$email"; >> $subject_d='Thank you from 888'; >> $msg_d="Thank you $fname for your submission, find our contact >> information >> listed for your convenience.\n\n" >> ."$contact\n\n" >> . "You have submitted the following information\n\n" >> . "Name: $fname $lname \n" >> . "E-Mail Address: $email\n" >> . "Comments: $comments\n" >> ; >> mail($to_d, $subject_d, $msg_d, 'From:' . $from_d); >> >> >> /*this is to form owner, */ >> $from="$email"; >> $to="myemail"; >> $subject="Submission from 888"; >> $msg= "This is a submission from 888com. \n\n" >> . "Clients Name: $fname . $lname \n" >> . "Email Address: $email\n" >> . "Comments: $comments\n" >> ; >> >> >> mail($to, $subject, $msg, 'From:' .$from); >> >> ?> >> >> >> >> __________ Information from ESET Smart Security, version of virus >> signature database 5228 (20100625) __________ >> >> The message was checked by ESET Smart Security. >> >> http://www.eset.com >> >> >> >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> > > > Your script can't find the attachment.zip file. As you're using a > relative path to it, it should be in the same directory as your php > script, or somewhere directly in the path environment variable. > > Also, make sure that the file has read properties set to allow Apache to > read it. > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > > Consider using something like phpmailer to handle the emails. Makes attaching things really simple. http://phpmailer.worxware.com/ -- Bastien Cat, the other other white meat Bastien How could anyone not love your advice when you seem to enjoy cats so much! I did download the phpmailer, however at this point I did not use it. On the one hand, my preferences is to be able to read/write and understand the code by itself (myself), however on the other hand, I'm not really interested in re-inventing the wheel everytime either. I have written all my mail scripts and re-cycle them as needed, I have yet to conquer the attachment hill yet. Thanks for your response, I appreciate your taking the time to offer help. Gary __________ Information from ESET Smart Security, version of virus signature database 5230 (20100625) __________ The message was checked by ESET Smart Security. http://www.eset.com
From: "Gary" on 26 Jun 2010 08:14 Richard Please accept my apology in that my response was sent directly to you and not the group, I hit 'Reply" instead of 'Reply to Group'. Gary "Richard Quadling" <rquadling(a)gmail.com> wrote in message news:AANLkTint_WiEsKaD-FuLaIHpjlfrMltkPjdYQsAo-F-a(a)mail.gmail.com... > First of all, take a look at > http://docs.php.net/manual/en/features.file-upload.php > > You are trying to open a named file (attachment.zip), but that may not > be what was uploaded. > > The 2 main functions to get to grips with are ... > > is_uploaded_file() and move_uploaded_file(). > > Uploaded files are not best directly accessed. Instead they should be > moved from the temp directory (assuming the server is set to > temporarily store uploaded files there) to a proper location for use > later on in the script. > > -- > ----- > Richard Quadling > "Standing on the shoulders of some very clever giants!" > EE : http://www.experts-exchange.com/M_248814.html > EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp > Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 > ZOPA : http://uk.zopa.com/member/RQuadling > > __________ Information from ESET Smart Security, version of virus > signature database 5229 (20100625) __________ > > The message was checked by ESET Smart Security. > > http://www.eset.com > > > __________ Information from ESET Smart Security, version of virus signature database 5230 (20100625) __________ The message was checked by ESET Smart Security. http://www.eset.com
From: Richard Quadling on 28 Jun 2010 05:32 On 26 June 2010 13:14, Gary <gpaul(a)paulgdesigns.com> wrote: > Richard > > Please accept my apology in that my response was sent directly to you and > not the group, I hit 'Reply" instead of 'Reply to Group'. > > Gary No problem. Here is an example of my code using the RMail script from phpguru.org. It was previously known as html_mime_mail5. <?php // Create a new message. $o_Mail = new RMail(); // As we are going to use SMTP to send the email, we need to know where to send it. // On my setup, the SMTP ini setting is what I'll be using. // You can also supply any SMTP AUTH settings needed here. $o_Mail->setSMTPParams ( ini_get('SMTP'), 25, Null, registrySettings_V2::read(registrySettings_V2::REG_SMTP_AUTH_LOGIN_REQUIRED), registrySettings_V2::read(registrySettings_V2::REG_SMTP_AUTH_LOGIN), registrySettings_V2::read(registrySettings_V2::REG_SMTP_AUTH_PASSWORD) ); // Set the From header $o_Mail->setHeader('From', '"Richard Quadling" <RAQ(a)nowhere.co.uk>'); // Some other useful headers. // $o_Mail->setHeader('Return-Path', '"Return to me" <ReturnToMe(a)nowhere.co.uk>'); // $o_Mail->setHeader('Return-Receipt-To', '"Delivery Receipt" <DeliveryConfirmations(a)nowhere.co.uk>'); // $o_Mail->setHeader('Disposition-Notification-To', '"Read or Delete Notification" <Disposition(a)nowhere.co.uk>'); // Add the subject. $o_Mail->setSubject($s_Subject); // Add the HTML with a location of the images to be added to the email automatically, rather than relying on internet to provide images // which is blocked by various security levels of Outlook. $o_Mail->setHTML($s_HTMLMessage, 'D:/Global Web Documents/images/'); // Let's add an attachment. // The filename, the mime type, the encoding and the file name to show the attachment as. $o_Mail->addAttachment(new fileAttachment('D:/Uploaded/content.zip', 'application/zip', new Base64Encoding(), 'YourContent.zip')); // If you want to keep copies of your emails, then setCc is the method to use. $o_Mail->setCc('RAQ(a)nowhere.co.uk'); // Finally, send the email to the recipients (held in an array to allow for multiple addresses) using SMTP. $o_Mail->send(array('"Your recipient\'s name" <your_recipient_email(a)domain.com>'), 'smtp'); ?> -- ----- Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling
From: "Gary" on 28 Jun 2010 08:23 Richard Thank you again for your kind help. Gary "Richard Quadling" <rquadling(a)gmail.com> wrote in message news:AANLkTikwUjmpBQIjd_EE9mBfPXA92SsEXJddNg2fGIbc(a)mail.gmail.com... > On 26 June 2010 13:14, Gary <gpaul(a)paulgdesigns.com> wrote: >> Richard >> >> Please accept my apology in that my response was sent directly to you and >> not the group, I hit 'Reply" instead of 'Reply to Group'. >> >> Gary > > No problem. > > Here is an example of my code using the RMail script from phpguru.org. > It was previously known as html_mime_mail5. > > <?php > // Create a new message. > $o_Mail = new RMail(); > > // As we are going to use SMTP to send the email, we need to know > where to send it. > // On my setup, the SMTP ini setting is what I'll be using. > // You can also supply any SMTP AUTH settings needed here. > $o_Mail->setSMTPParams > ( > ini_get('SMTP'), > 25, > Null, > registrySettings_V2::read(registrySettings_V2::REG_SMTP_AUTH_LOGIN_REQUIRED), > registrySettings_V2::read(registrySettings_V2::REG_SMTP_AUTH_LOGIN), > registrySettings_V2::read(registrySettings_V2::REG_SMTP_AUTH_PASSWORD) > ); > > > // Set the From header > $o_Mail->setHeader('From', '"Richard Quadling" <RAQ(a)nowhere.co.uk>'); > > // Some other useful headers. > // $o_Mail->setHeader('Return-Path', '"Return to me" > <ReturnToMe(a)nowhere.co.uk>'); > // $o_Mail->setHeader('Return-Receipt-To', '"Delivery Receipt" > <DeliveryConfirmations(a)nowhere.co.uk>'); > // $o_Mail->setHeader('Disposition-Notification-To', '"Read or Delete > Notification" <Disposition(a)nowhere.co.uk>'); > > // Add the subject. > $o_Mail->setSubject($s_Subject); > > // Add the HTML with a location of the images to be added to the email > automatically, rather than relying on internet to provide images > // which is blocked by various security levels of Outlook. > $o_Mail->setHTML($s_HTMLMessage, 'D:/Global Web Documents/images/'); > > // Let's add an attachment. > // The filename, the mime type, the encoding and the file name to show > the attachment as. > $o_Mail->addAttachment(new fileAttachment('D:/Uploaded/content.zip', > 'application/zip', new Base64Encoding(), 'YourContent.zip')); > > // If you want to keep copies of your emails, then setCc is the method to > use. > $o_Mail->setCc('RAQ(a)nowhere.co.uk'); > > // Finally, send the email to the recipients (held in an array to > allow for multiple addresses) using SMTP. > $o_Mail->send(array('"Your recipient\'s name" > <your_recipient_email(a)domain.com>'), 'smtp'); > ?> > > > -- > ----- > Richard Quadling > "Standing on the shoulders of some very clever giants!" > EE : http://www.experts-exchange.com/M_248814.html > EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp > Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 > ZOPA : http://uk.zopa.com/member/RQuadling > > __________ Information from ESET Smart Security, version of virus > signature database 5233 (20100628) __________ > > The message was checked by ESET Smart Security. > > http://www.eset.com > > > __________ Information from ESET Smart Security, version of virus signature database 5233 (20100628) __________ The message was checked by ESET Smart Security. http://www.eset.com
From: Andrew Ballard on 28 Jun 2010 09:58 On Mon, Jun 28, 2010 at 8:53 AM, Richard Quadling <rquadling(a)gmail.com> wrote: > On 28 June 2010 13:44, Brandon Rampersad <brandon.add.on(a)gmail.com> wrote: >> f**k no > > Enlightened criticism aside, why not? Or rather (as I'm willing to adapt) how? Probably because you ignored his latest request to chat. Just guessing, really. Andrew
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: in_array - what the... Next: Returning a Recordset from a Funtion |