Re: Fwd: E-mail attachments
Gene Clark <[email protected]> Sun, 29 Dec 2013 21:38:58 -0500
| Newsgroups | gmane.comp.php.drupal.devel |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail-ECA8CBCE-7699-4D4D-B659-D674F4B1F17C Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Shut up I'm sick of your stupid emails!!!! On Dec 29, 2013, at 6:47 PM, Rob Thorne <[email protected]> wrote: I don't see anything obviously wrong in your sample, but after comparing you= r implementation with mine from a recent project, I see a couple of differen= ces: 1. You mention using the mimemail module, but are you also using the mailsys= tem module? The simplest explanation would be that mimemail is not getting i= nvoked at all. 2. If I recall correctly, some fields you can set in the "message" array ups= tream can get unset before hook_mail is called for you. So you may need to p= ut these items into your "params" array and hammer them in as part of your h= ook_mail implementation. My code looks like this: Sending the mail: $mail_params =3D array( 'subject' =3D> $settings['subject'], 'message' =3D> $settings['message'], 'headers' =3D> array( 'Content-Type' =3D> 'text/html; charset=3DUTF-8' ), 'attachments' =3D> $attachments, 'voter' =3D> $credit_app, ); $mail_params['plain'] =3D FALSE; $mail_params['plaintext'] =3D $mail_params['message']; if (!empty($settings['bcc'])) { $mail_params['headers']['Bcc'] =3D $settings['bcc']; } =20 $message =3D drupal_mail('mymodule', 'send-test', $address, $language, $ma= il_params, $from); In my hook_mail implementation: switch ($key) { case 'send-test': $message['subject'] =3D $params['subject']; $message['body'][] =3D $params['message']; $message['headers'] =3D array_merge($message['headers'], $params['head= ers']); break; } =20 Note also that I'm setting some parameters that you are not setting ('plain'= , 'plaintext'); I believe I added those after debugging the problem you're h= aving here. Hope this helps, Rob Rob Thorne Torenware Networks > On Dec 29, 2013, at 12:50 PM, Muzaffer Tolga Ozses <[email protected]> wrote= : >=20 > Hi, >=20 > I keep developing my module, and inside it I am sending e-mail. I am also t= rying to attach a file, to no avail. I have installed mimemail, I have chang= ed mime type in my code, I have dpm'd everything. dpm gives me correct value= s, and the subject and body of the e-mail come through, but I couldn't get f= ile attachment to work at all. What else can I do? >=20 > Regards, >=20 > PS: You can see the code at http://drupalcode.org/sandbox/Kartagis/1543120= .git/blob/da47378:/pass2pdf.module#l69 --Apple-Mail-ECA8CBCE-7699-4D4D-B659-D674F4B1F17C Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable <html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=3D= utf-8"></head><body dir=3D"auto"><div>Shut up I'm sick of your stupid emails= !!!!<br><br><div style=3D"-webkit-tap-highlight-color: rgba(26, 26, 26, 0.29= 2969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webki= t-composition-frame-color: rgba(77, 128, 180, 0.230469); font-family: Helvet= ica; font-size: medium; -webkit-text-size-adjust: auto; "><br></div></div><d= iv><br>On Dec 29, 2013, at 6:47 PM, Rob Thorne <<a href=3D"mailto:rob@tor= enware.com">[email protected]</a>> wrote:<br><br></div><div><meta http-eq= uiv=3D"Content-Type" content=3D"text/html charset=3Diso-8859-1">I don't see a= nything obviously wrong in your sample, but after comparing your implementat= ion with mine from a recent project, I see a couple of differences:<div><br>= </div><div>1. You mention using the mimemail module, but are you also using t= he mailsystem module? The simplest explanation would be that mimemail i= s not getting invoked at all.</div><div>2. If I recall correctly, some field= s you can set in the "message" array upstream can get unset before hook_mail= is called for you. So you may need to put these items into your "para= ms" array and hammer them in as part of your hook_mail implementation.  = ;My code looks like this:</div><div><br></div><div>Sending the mail:</div><d= iv><br></div><div><blockquote style=3D"margin: 0 0 0 40px; border: none; pad= ding: 0px;"><div><div> $mail_params =3D array(</div><div> = 'subject' =3D> $settings['subject'],</div><div> 'message' =3D= > $settings['message'],</div><div> 'headers' =3D> array(<= /div><div> 'Content-Type' =3D> 'text/html; charset=3D= UTF-8'</div><div> ),</div><div> 'attachments' =3D&= gt; $attachments,</div><div> 'voter' =3D> $credit_app,</div>= <div> );</div><div> $mail_params['plain'] =3D FALSE;</div><div>&= nbsp; $mail_params['plaintext'] =3D $mail_params['message'];</div><div> = ; if (!empty($settings['bcc'])) {</div><div> $mail_params['head= ers']['Bcc'] =3D $settings['bcc'];</div><div> }</div><div> = </div><div> $message =3D drupal_mail('mymodule', 'send-test', $address= , $language, $mail_params, $from);</div></div><div><br></div></blockquote></= div><div>In my hook_mail implementation:</div><div><br></div><div><blockquot= e style=3D"margin: 0 0 0 40px; border: none; padding: 0px;"><div><div> = switch ($key) {</div><div> case 'send-test':</div><div> &= nbsp; $message['subject'] =3D $params['subject'];</div><div> &n= bsp; $message['body'][] =3D $params['message'];</div><div> &nbs= p; $message['headers'] =3D array_merge($message['headers'], $params['= headers']);</div><div> break;</div><div> } <= /div></div><div><br></div></blockquote></div><div>Note also that I'm setting= some parameters that you are not setting ('plain', 'plaintext'); I be= lieve I added those after debugging the problem you're having here.</div><di= v><br></div><div>Hope this helps,</div><div><br></div><div>Rob</div><div><br= ><div> <div>Rob Thorne</div><div>Torenware Networks</div><div><br></div><br class=3D= "Apple-interchange-newline"> </div> <br><div><div>On Dec 29, 2013, at 12:50 PM, Muzaffer Tolga Ozses <<a href= =3D"mailto:[email protected]">[email protected]</a>> wrote:</div><br class=3D= "Apple-interchange-newline"><blockquote type=3D"cite"><div dir=3D"ltr"><div c= lass=3D"gmail_default" style=3D"font-family:courier new,monospace">Hi,<br></= div><div class=3D"gmail_quote"><div dir=3D"ltr"><div style=3D"font-family:'c= ourier new',monospace"><br></div><div style=3D"font-family:'courier new',mon= ospace"> I keep developing my module, and inside it I am sending e-mail. I am also tr= ying to attach a file, to no avail. I have installed mimemail, I have change= d mime type in my code, I have dpm'd everything. dpm gives me correct values= , and the subject and body of the e-mail come through, but I couldn't get fi= le attachment to work at all. What else can I do?</div> <div style=3D"font-family:'courier new',monospace"><br></div><div style=3D"f= ont-family:'courier new',monospace">Regards,</div><div style=3D"font-family:= 'courier new',monospace"> <br></div><div style=3D"font-family:'courier new',monospace">PS: You can see= the code at <a href=3D"http://drupalcode.org/sandbox/Kartagis/1543120.= git/blob/da47378:/pass2pdf.module#l69" target=3D"_blank">http://drupalcode.o= rg/sandbox/Kartagis/1543120.git/blob/da47378:/pass2pdf.module#l69</a></div> </div> </div><br></div> </blockquote></div><br></div></div></body></html>= --Apple-Mail-ECA8CBCE-7699-4D4D-B659-D674F4B1F17C--