• 1 reply
  • Latest Post - ‏2011-09-23T19:06:52Z by SystemAdmin
1 Post

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
    9224 Posts

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

    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
    import zero.core.connection.EmailConnection; 
    import zero.core.connection.ConnectionException; 
    import zero.core.connection.MultipartBody;   System.out.println(
    { EmailConnection email = 
    new EmailConnection(
    ""); email.setFromAddress(
    ""); 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(
    } System.out.println(
    "emailconnection complete\n");

    requires an smtp server config in zero.config:
    /config/connection/defaults/smtp/hostname = 

    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.