Parsing e-mails

Hi Guys,
I'm trying to figure out a simple way to use regex (or any other alternative) to parse e-mails from a text file...
let's say I have a text file, "something test [email protected] more test and now another [email protected] and that's it"
Anyone have ideas as far as parsing a string to extract e-mails only? I think regex is the way to go, but I don't even know where to start.
Thanks
Lucy,

I wouldn't know how to extract multiple e-mail addresses from a String using the dark force called regex.
But here's another way to achieve it:
     public String[] getEMailAddresses(String str) {
          List<String> list = new ArrayList<String>();
          while(str.indexOf('@') != -1) {     
               int index = str.indexOf('@');
               int begin = 0;
               int end = 0;
               for(int i = index-1; i >= 0; i--)
                    if(str.charAt(i) == ' ') { begin = i+1; break; }
               for(int i = index+1; i < str.length(); i++)
                    if(str.charAt(i) == ' ') { end = i;      break; }
               list.add(str.substring(begin, end));
               str = str.substring(0, begin)+str.substring(end, str.length());
               System.out.println(str);
          return list.toArray(new String[list.size()]);
     }Note: this code does not look for valid e-mail addresses and there are numerous things that can go wrong! Debug it and adjust it to your needs if you wish.
Good luck.

Similar Messages

  • How to parse raw mail message into JavaMail MimeMessage?

    Hello developers,
    I'm trying to implement the following functionality:
    * Postfix accepts incoming mail message and feeds it into java application
    * java application reads the input and parses it into JavaMail Message object
    There is no trouble with first part, though, as far as I've seen, JavaMail is mostly used for creating messages part by part, sending them or checking existing mailboxes. Is there a way to read message on the fly without any sessions and connections to mailbox provider service, which I do not need?
    Thanks,
    Tomas Varaneckas

    Don't see why not. I notice that almost everything in JavaMail that returns a Message object is a method of the Folder class, which is abstract. So you could write a subclass of Folder and have it return Message objects in whatever way you liked.

  • Mailing lists are no longer being parsed for individual address to be placed in the email 'To' field.

    When I attempt to use a Mailing List, which has worked in the past, to supply the addresses for an email which I wish to send, it fails with an error message as per this example:
    "MAILING LIST NAME (current)" <"MAILING LIST NAME (current)"> is not a valid e-mail address because it is not of the form user@host. You must correct it before sending the e-mail.
    It seems that Thunderbird can no longer parse the Mailing List for the individual names and addresses.
    Do you need any more info?
    Thanks for your help.

    As you may need this fixed quickly: You could uninstall the current version via Control panel > Programs and Features and reinstall a previous version, download from here:
    Version 31.0:
    * ftp://ftp.mozilla.org/pub/mozilla.org/thunderbird/releases/31.0/
    Version 24.7:
    * ftp://ftp.mozilla.org/pub/mozilla.org/thunderbird/releases/24.7.0/
    click on the type for your OS. eg: If using Windows select 'win32'
    then select the language eg: en-GB = English british
    then download the .exe file
    The thunderbird program is not stored in the same place as your thunderbird Profile. So, uninstalling and reinstalling should not effect anything in the profile folder including emails, address books etc.
    However, it is always a good idea to backup your Profile, just in case :) You can use tools such as MoxBackup and/or ImportExporttool or manually copy your Profile folder to an external device. All info at links below:
    * http://kb.mozillazine.org/Profile_backup
    * http://kb.mozillazine.org/IMAP_backup
    * http://mozbackup.jasnapaka.com/
    * https://addons.mozilla.org/en-US/thunderbird/addon/importexporttools/

  • Why I can Send Mail Here -- Plz Help

    Hi All,
    I m trying to send Mails to multiple users with the MailerBackp.java. But it is trowing some exception in parsing the InternetAddress
    import java.util.*;
    import java.util.concurrent.*;
    public class MailerBackup {
         private final FileCollection to;
         private static ArrayList<String> emails ;
         public MailerBackup(String addressFile){
              to = new FileCollection(addressFile);
              emails = new ArrayList<String>();
              //No of remaining emails.
              int remaining = to.size();
              System.out.println("Remaining is: "+remaining);
              int noOfmailAtATime = 500;
              int counter = remaining/noOfmailAtATime;
              System.out.println("Counter is == "+counter + "   no of Mails at a time =="+noOfmailAtATime);          
              String email= "";     
              int start = 0;
              int end  = 0;
              if(to.size()> noOfmailAtATime){
                   end = noOfmailAtATime;
              }else{
                   end = to.size();
              if(counter>=1){               
                   for(int i=0; i<counter; i++) {     
                        System.out.println("i is : "+i);
                        System.out.println("Start is "+start+" and end is "+end);
                        for(int j=start; j<end; j++ ){
                             email = email + "," +to.get(j);     
                        start = end;                    
                        email = email.substring(1);
                        emails.add(email);
                        email = "";
                        if(i< counter-1){
                             end = end + noOfmailAtATime;     
              System.out.println("End is :"+end);          
              if(end < to.size()){
                   int count = 0;
                   System.out.println("Inside if");
                   for(int i= end; i<to.size(); i++){
                        System.out.println();
                        email = email + "," +to.get(i);
                        count = i;     
                   email = email.substring(1);               
                   emails.add(email);
                   email="";
                   System.out.println("End is =="+count+" and to size is "+to.size());
        public static void main(String[] args) {
            try{
                 BlockingQueue<Runnable> queue = new ArrayBlockingQueue<Runnable>(200);
                 ThreadPoolExecutor executor = new ThreadPoolExecutor(50, 50, 1, TimeUnit.SECONDS, queue);
                    if (args.length != 1) {
                         System.err.println("Usage: java ExecutorExample address_file" );
                         System.exit(1);
                  MailerBackup mailer = new MailerBackup(args[0]);
                  MailBean bean = null ;
                  MailSender sender = null;
                 long time = -System.currentTimeMillis();
                 time += System.currentTimeMillis();              
    //Here Emails is an ArrayCollection<String>, where each String consist of
    //multiple comma seperated emails .
                 for(int i = 0; i < emails.size(); i++){
                      bean = new MailBean();
                       bean.setSubject("Mail Bean Test");
                       bean.setMessage("Hi This is a Test Message, Please Ignore this Message");
                       System.out.println(emails.get(i));
                         bean.setTo(emails.get(i));
                         executor.execute(new MailSender(bean));
                 System.out.println(time + "ms");
                  System.out.println("Finished");          
            }catch(Exception ex){
                 ex.printStackTrace();
    }For sending Mails, My MailBeans send method is :
    public Message createMessage(){
             try{              
                  Message msg = new MimeMessage(session);
                   msg.setFrom(InternetAddress.parse(FROM, false)[0]);
                   msg.setHeader("X-Mailer", "VMailer");
                   msg.setSentDate(new Date());
                   if(getTo() != null || getTo() !="")
                   msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(getTo(), false));
                   if(getCc() != null || getCc() !="")
                        msg.setRecipients(Message.RecipientType.CC,InternetAddress.parse(getCc(), false));
                   if(getBcc() != null || getBcc() !="")
                        msg.setRecipients(Message.RecipientType.BCC,InternetAddress.parse(getBcc(), false));
                   msg.setSubject(getSubject());
                   msg.setText(getMessage());
                   return msg;                        
             }catch(Exception ex){
                  ex.printStackTrace();
             return null;          
        public void sendMessage(){
             try{
                  Message msg = createMessage();
                  transport.send(msg, msg.getAllRecipients());
             }catch(Exception ex){
                  ex.printStackTrace();
        }Error is while parsing the Mails.
    java.lang.NullPointerException
            at javax.mail.internet.InternetAddress.parse(InternetAddress.java:595)
            at javax.mail.internet.InternetAddress.parse(InternetAddress.java:555)
            at MailBean.createMessage(MailBean.java:123)
            at MailBean.sendMessage(MailBean.java:138)
            at MailSender.run(MailSender.java:11)
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)DEBUG: setDebug: JavaMail version 1.4ea
    DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
    DEBUG SMTP: useEhlo true, useAuth true
    DEBUG SMTP: trying to connect to host "email.vsginc.com", port 25, isSSL false
            at java.lang.Thread.run(Unknown Source)
    java.lang.NullPointerException
            at MailBean.sendMessage(MailBean.java:139)
            at MailSender.run(MailSender.java:11)
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
            at java.lang.Thread.run(Unknown Source)
    220 email.vsginc.com Microsoft ESMTP MAIL Service, Version: 6.0.3790.1830 ready at  Fri, 7 Sep 2007 09:19:00 -0400
    DEBUG SMTP: connected to host "email.vsginc.com", port: 25

    So what's in FROM?

  • Problem in parsing no-ascii body text message?

    I have a text/plain mime message(Composed in the outlook express) that contains a long one-line japanese string as follow:
    ���b�Z�[�W���O�v���b�g�t�H�[�����������r�W�l�X�V�X�e�������������������B�C���^�[�l�b�g���������\�����������������A���@�\�����b�Z�[�W���O�\�����[�V���������p���������B���������������A���q�T�[�r�X�������x�������A�r�W�l�X�v���Z�X�����������A�@�������������M�����������������R�X�g�����������������������B�������A�I�����C���u���[�J�[���g�b�v������������2���A���E�I���N���W�b�g�����������s�J�[�h���s������������3���A���������i�����X����5�����A�����r�W�l�X�N���e�B�J�������b�Z�[�W�C���t���X�g���N�`���[������Tumbleweed���\�����[�V�������g�p�����������B���������}�[�P�b�g�������������������������H���q���M��
    If I add one more japanese char to the begining of the string and parse the mail with JavaMail, It will becomes
    �����b�Z�[�W���O�v���b�g�t�H�[�����������r�W�l�X�V�X�e�������������������B�C���^�[�l�b�g���������\�����������������A���@�\�����b�Z�[�W���O�\�����[�V���������p���������B���������������A���q�T�[�r�X�������x�������A�r�W�l�X�v���Z�X�����������A�@�������������M�����������������R�X�g�����������������������B�������A�I�����C���u���[�J�[���g�b�v������������2���A���E�I���N���W�b�g�����������s�J�[�h���s������������3���A���������i�����X����5�����A�����r�W�l�X�N���e�B�J�������b�Z�[�W�C���t���X�g���N�`���[������Tumbleweed���\�����[�V�������g�p�����������B���������}�[�P�b�g�������������������������H���q���M???????
    Here is the message header info:
    Content-Type: text/plain; charset=iso-2022-jp
    Content-Transfer-Encoding: quoted-printable
    Does this mean that that there is a bug in the JavaMail in handling no-ascii chars?
    After I make the following call:
    setContent(this.getContent(), this.getContentType());
    The change becomes permanent and recipient will see the '????' at the end of the message.
    I can provide mime format of the message if necessary.
    Any one see this before?
    Any help is appreciated!

    KennethKwan,
    Thanks for you reply. I tried you code and it does not work. All I got is
    "$B%a%C%;!<%8%s%0%W%i%C%H%U%)!<%`$r4{B8$N%S%8%M%9%7%9%F%`$HE}9g$7$F$$$^$9!#%$%s%?!<%M%C%H@\B3$,2DG=$J$"$i$f$k>l=j$G!"9b5!G=$N%a%C%;!<%8%s%0%=%j%e!<%7%g%s$rMxMQ$G$-$^$9!#$3$l$i$N4k6H$O!"8\5R%5!<%S%9$dK~B-EY$r9b$a!"%S%8%M%9%W%m%;%9$r4JN,2=$7!"5!L)>pJs$rAw<u?.$9$k$?$a$K$+$+$k%3%9%H$H;~4V$r:o8:$7$F$$$^$9!#Nc$($P!"%*%s%i%$%s%V%m!<%+!<$N%H%C%W4k6H$N$&$A$N(B2$B<R!"@$3&E*$J%/%l%8%C%H$"$k$$$ON99T%+!<%IH/9T2q<R$N$&$A$N(B3$B<R!"$*$h$S@h?J9q$NM9@/6I(B5$B$D$,!"8=:_%S%8%M%9%/%j%F%#%+%k$J%a%C%;!<%8%$%s%U%i%9%H%i%/%A%c!<$H$7$F(BTumbleweed$B$N%=%j%e!<%7%g%s$r;HMQ$7$F$$$^$9!#$"$J$?$N%^!<%1%C%H$O$I$l$[$I$N6%AhN($G$9$+!)8\5R$N?.Mj(B"
    instead of the japanese string I posted.
    All I did was
    String text = (String)mimeMessage.getContent();
    It works ok for most of japanese strings except for the one I mention above which is a single long line of japanese string.

  • Mail attachment and conversion agent

    Hey guys,
    Is there a way to parse e-mail attachments usign a converion agent module
    added to the e-mail sender adapter in "one step" ?
    e.g. not doing mail->file and then file(CM module)->XI.
    Regards,
    Nimrod.G

    Hi nirmod,
    Refer these links
    The specified item was not found. - sending mail attachments
    The specified item was not found.
    and also check this article
    http://help.sap.com/saphelp_nw04/helpdata/en/43/4c38c4cf105f85e10000000a1553f6/frameset.htm
    Regards,
    Suryanarayana

  • Export a mail as PST file using EWS API

    Hi,
    I need to export the Exchange mails to PST file without installing the outlook. To acheive this i am choosing the EWS API. but i dont know how to do that. So, now i have a two questions, the first one, is it possible to create the pst file using EWS API?.
    If yes, how to create a pst file using EWS, if any one posted the sample code here, it is very helpful for me.
    Thanks,
    RamMohan

    EWS is not going to help you do what your trying to do, EWS is an Exchange API so you need to have an Exchange 2007 server or greater with the MailStore mounted to even use it to access the Mailbox . EWS also doesn't support exporting email to a PST because
    the PST file is an Office file format so in the case where you do manage to mount the database on Exchange then use Adam's suggestion or just connect via Outlook and export the Mailbox.
    >> I am parsing the mails from the exchange EDB files
     With what ? reading the contents of an EDB file directly is not supported although there are a few third party apps that can do it and if your using one of those apps then all of them I've seen support the export to PST (unless your using a Trial licence). 
    The correct method of recovering data from an EDB file would be to use a Recovery Database
    https://technet.microsoft.com/en-us/library/dd876954(v=exchg.150).aspx even if you don't have access to the environment you should be able to setup a temp environment using Virtual machines and recover it that way.
    Cheers
    Glen

  • UTL_SMTP mail with attachment( Problem in adding multiple recipient)

    Hi All,
    I am using the below code for sending the attachment.
    When i try to add the mail group name in my recipient details i am getting the following error
    ORA-29279: SMTP permanent error: 501 Syntax error, parameters in command "RCPT TO:Application Support - IT" unrecognized or missingHow to add the group in the recipient or cc ????
    My mail code is:
    create or replace PROCEDURE "SSSL_SEND_MAIL" ( p_sender varchar2,
          p_recipient varchar2,
          p_cc varchar2,
          p_subject varchar2,
          p_filename varchar2,
          text varchar2) is 
        /*LOB operation related varriables */
       v_src_loc  BFILE;
       l_buffer   RAW(54);
       l_amount   BINARY_INTEGER := 54;
       l_pos      INTEGER := 1;
       l_blob     BLOB := EMPTY_BLOB;
       l_blob_len INTEGER;
       v_amount   INTEGER;
        /*UTL_SMTP related varriavles. */
        v_connection_handle  UTL_SMTP.CONNECTION;
        v_from_email_address VARCHAR2(200);
        v_to_email_address   VARCHAR2(200) ;
        v_cc                 VARCHAR2(200);
        v_smtp_host          VARCHAR2(10) ;
        v_subject            VARCHAR2(500) ;
        l_message            VARCHAR2(3000);
        l_filename           VARCHAR2(4000);
        /* This send_header procedure is written in the documentation */
        PROCEDURE send_header(pi_name IN VARCHAR2, pi_header IN VARCHAR2) AS
        BEGIN
        --dbms_output.put_line('entering into procedure');
        --dbms_output.put_line(pi_name || ': ' || pi_header);
          UTL_SMTP.WRITE_DATA(v_connection_handle,
                              pi_name || ': ' || pi_header || UTL_TCP.CRLF);
        END;
      BEGIN
       v_src_loc             := BFILENAME('BROKERREPORTS',p_filename);
       v_from_email_address  := p_sender;
       v_to_email_address    := p_recipient;
       v_cc                  := p_cc;
       v_smtp_host           := 'xxxxxx'; --My mail server, replace it with yours.
       v_subject             := p_subject;
       l_message      := 'tets';
        /*Preparing the LOB from file for attachment. */
        DBMS_LOB.OPEN(v_src_loc, DBMS_LOB.LOB_READONLY); --Read the file
        DBMS_LOB.CREATETEMPORARY(l_blob, TRUE); --Create temporary LOB to store the file.
        v_amount := DBMS_LOB.GETLENGTH(v_src_loc); --Amount to store.
        DBMS_LOB.LOADFROMFILE(l_blob, v_src_loc, v_amount); -- Loading from file into temporary LOB
        l_blob_len := DBMS_LOB.getlength(l_blob);
        l_filename:=p_filename;
        IF l_blob_len > 7000000 THEN
        BEGIN
        SSSL_FILE_ZIP.COMPRESSFILE(
        P_IN_FILE => '/mfundb/prdapex/BROKER-REPORTS/'||p_filename,
        P_OUT_FILE => '/mfundb/prdapex/BROKER-REPORTS/'||REPLACE(UPPER(p_filename),'XLS','ZIP')
      l_filename:=NULL;
      l_filename:= REPLACE(UPPER(p_filename),'XLS','ZIP');
      v_src_loc := BFILENAME('BROKERREPORTS',l_filename);
      DBMS_LOB.OPEN(v_src_loc, DBMS_LOB.LOB_READONLY); --Read the file
      DBMS_LOB.CREATETEMPORARY(l_blob, TRUE); --Create temporary LOB to store the file.
      v_amount := DBMS_LOB.GETLENGTH(v_src_loc); --Amount to store.
      DBMS_LOB.LOADFROMFILE(l_blob, v_src_loc, v_amount); -- Loading from file into temporary LOB
      l_blob_len := DBMS_LOB.getlength(l_blob);
    EXCEPTION WHEN OTHERS THEN
    sssl_internal_error_track(sqlcode,sqlerrm,'SSSL_FILE_ZIP',l_filename||'-'||p_recipient);
    END;
    END IF;
    /*UTL_SMTP related coding. */
        v_connection_handle := UTL_SMTP.OPEN_CONNECTION(host => v_smtp_host);
        UTL_SMTP.HELO(v_connection_handle, v_smtp_host);
        UTL_SMTP.MAIL(v_connection_handle, v_from_email_address);
        UTL_SMTP.RCPT(v_connection_handle, v_to_email_address);
        UTL_SMTP.RCPT(v_connection_handle, v_cc);
        UTL_SMTP.OPEN_DATA(v_connection_handle);
        send_header('From', v_from_email_address);-- || '<'||'>');
        send_header('TO', v_to_email_address);--|| '<'||'>');
        send_header('CC', v_cc );   
        send_header('Subject', v_subject);
        --MIME header.
       UTL_SMTP.WRITE_DATA(v_connection_handle,
                          'MIME-Version: 1.0' || UTL_TCP.CRLF);
       UTL_SMTP.WRITE_DATA(v_connection_handle,
                            'Content-Type: multipart/mixed; ' || UTL_TCP.CRLF);
        UTL_SMTP.WRITE_DATA(v_connection_handle,
                            ' boundary= "' || 'SAUBHIK.SECBOUND' || '"' ||
                            UTL_TCP.CRLF);
       UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
        -- Mail Body
        UTL_SMTP.WRITE_DATA(v_connection_handle,
                            '--' || 'SAUBHIK.SECBOUND' || UTL_TCP.CRLF);
        UTL_SMTP.WRITE_DATA(v_connection_handle,
                            'Content-Type: text/plain;' || UTL_TCP.CRLF);
        UTL_SMTP.WRITE_DATA(v_connection_handle,
                            ' charset=US-ASCII' || UTL_TCP.CRLF);
        UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
        UTL_SMTP.WRITE_DATA(v_connection_handle, l_message || UTL_TCP.CRLF);
        UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
        -- Mail Attachment
        UTL_SMTP.WRITE_DATA(v_connection_handle,
                            '--' || 'SAUBHIK.SECBOUND' || UTL_TCP.CRLF);
        UTL_SMTP.WRITE_DATA(v_connection_handle,
                           'Content-Type: application/octet-stream' ||
                            UTL_TCP.CRLF);
        UTL_SMTP.WRITE_DATA(v_connection_handle,
                            'Content-Disposition: attachment; ' || UTL_TCP.CRLF);
        UTL_SMTP.WRITE_DATA(v_connection_handle,
                            ' filename="' || l_filename || '"' || --My filename
                            UTL_TCP.CRLF);
        UTL_SMTP.WRITE_DATA(v_connection_handle,
                            'Content-Transfer-Encoding: base64' || UTL_TCP.CRLF);
        UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
      /* Writing the BLOL in chunks */
        WHILE l_pos < l_blob_len LOOP
          DBMS_LOB.READ(l_blob, l_amount, l_pos, l_buffer);
          UTL_SMTP.write_raw_data(v_connection_handle,
                                  UTL_ENCODE.BASE64_ENCODE(l_buffer));
          UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
          l_buffer := NULL;
          l_pos    := l_pos + l_amount;
        END LOOP;
        UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
        -- Close Email
        UTL_SMTP.WRITE_DATA(v_connection_handle,
                            '--' || 'SAUBHIK.SECBOUND' || '--' || UTL_TCP.CRLF);
        UTL_SMTP.WRITE_DATA(v_connection_handle,
                            UTL_TCP.CRLF || '.' || UTL_TCP.CRLF);
        UTL_SMTP.CLOSE_DATA(v_connection_handle);
        UTL_SMTP.QUIT(v_connection_handle);
        DBMS_LOB.FREETEMPORARY(l_blob);
        DBMS_LOB.FILECLOSE(v_src_loc);
      EXCEPTION
        WHEN OTHERS THEN
          UTL_SMTP.QUIT(v_connection_handle);
          DBMS_LOB.FREETEMPORARY(l_blob);
          DBMS_LOB.FILECLOSE(V_SRC_LOC);
         sssl_internal_error_track(sqlcode,sqlerrm,'SSSL_SEND_MAIL',l_filename||'-'||p_recipient);
      END;Kindly help me out to add the group or one or more mail id's
    Thanks in Advance
    Cheers,
    Shan.

    As, I said earlier (in some of your posts), you have to add UTL_RCPT for each recepient. For example, if you have CC list into some variable p_cc as comma separated list, then you can do something like this:
    ll_cc := '[email protected],[email protected],[email protected]';
       loop
           exit when l_to is null;
           n := instr( l_cc, ',' );
           IF n =0 THEN exit; end if;
           l_tmp := substr( l_cc, 1, n-1 );
           l_cc := substr( l_cc, n+1 );
           utl_smtp.rcpt( l_tmp );
       end loop;PS.: Not tested.
    Read this excellent explanation from Billy Verreynne
    To expand on what was said - the SMTP server does not parse the mail data you give it. It does not look at that to see the recipients, CC and BC list. The mail data is just that - raw data. This is the payload that the SMTP server will deliver.Where will it deliver it to? That you need to explicitly tell it via the RCPT TO SMTP command. So you need to build a complete list of names that includes all recipients, including CC and BC.
    And then use this list of names to instruct the SMTP SERVER, via the RCPT TO command, who must receive the message payload.>
    Re: Problem in sending email from oracle

  • Spam / Virus / Mail Reporting Tools

    Does anyone have an recommendations on how i find the stats for what the Leopard mail server is upto? Just daily reports on the volumes of mails / spams / virus scans would be great.
    Thanks.
    N.

    I second pterobyte's suggestion of mailgraph. It took me about 5 minutes; about as painful as a bandaid. And the resulting database can be parsed and mailed a million was with rrdtool. A big benefit that may make it worth it to you is that it handles the time data; any other script you put together will have to keep track of what it has and hasn't seen, etc. where with mailgraph and rrdtool you can whip up a command line that summarizes running-average data and mails it to you (optionally with attached images).
    That said, if you really want something else, I imagine they exist. I have run several other mail log analyzers (that's a good search term) that work passably well. None were as nice as mailrrd, though.

  • Difficulty sending mail to secure SMTP, SMTPAddressFailedException: 554

    I keep getting the following exception in my application:
    class com.sun.mail.smtp.SMTPAddressFailedException: 554 <[email protected]>: Recipient address rejected: Relay access denied
    My code is as follows:
    public class SMTPSender {
         private Session session;
         public SMTPSender() {
              Properties props = new Properties();
              props.setProperty("mail.smtp.host", AutomailingUtility.HOST);
              props.put("mail.smtps.auth", AutomailingUtility.AUTH);
              props.put("mail.smtp.port", "465");
              props.put("mail.smtp.socketFactory.port", "465");
              props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
              props.put("mail.smtp.socketFactory.fallback", "false");
              Authenticator auth = new MyAuthenticator(AutomailingUtility.USERNAME, AutomailingUtility.PASSWORD);
              session = Session.getInstance(props, auth);
         public void sendMessage(String toUser, String message, String subject) {
              try {
                   Message msg = new MimeMessage(session);
                   msg.setSubject(subject);
                   msg.setSentDate(new Date());
                   InternetAddress ia = new InternetAddress(AutomailingUtility.FROM_ADDRESS);
                   msg.setFrom(ia);
                   msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(toUser + "@mail.gatech.edu"));
                   msg.setText(message);
                   Transport.send(msg);
              } catch (AddressException e) {
                   e.printStackTrace();
              } catch (MessagingException e) {
                   e.printStackTrace();
    }All the Automailing constants are strings.
    I'd appreciate the help

    The code? For regular SMTP with authentication I believe you needprops.put("mail.smtp.auth", "true");whereas you set up the mail.smtps.auth property instead. However I don't have any experience with secure SMTP, so I don't know what's right in that case. Are those other applications you mention using secure SMTP or just regular SMTP?

  • SAP to OUTLOOK MAIL - GATEWAY Problems...

    Hi Gurus;
    I want to send email , sap to outlook. We use sap on the windows os. I created RFC with SM59 and created SAPConnect note with SCOT.
    But I dont know create gateway process. Please help me.
    My ref. shortcut : /people/thomas.jung3/blog/2004/09/07/sending-e-mail-from-abap--version-46d-and-lower--api-interface
    Thanks for everything.
    Best regards.

    Hi Melih,
    The problem here is that you are trying to use the internet mail gateway and Sendmail to relay mails on a Windows OS (usually to Exchange).
    The main problem is that Sendmail is not a native Windows program. So the Blog that you were following was not correct for Windows OS.
    Sendmail is a native Unix program and as such is called with switches. The IMG was designed to communicate with Sendmail with the follow command to correctly parse the mail (sendmail -i -f<SENDER_ADDRESS>) to Sendmail.
    So you have to follow the blog below and use another command line mailer to correctly communicate with Exchange or any other SMTP mail server.
    Please refer to the following blog to enable emails to be sent from SAP connect:-
    [Email from SAP - 4.6* using MS Exchange|http://it.toolbox.com/wiki/index.php/Email_from_SAP_-_4.6C_using_MS_Exchange_2003]
    And your problem will be resolved

  • Receiving Mail Only from Addresses I Specify

    Is there any simple way to set up Mail to send all messages to the junk folder except ones from particular addresses I put on a list to let through?
    Sorry if this has been answered, but I couldn't find it by searching…
    Thanks.

    Wouldn't Mail > Preferences > Rules > Add Rule > and then select the following pulldowns: if any of the following are conditions met: Sender not in my address book then move message to mailbox junk, do what you want? Or as an additional second condition, use previous recipients?
    If you are going to maintain a stand-alone list, you will probably have to do something like: if Account {acc'tName} then Run Applescript {file/path/to/Applescript}, then move message to mailbox junk where the Applescript parses the mail message's From line and compares it against the stand-alone list.
    (if this solves your problem, or is actually helpful towards arriving at a solution to your problem, please consider marking this reply as "helpful" or "solved" in order to award points. This would be in addition to (if applicable) marking this question as "answered")

  • How to find from/for whom the mail has been bounced.

    Hi,
    I got a bounced email. I have to find which mail has bounced. For example lets take I have sent a mail to [email protected] and the mail is bounced. Now I have to read my message using Javamail API and have to find mail for which intended user is failed. Hope I am clear on my question.
    One thing I found is failed recepient address will be in the bounced mail's body but to get it I need to parse the mail (some server doesn't even put it in the body). Is there any other way? (like including it in the header or somewhere)
    Thanks,
    Harish

    Did you find the JavaMail FAQ? There's an entry in the FAQ that addresses
    this question explicitly.

  • MutliPart Message Parsing

    hi,
    Could somebody tell me how a multipart/related message could be parsed for the various parts?
    A sample message stream is as shown below
    POST http://www.somewhere.com/some.cgi
    HTTP/1.0
    Content-Type: multipart/related
    Content-Length:1032
    MIME-Version: 1.0
    Content-Type: multipart/related;boundary=--7d021a37605f0
    ----7d021a37605f0
    Content-Type: text/xml;charset="UTF-8"
    Content-Id: APP
    <?xml version="1.0" encoding="UTF-8"?>
    <Root>
         <a>notempty</a>
    </Root>
    ----7d021a37605f0
    Content-Disposition: form-data;name="textFileAttached"; filename="theTextFile"
    Content-Type: text/plain
    This is a test
    for the post data.
    ----7d021a37605f0--

    Well this is nearly same as parsing out attatchmets. The difference is once you have parsed the mail and created the files referred to , by the content-id field you must change the 'src' tag of the html to point to the file you have created.
    cheers
    Projyal

  • Missing start boundary exception, caused by an empty Part, how to handle?

    Hello,
    i wrote an application that automatically handles mails from laboratories. The only essential part of the mail is the attachment, where chemical analyses are submitted (from permitted addresses, recognized by whitelist and fileheader of the attachment). Other ways to submit data weren't allowed.
    Currently a mail was received that can't be parsed. It's from a laboratory, that
    use its provider's (a german internet suplier named Arcor) webmail, a browser-based mailing portal. It always worked fine, because they wrote some greetings. But this time they sent a blank message. The result is following structure of the mail:
    MIME-Version: 1.0
    Content-Type: multipart/mixed;
    boundary="----=_Part_50112_10709369.1203586767396"
    //Some X-Flags
    ------=_Part_50112_10709369.1203586767396
    Content-Type: multipart/alternative;
         boundary="*----=_Part_50111_24141780.1203586767396*"
    ------=_Part_50111_24141780.1203586767396--
    ------=_Part_50112_10709369.1203586767396
    Content-Type: application/octet-stream
    Content-Transfer-Encoding: base64
    Content-Disposition: attachment; filename=somefile.bin
    ABCDEF.... //Some binary data
    ------=_Part_50112_10709369.1203586767396--
    It seems the webmailer creates an empty mailpart and only writes the end boundary (Line: ------=_Part_50111_24141780.1203586767396--).
    I know, the start boundary is really missing.
    I checked it out by getting a mailaccount from Arcor, and it always creates this structure when sending a message without a text. By the way, the Message-ID (header) generated from Arcor's server seems to be from javamail. (.....1234.567890.....JavaMail.ngmail@....).
    I don't know how many mailclients create "empty" parts, but impossible is nothing (e.g. other or future webmailer services).
    But how to handle?
    The error occures when calling MimeMultipart.getCount(), which causes to parse the mail if not parsed. All actions, which cause the mail to be parsed, will end in this exception (for this mail).
    I looked at the javamail source and found out, that the line of the empty part is not recognized as a boundary, because of its ending delimiters:
    if (line.equals(boundary))
    break;
    So the boundary is added to the preamble. It goes on with reading lines from the stream, until line == null.
    if (line == null)
    throw new MessagingException("Missing start boundary");
    Because there is no test, if the line matches the end boundary, it's not recognized. Wouldn't it be better in this case, to add an empty bodypart and set a variable to false (e.g. complete) instead of throwing an exception? Because MimeMultipart.parse() is called by other methods, like getCount, getBodyPart and writeTo, I can't nearly do anything automatically with the mail. How should i walk through the bodyparts and fetch the parts I'm interested in?
    Subclassing seems to be difficult to me:
    Object content = message.getContent();
    //javax.mail.Message, won't return a subclassed multipart
    if (content instanceof Multipart) {
    //recursive method!
    handleMultipart((Multipart) content); //collecting parts from multipart
    Of course, I could ask the laboratory: "please send me a greeting!" ;-)
    Greetings,
    cliff

    Interesting.
    Yes, it's probably a bug that JavaMail allows you to
    create a multipart with no body parts, since the
    MIME specification doesn't allow that. Still, the
    webmail application should be fixed so that it doesn't
    try to do that, at least including an empty plain text
    body part.
    Please contact the webmail provider and tell them of
    this bug in their application.
    I'll also look into making JavaMail cope with these
    broken messages more gracefully. Contact me
    at [email protected] and I'll let you know when
    I have a version ready to test.

Maybe you are looking for

  • How to generate data in BPS via function, not having any reference data?

    <b>Hi everybody, My approach was to use FM 'API_SEMBPS_SETDATA' but the modified values neighter appear in the layout nor were saved to the infocube after launching 'API_SEMBPS_POST'.</b> <a href="http://help.sap.com/saphelp_nw04/helpdata/en/2e/260a8

  • Adding a 3D sphere onto a 3D cube

    Hi, currently i have created a 3D cube and was thinking to create a 3D sphere so that the sphere can stay onto the cube. And so when the cube is being rotated, the sphere that is on the cube will move according too. Can any1 show me the code to creat

  • Nilvaiu.dll functions

    HI. I am trying to get the list functions of nivaiu.dll library. Does anyone know the the nivaiu.dll programming manual or related information.  Thanks Gary

  • Can't use java on any programs

    so im trying to use a program that needs java, and it does start but you can't do anything or shuts down the mac hangs and it stops responding. aagggghhh

  • Delivery address in PO with more than one address for storage location

    Hi All,          Can you please let me know how the storage location addresss gets picked up in a PO where the storage location has more than more address defined in customizing. How can we control the address in the PO ? Regards, Ashwin