Search the Community
Showing results for tags 'attachment'.
-
i'm trying to attach a .ics-file to a mail The Page send sends out the email but only download the ics-file. Email has no attachments. // event ID $eventID = $input->get('eventID','int'); $event = $pages->get($eventID); // config $testEmail = $event->event_mail_test_adress; $fromEmail = $event->event_mail_from; $fromName = $event->event_mail_from_name; $emailSubject = $event->event_subject; // .ics $filename = $event->name; header('Content-Encoding: UTF-8'); header('Content-type: text/calendar; charset=utf-8'); header("Content-Disposition: attachment; filename={$filename}.ics"); // fetch start date $event_start_ts = $event->getUnformatted("date_start"); // build the .ics data $ical_data = 'BEGIN:VCALENDAR'; $ical_data .= "\r\n"; $ical_data .= 'VERSION:2.0'; $ical_data .= "\r\n"; $ical_data .= 'CALSCALE:GREGORIAN'; $ical_data .= "\r\n"; $ical_data .= 'METHOD:PUBLISH'; $ical_data .= "\r\n"; $ical_data .= 'BEGIN:VEVENT'; $ical_data .= "\r\n"; $ical_data .= 'SUMMARY:'.$event->title; $ical_data .= "\r\n"; $ical_data .= 'UID:' . md5(uniqid(mt_rand(), true)) . '@'.$config->httpHost; $ical_data .= "\r\n"; $ical_data .= 'CLASS:PUBLIC'; $ical_data .= "\r\n"; $ical_data .= 'STATUS:CONFIRMED'; $ical_data .= "\r\n"; $ical_data .= 'DTSTART:'.date('Ymd', $event_start_ts).'T'.date("His", $event_start_ts); $ical_data .= "\r\n"; $ical_data .= 'DTSTAMP:'.date('Ymd').'T'.date('His'); $ical_data .= "\r\n"; $ical_data .= 'LOCATION:'.$event->venue; $ical_data .= "\r\n"; $ical_data .= 'URL:'.$event->httpUrl; $ical_data .= "\r\n"; $ical_data .= 'END:VEVENT'; $ical_data .= "\r\n"; $ical_data .= 'END:VCALENDAR'; // HTML BODY ob_start(); include('./_inc/emailbody.inc'); $emailBody = ob_get_clean(); // send email $m = new WireMail(); $m->to($testEmail); $m->from($fromEmail, $fromName); $m->subject($emailSubject); $m->bodyHTML($emailBody); $m->attachment($ical_data); $m->send();
-
Hello Is there a way to program my code in a way, that the website has Background-Attachment Fixed on laptops and PC's and Background-Attachment Scroll on mobile devices? On ios Background-Attachment Fixed does not work. It can't be done with media queries, because the ipad pro is bigger than my laptop. Maybe a Javascript or something. I found this, but not knowing Javascript I don't know if it would work. Could this work? if (iosVersion >= 7) { $(document).scroll(function() { $('#background').css('background-position', '0px ' + $(document).scrollTop() + 'px'); }); } Can anybody offer some advice? Thanks a lot Jakob
- 5 replies
-
- attachment
- fixed
-
(and 1 more)
Tagged with:
-
Hello, from the day i am using PW every day i am loving it more and more, its really great. i am trying to create a page for website where people can apply for job and send CV as attachment too. i was searching forums from last few days and create one page with combinations of many posts in form, my code is bellow. <style> #email2 { display:none; } #message-error { color:#F00;} #message-success { color:#09F;} </style> <?php // check if the form was submitted $spam_check=trim($input->post->email2); if($input->post->submit && $spam_check == '') { $sent = false; $error = ""; $emailTo = $page->email; // sanitize form values or create empty $form = array( 'fullname' => $sanitizer->text($input->post->fullname), 'job_title' => $sanitizer->text($input->post->job_title), 'job_id' => $sanitizer->text($input->post->job_id), 'contact' => $sanitizer->text($input->post->contact), 'email' => $sanitizer->email($input->post->email), 'comments' => $sanitizer->textarea($input->post->comments), ); $msg = "Full Name: $form[fullname]\n" . "Contact number: $form[contact]\n" . "Job Title: $form[job_title]\n" . "Job Id: $form[job_id]\n" . "Email: $form[email]\n" . "Comments: $form[comments]"; // attachment if(isset($_POST['submit']) && !empty($_FILES['file']['size'])) { $filename = $_FILES["file"]["name"]; $filetype = $_FILES["file"]["type"]; $filesize = $_FILES["file"]["size"]; $filetemp = $_FILES["file"]["tmp_name"]; if($filesize < 10) throw new Exception("File too small"); if($filesize > 1000000) throw new Exception("File too big"); $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); if(!in_array($ext, array('doc', 'pdf', 'docx'))) throw new Exception("Invalid file type"); $destination = $config->paths->cache . $user->name . '.' . $ext; if(!move_uploaded_file($filetemp, $destination)) throw new Exception("Unable to move uploaded file"); $fp = fopen($destination, "rb"); $file = fread($fp, $filesize); $file = chunk_split(base64_encode($file)); unlink($destination); } // This two steps to help avoid spam $headers .= "Message-ID: <".gettimeofday()." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n"; $headers .= "X-Mailer: PHP v".phpversion()."\r\n"; // With message $headers .= "Content-Type: text/html; charset=utf-8\r\n"; $headers .= "Content-Transfer-Encoding: 8bit\r\n"; $headers .= "".$message."\n"; $headers .= "--".$num."\n"; // Attachment headers $headers .= "Content-Type:".$filetype." "; $headers .= "name=\"".$filename."\"r\n"; $headers .= "Content-Transfer-Encoding: base64\r\n"; $headers .= "Content-Disposition: attachment; "; $headers .= "filename=\"".$filename."\"\r\n\n"; $headers .= "".$file."\r\n"; $headers .= "--".$num."--"; if(mail($emailTo, "Job Application", $msg, "From: $form[email]",$headers)) { // populate body with success message, or pull it from another PW field $messageok = "<div id='message-success'><p>Thanks, your message has been sent.<b>We will Contact you back</p> </div>"; $sent = true; }else{ $error= "<div id='message-error'><p>Error! Mail Not Sent.</p></div>"; $sent = false; } } include("./head.inc"); ?> here is my form code Please enter your contact details below.<br /><br /> <?php if(strlen($error)>1) { echo $error; } // to get JOB title and id $job=$pages->get($input->urlSegment1); if(!$sent) { ?> <form action="./" method="post" class="contact-form" id="contactform"> <input id="job_title" name="job_title" type="hidden" value="<?php echo $job->title;?>" /> <input id="job_id" name="job_id" type="hidden" value="<?php echo $job->job_id;?>" /> <input Placeholder="Please Enter Your Name" name="fullname" id="fullname" value="<?php echo $form[fullname];?>" /> <input type="text" Placeholder="Please Enter Your Contact Number" name="contact" id="contact" value="<?php echo $form[contact];?>" /> <input type="text" name="email" id="email" Placeholder="Please Enter Your Email" /> <input type="file" name="file" id="file" value="Uplode Cv" /> <textarea id="comments" name="comments" cols="60" rows="3" Placeholder="Please Enter Your Message"><?php echo $form[comments];?> <input type="text" name="email2" id="email2"> <input name="submit" id="submit" type="submit" value="Send" /> </form> <?php }else{ echo $messageok; } include("./foot.inc"); ?> form is displaying properly but emails are not going and i am getting error "Error! Mail Not Sent." what i want to do is send email with attachment and then delete uploaded file from server and of course secure. really appreciate your update. Thanks
- 5 replies
-
- 1
-
- attachment
-
(and 1 more)
Tagged with:
-
Hi guys, have been trying to figure out how I can get hold of a file's path when it has been uploaded via a form. I don't need to add it to the database, just email it. I am currently using phpmailer to send the email and all I need for it to send the attachment is the path of the uploaded file. I have tried using $input->post then I was thinking it may be something to do with $file or $files?