Topic
1 reply Latest Post - ‏2011-09-23T19:06:52Z by SystemAdmin
null
null
1 Post
ACCEPTED ANSWER

Pinned topic [zero.core.connection.EmailConnection.addAttachment] filename maxlength

‏2011-09-16T08:26:36Z |
Hi, I am using zero.core.connection.EmailConnection. I was trying to send attachment in mail and found that the length of filename of attachment can't exceed 59 characters.

$response = $emailConn->doGET('file:///~/public/samples/' . $filepath);
$fileStream = $response->getResponseBodyInputStream();
$emailConn->addAttachment($fileStream, null, $fileName);

If the filename is 60 chars or more, the filename in mail will be cut and the file is broken.

Is it a limitation of this method or caused by something else?
Is there a way to use the long filename?

I will appreciate if you could provide any answer / suggestion. Thanks!

Edited by: jeffo_admin on Sep 26, 2011 11:05 AM
Updated on 2011-09-23T19:06:52Z at 2011-09-23T19:06:52Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    9224 Posts
    ACCEPTED ANSWER

    Re: [zero.core.connection.EmailConnection.addAttachment] filename maxlength

    ‏2011-09-23T19:06:52Z  in response to null
    No obvious limitation in the code. Reproducible in a simple, local sample. Given the resulting corruption in the attachment (header info instead of attachment content), it looks like a sMash bug.

    including a sample here that will generate the problem
    index.groovy
    
    
    
    import zero.core.connection.EmailConnection; 
    
    import zero.core.connection.ConnectionException; 
    
    import zero.core.connection.MultipartBody;   System.out.println(
    "Start\n"); 
    
    try 
    { EmailConnection email = 
    
    new EmailConnection(
    "user@domain.com"); email.setFromAddress(
    "user@domain.com"); email.setSubject(
    "Hello to me"); email.setContent(
    "Please read the attachment."); email.addAttachment(
    "This is the content of the attachment", 
    "text/plain; charset=\"UTF-8\"", 
    "attachmentattachmentattachmentattachmentattachmentattachment1.txt"); email.send(); 
    } 
    
    catch (Exception e) 
    { 
    // failed to send e-mail System.out.println(
    "FAIL\n"); 
    } System.out.println(
    "emailconnection complete\n");
    


    requires an smtp server config in zero.config:
    
    /config/connection/defaults/smtp/hostname = 
    "smtp.relay.domain.com"
    


    At this point it is a limitation in that there is no workaround/option for a longer filename with the emailconnection api. I'll update if we find something that helps relieve the limitation.