oh, Thanks Pascal, very useful :-)
On 12/feb/2010, at 04.23, Pascal Robert wrote:
>
> Le 2010-02-11 à 13:37, Amedeo Mantica a écrit :
>
>> Actually my system doesn't handle Bounces, but check if a recipiend have
>> read email putting an image in the email that calls a direct action
>> Pascal suggested me the way POP/IMAP to handle bounces too, I hope to
>> implement it soon
>
> First draft :
>
> package org.wocommunity.massmailing;
>
> import java.util.Properties;
>
> import javax.mail.Folder;
> import javax.mail.internet.MimeMessage;
>
> import com.sun.mail.dsn.DeliveryStatus;
> import com.sun.mail.imap.IMAPFolder;
> import com.sun.mail.imap.IMAPStore;
> import com.webobjects.foundation.NSLog;
>
> import er.extensions.foundation.ERXProperties;
>
>
> public class EmailBounces {
> private IMAPStore imapStore;
> private IMAPFolder inbox;
>
> public EmailBounces() {
>
> }
>
> public boolean openIMAPConnection() {
> String imapUserName =
> ERXProperties.stringForKey("imap.username");
> String imapUserPasswd =
> ERXProperties.stringForKey("imap.password");
> String imapServerHostName =
> ERXProperties.stringForKey("imap.host");
> String smtpServerHostName =
> ERXProperties.stringForKey("mail.smtp.host");
>
> try {
> Properties props = System.getProperties();
> props.put("mail.smtp.host",smtpServerHostName);
> javax.mail.Session sessionEmail =
> javax.mail.Session.getDefaultInstance(props,null);
> sessionEmail.setDebug(false);
> imapStore = (IMAPStore)sessionEmail.getStore("imap");
> imapStore.connect(imapServerHostName, imapUserName,
> imapUserPasswd);
> inbox = (IMAPFolder)imapStore.getFolder("INBOX");
> inbox.open(Folder.READ_ONLY);
> return true;
> } catch (Exception ex) {
> ex.printStackTrace();
> return false;
> }
> }
>
> public boolean closeIMAPConnection(boolean purgeDeletedMessages) {
> try {
> inbox.close(purgeDeletedMessages);
> imapStore.close();
> return true;
> } catch (Exception ex) {
> ex.printStackTrace();
> return false;
> }
> }
>
> public void findBouncesInInbox() {
> try {
> for (int i = 1; i <= inbox.getMessageCount(); i++) {
> MimeMessage message =
> (MimeMessage)inbox.getMessage(i);
> if (message.isMimeType("multipart/report")) {
> Object content = message.getContent();
> if (content instanceof
> com.sun.mail.dsn.MultipartReport) {
>
> com.sun.mail.dsn.MultipartReport report =
> (com.sun.mail.dsn.MultipartReport)content;
> Object status =
> report.getReport();
> if (status instanceof
> com.sun.mail.dsn.DeliveryStatus) {
> DeliveryStatus
> statusReport = (DeliveryStatus)status;
> /*
> * The optional
> Arrival-Date field indicates the date and time at which the message arrived
> at the Reporting MTA. If the Last-Attempt-Date field is also provided in a
> per-recipient field, this can be used to determine the interval between when
> the message arrived at the Reporting MTA and when the report was issued for
> that recipient.
> */
>
> NSLog.out.appendln(statusReport.getMessageDSN().getHeader("Arrival-Date")[0]);
> /*
> * A DSN describes the
> results of attempts to deliver, relay, or gateway a message to one or more
> recipients. In all cases, the Reporting-MTA is the MTA which attempted to
> perform the delivery, relay, or gateway operation described in the DSN. This
> field is required.
> */
>
> NSLog.out.appendln(statusReport.getMessageDSN().getHeader("Reporting-MTA")[0]);
> for (int k = 0; k <
> statusReport.getRecipientDSNCount(); k++) {
> /*
> * The
> Original-Recipient field indicates the original recipient address as
> specified by the sender of the message for which the DSN is being issued.
> */
>
> NSLog.out.appendln(statusReport.getRecipientDSN(k).getHeader("Original-Recipient")[0]);
> /*
> * The
> Final-Recipient field indicates the recipient for which this set of
> per-recipient fields applies. This field MUST be present in each set of
> per-recipient data.
> */
>
> NSLog.out.appendln(statusReport.getRecipientDSN(k).getHeader("Final-Recipient")[0]);
> /*
> * The Action
> field indicates the action performed by the Reporting-MTA as a result of its
> attempt to deliver the message to this recipient address. This field MUST be
> present for each recipient named in the DSN.
> * Possible values :
> failed, delayed, delivered, relayed
> */
>
> NSLog.out.appendln(statusReport.getRecipientDSN(k).getHeader("Action")[0]);
> /*
> * The
> per-recipient Status field contains a transport-independent status code which
> indicates the delivery status of the message to that recipient. This field
> MUST be present for each delivery attempt which is described by a DSN.
> * Status codes
> thus consist of three numerical fields separated by ".". The first sub-field
> indicates whether the delivery attempt was
>
> successful (2 = success, 4 = persistent temporary failure, 5 = permanent
> failure). The second sub-field indicates the probable
> source
> of any delivery anomalies, and the third sub-field denotes a precise error
> condition, if known.
> * Example :
> 5.4.4
> */
>
> NSLog.out.appendln(statusReport.getRecipientDSN(k).getHeader("Status")[0]);
> /*
> * For a
> "failed" or "delayed" recipient, the Diagnostic-Code DSN field contains the
> actual diagnostic code issued by the mail transport. Since such codes vary
> from one mail transport to another, the diagnostic-type subfield is needed to
> specify which type of diagnostic code is represented.
> * Example :
> DNS; Host not found
> */
>
> NSLog.out.appendln(statusReport.getRecipientDSN(k).getHeader("Diagnostic-Code")[0]);
> }
> }
> } else {
> NSLog.out.appendln("WTF? : " +
> content.getClass().getName());
> }
> }
> }
> } catch (Exception nspex) {
> nspex.printStackTrace();
> }
> }
>
> }
>
>> Regards
>> Amedeo
>>
>> On 11/feb/2010, at 19.19, Tusker wrote:
>>
>>> This looks great! What about handling bounces? I work in a really small
>>> team so would creating/setting up/maintaining this type of system might be
>>> too much? Like it was mentioned before, you can just let MailChimp handle
>>> all this. The only problem with that is the fact that we have to store our
>>> customer data on their servers.
>>>
>>> M
>>>
>>> On Feb 11, 2010, at 3:49 AM, Amedeo Mantica wrote:
>>>
>>>> Hello,
>>>>
>>>> Some time ago I have made some work for sending "bulk" emails... Let me
>>>> explain how it works, because I think that may be a good start
>>>>
>>>> 1) Mailing List management
>>>>
>>>> Two Entities MailRecipient (emails) and and MailingList (groups) in a
>>>> many-to-many relationship
>>>> I made an UI for managing Lists and email, insert / remove bulk emails
>>>> automatically handling spaces, commas, carriage returns, duplicate
>>>> addresses, etc...
>>>>
>>>> 2) Mail Templates
>>>>
>>>> In a very similar manner as Appe Mail.app templates, I have made a folder
>>>> with some mail templates
>>>>
>>>> 3) Email Sending
>>>>
>>>> The user can Send an email using a web form that contains an html editor
>>>> or can send an article published in the website (in my case), I also
>>>> handle attchments sending them as links.
>>>> I have a Class called MailTask that take care of sending email in a
>>>> separate Thread while the user can continue to use the webapp/website, and
>>>> can evantually close session without stopping sending.
>>>>
>>>> 4) Email Read checking
>>>>
>>>> The MailTask thread personalize each email with a special blank image (
>>>> 1px ) that call a Direct Action that set a timestamp to the MailRecipient
>>>> raw so you know when that email address had last access.
>>>>
>>>> Please see screenshots at:
>>>> http://downloads.insigno.net/Amedeo/MailingList.pdf
>>>>
>>>> Please le me know what you think about this and if you have some ideas to
>>>> improve this work. Actually is still not an indipendent framework, but i'm
>>>> working to make it universal and share it with wo community.
>>>>
>>>> Regards
>>>> Amedeo
>>>>
>>>> On 10/feb/2010, at 19.44, Tusker wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> Is there any webobjects api which will allow sending out mass amounts of
>>>>> custom emails (~200K / week) and also handles the bounces? I know there
>>>>> are some stand-alone applications which do just that, but I need this
>>>>> integrated tightly with WO and to work with my EOF data. Should I use
>>>>> Project Wonder ERJavaMail and will it be able to handle the number of
>>>>> emails we plan on sending out? Any suggestions or ideas would be greatly
>>>>> appreciated.
>>>>>
>>>>> Thanks,
>>>>> M
>>>>> _______________________________________________
>>>>> Do not post admin requests to the list. They will be ignored.
>>>>> Webobjects-dev mailing list ([email protected])
>>>>> Help/Unsubscribe/Update your Subscription:
>>>>> http://lists.apple.com/mailman/options/webobjects-dev/amedeomailing%40insigno.it
>>>>>
>>>>> This email sent to [email protected]
>>>>>
>>>>
>>>
>>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list ([email protected])
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/webobjects-dev/probert%40macti.ca
>>
>> This email sent to [email protected]
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]