Sent email tables and attachments.

A place for users and developers of the Xataface to discuss and receive support.

Sent email tables and attachments.

Postby jvinolas » Wed Nov 30, 2011 2:06 am

Hi Steve,

This a two-question topic:

1.- I can see in database that there are few tables related to emails:
- newsletters
- newsletters__history
- newsletters__newsletters
If I show (through conf.ini) the 'newsletters tables', I can see some fields from those sent mails. The problem is that other fields like 'recipients' seem to go to 'join_table' that seems to be 'newsletters__newsletters', but nothing in that table.

How can I show complete information of sent mails with the module?

2.- I'm trying to add attachment to emails. I would like to know if it is already implemented through configuration files or I have to code it. If I have to code it, is this what I should do?:
- Modify newsletters table creation (in email.php) to add blow field
- Modify email template to add upload field. (maybe this is not necessary if I do previous modification as email_form.html seems to get fields from table)
- Modify email.php to extract blob data from table and add it to //$at[] = MIME::message('source file', 'text/plain', 'file.txt', 'ISO-8859-1', 'base64', 'attachment'); (better to get file_type automatically before)

Another option (maybe better one) will be to add upload field to template and save it to disk and delete it after sending email.

Thanks in advance!
jvinolas
 
Posts: 51
Joined: Thu Apr 15, 2010 12:31 am

Re: Sent email tables and attachments.

Postby jvinolas » Thu Dec 01, 2011 7:15 am

Hi again,

I'm almost done with email attachment. The only problem is that I can't figure out how to get data from blob field correctly to compose message.

This is what I have right now:

Changed function createEmailTables to add blob field:
Code: Select all
      if ( isset($tablename) ){
         $sql[] = "create table if not exists `{$tablename}` (
         `id` int(11) not null auto_increment,
         `subject` varchar(128) not null,
         `cc` varchar(128) default null,
         `from` varchar(128) default null,
         `content` text,
           `attachment` longblob,
           `attachment_mimetype` varchar(64) DEFAULT NULL,
           `attachment_filename` varchar(64) DEFAULT NULL,
         `ignore_blacklist` tinyint(1) default 0,
         primary key (`id`))";


Added an attachField to the form (handle)
Code: Select all
      $attachField =& $emailTableObj->getField('attachment');
      $attachField['widget']['label'] = 'Attachment';
      $attachField['widget']['type'] = 'file';


And here it comes the problem. In sendMail function I try to retrieve blob field. Mimetype and Filename are correct, but it seems I'm missing something with data field as I get nothing on email contents:

Code: Select all
   $file=$email->val('attachment');
   $filemime=$email->strval('attachment_mimetype');
   $filename=$email->strval('attachment_filename');

   $at[] = MIME::message($file, $filemime, $filename, null, 'base64', 'inline', $id);
        // compose mail message in MIME format
   $mess = MIME::compose($text, $html,$at);


Have you got any idea why it is not working? I tried reading file from disk with file_get_contents and it worked like a charm!
jvinolas
 
Posts: 51
Joined: Thu Apr 15, 2010 12:31 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 8 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved