Email attachment

All installation and configuration problems and questions

Moderators: gerski, enjay, williamconley, Op3r, Staydog, gardo, mflorell, MJCoate, mcargile, Kumba, Michael_N

Email attachment

Postby ClearCall » Sat May 09, 2015 5:46 pm

Is there any way to set the email Reply up so that it only put in mime information if there is actually 1 or more attachments? I would prefer if all my replies don't go out with an empty ATT00xxx.txt file.

*Edit:
It seems the reply with attachment isn't working. I just attempted a reply with a small text file attachment but the email I received only had the Vicidial generated ATT00168.txt file, which was empty.

I put in a flag in the REPLY code and set the message to include the flag. The code enters the FOR loop around line 203 but then whether there is an attachment or not the code does not enter the ELSE within the IF ($LF_orig) around line 211.

I removed the pound from the line echo "<p>".$$attachment_name."<BR/>".$$attachment_orig_name."<BR/>".$$attachment_path."<BR/><p>"; and nothing displayed on the screen.

Receiving attachments doesn't seem to work either.

Please advise.
VERSION: 2.14-620a BUILD: 170623-2142
Asterisk: 1.8.32.0-vici
Installed from Vicibox iso.
Vicibox Redux Ver 6.0.2-140825
Open Suse Leap 42.3
ClearCall
 
Posts: 164
Joined: Fri Dec 03, 2010 12:21 pm

Re: Email attachment

Postby williamconley » Sun Oct 18, 2015 11:50 am

1) How did you install your system? Vicibox? Goautodial with upgrades? Scratch/manual?

2) You're a bit behind in your Vicidial version. You may want to upgrade to the latest version and see if that helps as this is a very recent add-on for Vicidial and may still be "under construction" (just a guess, couldn't hurt to try).

3) Unfortunately, I have no clients presently using this function so I've never had to delve before.

4) If the code never enters the else, what is the condition of the IF? You should echo that during an execution and see what value it contains to cause the if to react incorrectly.

5) Happy Hunting! 8-)
Vicidial Installation and Repair, plus Hosting and Colocation
Newest Product: Vicidial Agent Only Beep - Beta
http://www.PoundTeam.com # 352-269-0000 # +44(203) 769-2294
williamconley
 
Posts: 20019
Joined: Wed Oct 31, 2007 4:17 pm
Location: Davenport, FL (By Disney!)

Re: Email attachment

Postby ClearCall » Thu Oct 29, 2015 9:43 am

I upgraded to lastest SVN yesterday -- VERSION: 2.12-515a BUILD: 151007-2224.
Agents still do not receive any attachments. The inbound_email_attachments table is empty.
All replies with no attachment still go out with an empty ATT00xxx.txt file of size 0B.
Replies with an attachment now send the attachment and also include an empty ATT00xxx.txt file with a non-zero file size.
ClearCall
 
Posts: 164
Joined: Fri Dec 03, 2010 12:21 pm

Re: Email attachment

Postby jjohnson78 » Thu Oct 29, 2015 11:55 pm

As far as emails arriving without attachments, I looked at a full debug output of the script that parses the email (AST_inbound_email_parser.pl) as it's coming from the account, and it seems that there has been a small but critical change to the email headers coming from Gmail (and probably elsewhere).

The parsing script looks for a header that indicates that a particular chunk is an attachment and grabs the Content-Type line in the same header to determine what kind of attachment it is.

These are the crucial lines, which appear twice, one time in both the IMAP and POP3 sections.


## Check to see if attachment is an accepted filetype
$sub_content_type=~/Content-Type\:\s+[^\;]+\;/i; $attachment_type=$&;
$attachment_type=~s/(^Content-Type\:\s+|\;$)//gi;
$attachment_type=~s/[\r\n]//g;


Because the matching line in the header typically reads:

Content-Type: application/vnd.oasis.opendocument.text;

HOWEVER, coming from at least Gmail, the Content-Type line in the examples I tested with read the following:

Content-Type: application/vnd.oasis.opendocument.text

i.e. there is no ending semicolon for that line so the pattern match fails and the resulting check for the attachment type never runs.

Try changing the above lines to the below lines where they appear in the file (again, two times):

## Check to see if attachment is an accepted filetype
$sub_content_type=~/Content-Type\:\s+[^\;]+(\;.*)?$/i; $attachment_type=$&;
$attachment_type=~s/(^Content-Type\:\s+|(\;.*)?$)//gi;
$attachment_type=~s/[\r\n]//g;


I did this and attachments starting coming through again, so I'd suggest changing those lines in your version of AST_inbound_email_parser.pl and seeing if that works.
jjohnson78
 
Posts: 57
Joined: Thu May 08, 2008 8:18 am

Re: Email attachment

Postby ClearCall » Fri Oct 30, 2015 9:49 am

I changed to the suggested code in both places. The email attachments table is still empty and now the body of the email message is truncated at the first new line character.
Please advise.
ClearCall
 
Posts: 164
Joined: Fri Dec 03, 2010 12:21 pm

Re: Email attachment

Postby jjohnson78 » Fri Oct 30, 2015 10:28 am

Run the script with the debugX option added and show the output. Leave out the dozens/hundreds of lines that are the encoded attachment.
jjohnson78
 
Posts: 57
Joined: Thu May 08, 2008 8:18 am

Re: Email attachment

Postby ClearCall » Fri Oct 30, 2015 12:05 pm

I ran the debug with the original code. It found the attachment but then skipped it because it said it couldn't find the name.
------=_NextPart_000_0066_01D11301.804BA070
Content-Type: text/plain;
name="todo.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="todo.txt"

Get email attachments working.


***
1)
***Post-HTML strip:
Test. Please reply.
***
Part content disposition is Content-Disposition: attachment;
Part content type is Content-Type: text/plain;.
Part content size is 237
Couldn't find file name with content-disposition. Searching full header for 'filename' value...
Couldn't find file name anywhere in header. Searching Content-Type for 'name' value...
!!!!WARNING - Found valid attachment, type text/plain
Attachment does not have file name. Skipping...

Found 0 attachments in email
ClearCall
 
Posts: 164
Joined: Fri Dec 03, 2010 12:21 pm

Re: Email attachment

Postby ClearCall » Fri Oct 30, 2015 2:33 pm

I ran the debug also with the suggested changes to the code and it encountered the same error about the file name.

Also, if my original email is:
Test.
Please reply.

Thanks,
Testing team

What I I get is:
Test. Please reply. Thanks, Testing team

The inbound_email_parser replaces all the new line characters with a single space, which is very annoying especially for long emails. I have tried various suggestions to fix this but to no avail.
ClearCall
 
Posts: 164
Joined: Fri Dec 03, 2010 12:21 pm

Re: Email attachment

Postby lvish » Fri May 19, 2017 11:58 pm

Hi

We have similar issue of attachment not getting parsed. --Attachment file name not found error.
Attachment type and file name is seen in the debugX. But filename is not getting parsed. Appreciate any inputs on this issue.



Below is the script debugX and error.

Attachment DID.xls is read by the script in below logs.
---------------------------------------------------------------------------

--------------020004090302050306020004
Content-Type: application/vnd.ms-excel;
name="DID.xls"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="DID.xls"

0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAOwADAP7/CQAGAAAAAAAAAAAAAAABAAAAEgAAAAAA
AAAAEAAADwAAAAEAAAD+////AAAAAAAAAAD/////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/////////////////////////////////
----------------------------------------------------------------------------------

But while parsing Filename not found error is displayed.
-----------------------------------------------------------------------------------------------------------------
Time stamp on email is 20 May 2017 09:00:28
Email message is multipart. Need to select the best format type and parse it.
Part content disposition is
Part content type is Content-Type: text/plain; charset=utf-8; format=flowed.
Part content size is 1148
First acceptable content-type match is text/plain. Stripping headers to get text...
Part content disposition is Content-Disposition: attachment;
Part content type is Content-Type: application/vnd.ms-excel;.
Part content size is 14944
Couldn't find file name with content-disposition. Searching full header for 'filename' value...
Couldn't find file name anywhere in header. Searching Content-Type for 'name' value...
!!!!WARNING - Found valid attachment, type application/vnd.ms-excel
Attachment does not have file name. Skipping...

--------------------------------------------------------------------------------------------------




lvish

-------Vicibox 7.0.4 ---VERSION: 2.14-605a-- BUILD: 170327-1655 --DELL R730 -- All in one Standalone server.
lvish
lvish
 
Posts: 103
Joined: Tue Jan 25, 2011 4:56 am

Re: Email attachment

Postby lvish » Mon May 22, 2017 7:49 am

Hi

Was able isolate the issue ,

Email sent from gmail weblogin has below attachment headers which are getting parsed. If the same mail sent from thuderbird or outlook header will change and filename moves to next line (log capture mentioned in my previous post).


---------------------------------------
--94eb2c0edcfc1aca9005501be85f--
--94eb2c0edcfc1aca9505501be861
Content-Type: application/vnd.ms-excel; name="DID.xls"
Content-Disposition: attachment; filename="DID.xls"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_j303ovil0

-----------------------------------------------------



I guess script is not able to match the pattern from the next line.

May be this code below needs to be tweaked to search for next line or next two lines which may be a fix. Any help on this highly appreciated.

---------------------------
## Check to see if attachment is an accepted filetype
$sub_content_type=~/Content-Type\:\s+[^\;]+(\;.*)?$/i; $attachment_type=$&;
$attachment_type=~s/(^Content-Type\:\s+|(\;.*)?$)//gi;
$attachment_type=~s/[\r\n]//g;
---------------------------------------------------------------
lvish
lvish
 
Posts: 103
Joined: Tue Jan 25, 2011 4:56 am

Re: Email attachment

Postby jjohnson78 » Mon May 22, 2017 10:09 pm

I made some modifications to the pattern matching that does one more attempt at finding the file attachment and also uses a slightly more inclusive pattern-match check (which hopefully won't pick up anything it shouldn't). Give it a try with the usual full debug output, if you could. Downloadable here

http://www.vicidial.org/VICIDIALmantis/ ... 4&type=bug

You'll need to rename it to AST_inbound_email_parser.pl
jjohnson78
 
Posts: 57
Joined: Thu May 08, 2008 8:18 am

Re: Email attachment

Postby lvish » Tue May 23, 2017 11:07 am

Thank you , script is working even if the filename is in the next line.

regds

lvish
lvish
lvish
 
Posts: 103
Joined: Tue Jan 25, 2011 4:56 am


Return to Support

Who is online

Users browsing this forum: Google [Bot] and 78 guests