<div dir="ltr"><div class="gmail_default" style="font-family:courier new,monospace">Still no attachment :S</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 18 December 2013 00:48, Paolo Mainardi <span dir="ltr"><<a href="mailto:paolo@twinbit.it" target="_blank">paolo@twinbit.it</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Seems that there is a typo here:<div class="im"><div><br></div><div><div class="gmail_default" style="font-family:arial,sans-serif;font-size:12.800000190734863px">
<font face="courier new, monospace">function pass2pdf_mail($key, &$message, $attachment) {</font></div>
<div class="gmail_default" style="font-family:arial,sans-serif;font-size:12.800000190734863px"><font face="courier new, monospace"> switch($key) {</font></div><div class="gmail_default" style="font-family:arial,sans-serif;font-size:12.800000190734863px">
<font face="courier new, monospace"> case 'key':</font></div><div class="gmail_default" style="font-family:arial,sans-serif;font-size:12.800000190734863px"><font face="courier new, monospace"> $message['subject'] = $subject;</font></div>
<div class="gmail_default" style="font-family:arial,sans-serif;font-size:12.800000190734863px"><font face="courier new, monospace"> $message['body'][] = $body;</font></div><div class="gmail_default" style="font-family:arial,sans-serif;font-size:12.800000190734863px">
<font face="courier new, monospace"> $message['attachments'][] = $attachment;</font></div><div class="gmail_default" style="font-family:arial,sans-serif;font-size:12.800000190734863px"><font face="courier new, monospace"> break;</font></div>
<div class="gmail_default" style="font-family:arial,sans-serif;font-size:12.800000190734863px"><font face="courier new, monospace"> }</font></div><div class="gmail_default" style="font-family:arial,sans-serif;font-size:12.800000190734863px">
<font face="courier new, monospace">}</font></div></div><div class="gmail_default" style="font-family:arial,sans-serif;font-size:12.800000190734863px"><font face="courier new, monospace"><br></font></div></div><div class="gmail_default" style="font-size:12.800000190734863px">
<font face="courier new, monospace">Must be:</font></div><div class="gmail_default" style="font-size:12.800000190734863px"><font face="courier new, monospace"><br></font></div><div class="gmail_default" style="font-size:12.800000190734863px">
<div class="gmail_default" style="font-family:arial,sans-serif"><font face="courier new, monospace">function pass2pdf_mail($key, &$message, $params) {</font></div><div class="gmail_default" style="font-family:arial,sans-serif">
<font face="courier new, monospace"> switch($key) {</font></div><div class="gmail_default" style="font-family:arial,sans-serif"><font face="courier new, monospace"> case 'key':</font></div><div class="gmail_default" style="font-family:arial,sans-serif">
<font face="courier new, monospace"> $message['subject'] = $params['subject'];</font></div><div class="gmail_default" style="font-family:arial,sans-serif"><font face="courier new, monospace"> $message['body'][] = $params['body'];</font></div>
<div class="gmail_default" style="font-family:arial,sans-serif"><font face="courier new, monospace"> $message['attachments'][] = $params['attachment'];</font></div><div class="gmail_default" style="font-family:arial,sans-serif">
<font face="courier new, monospace"> break;</font></div><div class="gmail_default" style="font-family:arial,sans-serif"><font face="courier new, monospace"> }</font></div><div class="gmail_default" style="font-family:arial,sans-serif">
<font face="courier new, monospace">}</font></div></div></div><div class="gmail_extra"><div><div class="h5"><br><br><div class="gmail_quote">On Tue, Dec 17, 2013 at 11:37 PM, Muzaffer Tolga Ozses <span dir="ltr"><<a href="mailto:tolga@ozses.net" target="_blank">tolga@ozses.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:'courier new',monospace">Hi,</div><div class="gmail_default" style="font-family:'courier new',monospace">
<br></div><div class="gmail_default" style="font-family:'courier new',monospace">
I've been trying to develop this module. It does what I need, with the exception of e-mailing a PDF file. What is wrong with my code? It gives me 'Undefined variable $attachment' and doesn't e-mail the attachment.</div>
<div class="gmail_default" style="font-family:'courier new',monospace"><br></div><div class="gmail_default"><div class="gmail_default"><font face="courier new, monospace">function pass2pdf_email_pdf_to_user($form) {</font></div>
<div class="gmail_default"><font face="courier new, monospace"> global $user;</font></div><div class="gmail_default"><font face="courier new, monospace"> $account = $user;</font></div><div class="gmail_default"><font face="courier new, monospace"> require(libraries_get_path('fpdf') . '/fpdf.php');</font></div>
<div class="gmail_default"><font face="courier new, monospace"> $pdf = new FPDF();</font></div><div class="gmail_default"><font face="courier new, monospace"> $pdf->AddPage();</font></div><div class="gmail_default">
<font face="courier new, monospace"> $pdf->SetFont('Arial', 'B', 16);</font></div>
<div class="gmail_default"><font face="courier new, monospace"> $pdf->Image(theme_get_setting('logo'), 10, 6, 30);</font></div><div class="gmail_default"><font face="courier new, monospace"> $pdf->Cell(100, 100, $form['pass2pdf_pass']['#value']['pass1']);</font></div>
<div class="gmail_default"><font face="courier new, monospace"> $pdf->Output(drupal_realpath('public://') . '/' . $form['account']['name']['#value'] . '.pdf');</font></div>
<div class="gmail_default"><font face="courier new, monospace"> $to = $form['account']['mail']['#value'];</font></div><div class="gmail_default"><font face="courier new, monospace"> $from = variable_get('site_name') . "<" . variable_get('site_mail') . ">";</font></div>
<div class="gmail_default"><font face="courier new, monospace"> $subject = t('Your password from @site', array('@site' => variable_get('site_name')));</font></div><div class="gmail_default"><font face="courier new, monospace"> $body = t('Hello !user. Please find your password in the attached PDF file.', array('!user' => $form['account']['name']['#value']));</font></div>
<div class="gmail_default"><font face="courier new, monospace"> $attachment = array(</font></div><div class="gmail_default"><font face="courier new, monospace"> 'filecontent' => file_get_contents(drupal_realpath('public://') . '/'. $form['account']['name']['#value'] . '.pdf'),</font></div>
<div class="gmail_default"><font face="courier new, monospace"> 'filemime' => 'application/pdf',</font></div><div class="gmail_default"><font face="courier new, monospace"> );</font></div><div class="gmail_default">
<font face="courier new, monospace"> $params['subject'] = $subject;</font></div><div class="gmail_default"><font face="courier new, monospace"> $params['body'] = $body;</font></div><div class="gmail_default">
<font face="courier new, monospace"> $params['attachment'] = $attachment;</font></div><div class="gmail_default"><font face="courier new, monospace"> $message = drupal_mail('pass2pdf', 'key', $to, user_preferred_language($user), $params, $from, TRUE);</font></div>
<div class="gmail_default"><font face="courier new, monospace"> if ($message) {</font></div><div class="gmail_default"><font face="courier new, monospace"> drupal_set_message(t('E-mail sent successfully'));</font></div>
<div class="gmail_default"><font face="courier new, monospace"> }</font></div><div class="gmail_default"><font face="courier new, monospace">}</font></div><div class="gmail_default"><font face="courier new, monospace"><br>
</font></div><div class="gmail_default"><font face="courier new, monospace">function pass2pdf_mail($key, &$message, $attachment) {</font></div><div class="gmail_default"><font face="courier new, monospace"> switch($key) {</font></div>
<div class="gmail_default"><font face="courier new, monospace"> case 'key':</font></div><div class="gmail_default"><font face="courier new, monospace"> $message['subject'] = $subject;</font></div>
<div class="gmail_default">
<font face="courier new, monospace"> $message['body'][] = $body;</font></div><div class="gmail_default"><font face="courier new, monospace"> $message['attachments'][] = $attachment;</font></div>
<div class="gmail_default">
<font face="courier new, monospace"> break;</font></div><div class="gmail_default"><font face="courier new, monospace"> }</font></div><div class="gmail_default"><font face="courier new, monospace">}</font></div><div class="gmail_default">
<font face="courier new, monospace"><br></font></div><div class="gmail_default"><font face="courier new, monospace">Regards,</font></div></div></div>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div><a href="http://twinbit.it/" style="color:rgb(17,85,204);font-family:Consolas,Menlo,Monaco,'Andale Mono WT','Andale Mono','Lucida Console','Lucida Sans Typewriter','DejaVu Sans Mono','Bitstream Vera Sans Mono','Liberation Mono','Nimbus Mono L','Courier New',Courier,monospace;font-size:x-small" target="_blank"><img border="0" alt="TWINBIT logo" width="200" height="46"></a><span style="font-family:Consolas,Menlo,Monaco,'Andale Mono WT','Andale Mono','Lucida Console','Lucida Sans Typewriter','DejaVu Sans Mono','Bitstream Vera Sans Mono','Liberation Mono','Nimbus Mono L','Courier New',Courier,monospace;font-size:x-small"> </span><br style="font-family:Consolas,Menlo,Monaco,'Andale Mono WT','Andale Mono','Lucida Console','Lucida Sans Typewriter','DejaVu Sans Mono','Bitstream Vera Sans Mono','Liberation Mono','Nimbus Mono L','Courier New',Courier,monospace;font-size:x-small">
<br style="font-family:Consolas,Menlo,Monaco,'Andale Mono WT','Andale Mono','Lucida Console','Lucida Sans Typewriter','DejaVu Sans Mono','Bitstream Vera Sans Mono','Liberation Mono','Nimbus Mono L','Courier New',Courier,monospace;font-size:x-small">
<font style="font-family:arial,helvetica,sans-serif;color:rgb(51,51,51)"><font size="4">Paolo Mainardi</font> <br></font><i>Twinbit Founder - CTO<br style="font-family:Consolas,Menlo,Monaco,'Andale Mono WT','Andale Mono','Lucida Console','Lucida Sans Typewriter','DejaVu Sans Mono','Bitstream Vera Sans Mono','Liberation Mono','Nimbus Mono L','Courier New',Courier,monospace;font-size:x-small">
</i><br style="font-family:Consolas,Menlo,Monaco,'Andale Mono WT','Andale Mono','Lucida Console','Lucida Sans Typewriter','DejaVu Sans Mono','Bitstream Vera Sans Mono','Liberation Mono','Nimbus Mono L','Courier New',Courier,monospace;font-size:x-small">
<font face="Consolas, Menlo, Monaco, Courier New, Courier, monospace" color="#666666" style="font-family:Consolas,Menlo,Monaco,'Andale Mono WT','Andale Mono','Lucida Console','Lucida Sans Typewriter','DejaVu Sans Mono','Bitstream Vera Sans Mono','Liberation Mono','Nimbus Mono L','Courier New',Courier,monospace"><font face="Consolas, Menlo, Monaco, Courier New, Courier, monospace"><b>www</b>: <a href="http://twinbit.it/" style="color:rgb(241,126,14)" target="_blank">twinbit.it</a></font> <br>
<font face="Consolas, Menlo, Monaco, Courier New, Courier, monospace"><b>mobile</b>: <a value="+393895122611" style="color:rgb(17,85,204)">(+39) 3401678089</a></font> <br><font face="Consolas, Menlo, Monaco, Courier New, Courier, monospace"><b>skype</b>: paolo_mainardi</font> <br>
<font face="Consolas, Menlo, Monaco, Courier New, Courier, monospace"><b>linkedin</b>: <a href="http://www.linkedin.com/in/paolomainardi" style="color:rgb(241,126,14)" target="_blank">paolomainardi</a></font> <br><font face="Consolas, Menlo, Monaco, Courier New, Courier, monospace"><b>twitter</b>: <a href="http://twitter.com/paolomainardi" style="color:rgb(241,126,14)" target="_blank">@paolomainardi</a></font> <br>
<font face="Consolas, Menlo, Monaco, Courier New, Courier, monospace"><b>blog</b>: <a href="http://paolomainardi.com/" style="color:rgb(241,126,14)" target="_blank">paolomainardi.com</a></font> <br></font></div>
</font></span></div>
</blockquote></div><br></div>