email - Create and mail temporary pdf in php -



email - Create and mail temporary pdf in php -

when clicking button pdf generated , opens pdf in web browser. pdf stored temporary in variable , included in mail service attachment when buttons clicked.

i'm struggling how save , attach file.

<a class="button" href="http://mydomian.com/pdf001.php">send pdf</a> <?php $to = 'nobody@example.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'from: webmaster@example.com' . "\r\n" . 'reply-to: webmaster@example.com' . "\r\n" . 'x-mailer: php/' . phpversion(); mail($to, $subject, $message, $headers); ?>

like comment under original post say

use phpmailer

<?php require_once('../class.phpmailer.php'); $mail = new phpmailer(); // defaults using php "mail()" $mail->addreplyto("name@yourdomain.com","first last"); $mail->setfrom('name@yourdomain.com', 'first last'); $mail->addreplyto("name@yourdomain.com","first last"); $address = "whoto@otherdomain.com"; $mail->addaddress($address, "john doe"); $mail->subject = "php send pdf test"; $mail->altbody = "to view message, please utilize html compatible email viewer!"; // optional, comment out , test $mail->msghtml($body); $mail->attachfromstring (base64_encode(file_get_contents($urltopdf))); // attachment // in case http://mydomian.com/pdf001.php if(!$mail->send()) { echo "mailer error: " . $mail->errorinfo; } else { echo "message sent!"; } ?>

i edited code online real quick , think work. tweaking each variable.

php email temporary-files

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -