Search in sources :

Example 1 with ParsedAddress

use of com.zimbra.cs.mime.ParsedAddress in project zm-mailbox by Zimbra.

the class SenderList method importAddress.

private static ParsedAddress importAddress(Metadata meta) {
    if (meta == null)
        return null;
    ParsedAddress pa = new ParsedAddress(meta.get(FN_EMAIL, null), meta.get(FN_PERSONAL, null));
    pa.firstName = meta.get(FN_DISPLAY, null);
    return pa;
}
Also used : ParsedAddress(com.zimbra.cs.mime.ParsedAddress)

Example 2 with ParsedAddress

use of com.zimbra.cs.mime.ParsedAddress in project zm-mailbox by Zimbra.

the class SenderList method toString.

@Override
public String toString() {
    Metadata meta = new Metadata();
    meta.put(Metadata.FN_NODES, mSize);
    meta.put(Metadata.FN_LAST_DATE, mLastDate);
    meta.put(Metadata.FN_ELIDED, mIsElided);
    if (mParticipants != null && !mParticipants.isEmpty()) {
        MetadataList entries = new MetadataList();
        for (ParsedAddress pa : mParticipants) entries.add(exportAddress(pa));
        meta.put(Metadata.FN_ENTRIES, entries);
    }
    return meta.toString();
}
Also used : ParsedAddress(com.zimbra.cs.mime.ParsedAddress)

Example 3 with ParsedAddress

use of com.zimbra.cs.mime.ParsedAddress in project zm-mailbox by Zimbra.

the class SenderList method add.

public SenderList add(Message msg) throws RefreshException {
    String sender = msg.getSender();
    if (sender == null || sender.trim().equals("")) {
        mSize++;
        return this;
    }
    long date = msg.getDate();
    if (date < mLastDate)
        throw new RefreshException("appended message predates existing last message");
    mLastDate = date;
    mSize++;
    ParsedAddress pa = new ParsedAddress(sender).parse();
    if (mParticipants == null) {
        (mParticipants = new ArrayList<ParsedAddress>(MAX_PARTICIPANT_COUNT)).add(pa);
    } else {
        mParticipants.remove(pa);
        mParticipants.add(0, pa);
        while (mParticipants.size() > MAX_PARTICIPANT_COUNT) {
            mParticipants.remove(MAX_PARTICIPANT_COUNT);
            mIsElided = true;
        }
    }
    return this;
}
Also used : ParsedAddress(com.zimbra.cs.mime.ParsedAddress)

Example 4 with ParsedAddress

use of com.zimbra.cs.mime.ParsedAddress in project zm-mailbox by Zimbra.

the class SocialcastTest method executeBasic.

@Override
protected boolean executeBasic(MailAdapter mail, Arguments args, SieveContext ctx) throws SieveException {
    if (mail instanceof DummyMailAdapter) {
        return true;
    }
    if (!(mail instanceof ZimbraMailAdapter)) {
        return false;
    }
    ZimbraMailAdapter adapter = (ZimbraMailAdapter) mail;
    ParsedMessage pm = adapter.getParsedMessage();
    ParsedAddress sender = pm.getParsedSender();
    if (!Strings.isNullOrEmpty(sender.emailPart) && sender.emailPart.endsWith("@socialcast.com")) {
        try {
            if (pm.getMimeMessage().getHeader("Reply-To", null) != null) {
                // test if Reply-To exists
                return true;
            }
        } catch (MessagingException ignore) {
        }
    }
    return false;
}
Also used : MessagingException(javax.mail.MessagingException) ParsedMessage(com.zimbra.cs.mime.ParsedMessage) DummyMailAdapter(com.zimbra.cs.filter.DummyMailAdapter) ZimbraMailAdapter(com.zimbra.cs.filter.ZimbraMailAdapter) ParsedAddress(com.zimbra.cs.mime.ParsedAddress)

Example 5 with ParsedAddress

use of com.zimbra.cs.mime.ParsedAddress in project zm-mailbox by Zimbra.

the class TwitterTest method executeBasic.

@Override
protected boolean executeBasic(MailAdapter mail, Arguments args, SieveContext ctx) throws SieveException {
    if (mail instanceof DummyMailAdapter) {
        return true;
    }
    if (!(mail instanceof ZimbraMailAdapter)) {
        return false;
    }
    ZimbraMailAdapter adapter = (ZimbraMailAdapter) mail;
    ParsedAddress sender = adapter.getParsedMessage().getParsedSender();
    if (!Strings.isNullOrEmpty(sender.emailPart)) {
        String email = sender.emailPart.toLowerCase();
        if (email.equals("notify@twitter.com")) {
            return true;
        }
    }
    return false;
}
Also used : DummyMailAdapter(com.zimbra.cs.filter.DummyMailAdapter) ZimbraMailAdapter(com.zimbra.cs.filter.ZimbraMailAdapter) ParsedAddress(com.zimbra.cs.mime.ParsedAddress)

Aggregations

ParsedAddress (com.zimbra.cs.mime.ParsedAddress)10 DummyMailAdapter (com.zimbra.cs.filter.DummyMailAdapter)4 ZimbraMailAdapter (com.zimbra.cs.filter.ZimbraMailAdapter)4 InternetAddress (com.zimbra.common.mime.InternetAddress)2 ServiceException (com.zimbra.common.service.ServiceException)2 ArrayList (java.util.ArrayList)2 Element (com.zimbra.common.soap.Element)1 AccountServiceException (com.zimbra.cs.account.AccountServiceException)1 MailServiceException (com.zimbra.cs.mailbox.MailServiceException)1 Mailbox (com.zimbra.cs.mailbox.Mailbox)1 Message (com.zimbra.cs.mailbox.Message)1 SenderList (com.zimbra.cs.mailbox.SenderList)1 ParsedContact (com.zimbra.cs.mime.ParsedContact)1 ParsedMessage (com.zimbra.cs.mime.ParsedMessage)1 CreateContact (com.zimbra.cs.redolog.op.CreateContact)1 ModifyContact (com.zimbra.cs.redolog.op.ModifyContact)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 MessagingException (javax.mail.MessagingException)1 MimeMessage (javax.mail.internet.MimeMessage)1