net.mail problems


    Mar 05 2008 | 11:31 pm
    i use max for aprox 10 years, but i have no knowledge of java, and i need some help here.
    trying to load net.mail help files, i get the following errors:
    • error: java.lang.NoClassDefFoundError: javax/mail/MessagingException • error: (mxj) unable to alloc instance of net.mail.send • error: java.lang.NoClassDefFoundError: javax/mail/MessagingException • error: (mxj) unable to alloc instance of net.mail.recv
    i found some info in java tutorials (tutorial 9)- it seemed i miss some libraries. i managed to install java.mail - i simply copied mail.jar to java/lib directory. i'm lost when it comes to "JavaBeans Activation Framework". I have no idea what to download and how to install......
    with only mail.jar installed, net.mail.recv initiates fine, but still fails to check mail. i get the following errors:
    javax.mail.MessagingException: Connect failed; nested exception is: java.net.ConnectException: Operation timed out at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:161) at javax.mail.Service.connect(Service.java:288) at javax.mail.Service.connect(Service.java:169) at net.mail.recv.saveMessage(recv.java:43) Caused by: java.net.ConnectException: Operation timed out at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:430) at java.net.Socket.connect(Socket.java:520) at java.net.Socket.connect(Socket.java:470) at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233) at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189) at com.sun.mail.pop3.Protocol.(Protocol.java:94) at com.sun.mail.pop3.POP3Store.getPort(POP3Store.java:214) at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:157) ... 3 more exceptions: javax.mail.MessagingException: Connect failed; nested exception is: java.net.ConnectException: Operation timed out

    • Mar 05 2008 | 11:48 pm
      On 5 Mar 2008, at 23:31, ivan marusic wrote:
      > javax.mail.MessagingException: Connect failed; > nested exception is: > java.net.ConnectException: Operation timed out > at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:161)
      That pretty much tells you what you need to know: you're trying to do POP3 mail and the connection to the server is timing out.
      Error messages can be useful: sometimes a cigar is just a cigar.
      nick rothwell -- composition, systems, performance -- http:// www.cassiel.com
    • Mar 06 2008 | 12:03 am
      thank you for your prompt reply :)
      i'm still confused about missing javabean activation.jar file???
      i'm quite sure it is not installed on my machine.
      have no idea what package to download and where from??
    • Mar 06 2008 | 12:59 am
      i'm probably just tired, or it is a really bad day. it took me 2 hours to find Javabeans activation framework download at Sun.com.
      I found it. it works.
      Only, help file doesn't want to check gmail account with the same error that i allready posted.
      Any hints?? Or experiences with other free mail services?
    • Mar 06 2008 | 10:02 am
      whats the default timeout?
      maybe try increasing it.
      if its still not getting anywhere i would try to manually telnet to the POP3 server and see if it responds, then if that appears to work but the java code doesnt then use a network monitor to see whats happening on the wire, e.g. wireshark :
      Are you trying the code from within max or from your development setup?
    • Mar 06 2008 | 10:45 am
      hmmmmm.
      as i said, i'm a complete novice when it comes to java.
      i managed to check mail on small local server, but couldn't do it on gmail.
      i checked it on max. i have no idea where to change timeout settings. i checked net.mail.recv code, but don't remember seeing anything that looked like timeout value.
      thanx for your help
    • Mar 06 2008 | 11:21 am
      right, i think the problem is that pop3 access to google mail requires SSL, if you look here for details :
      this page is a bit easier to read :
      I havent used the max net.mail classes so I dont know how much it exposes of the underlying mail library, but hopefully you can set the right configuration.
    • Mar 25 2008 | 7:16 am
      Hello, A while ago I created a mxj program to email mp3s of performances as attachments to gmails. I've attached everything. Let me know if you have suggestions or comments. Myer
      note - you need to 1.) start pop3 support in your gmail account settings 2.) get activation.jar and mail.jar, and put them in your mxj classpath, and edit the config file so it loads the jars to get this to work ************************************ ********BPATCHER IMPLEMENTATION***** ************************************
      *********************************** *********MXJGmail.java************* ***********************************
      import com.cycling74.max.*; import java.util.Properties; import javax.mail.*; import javax.mail.internet.*; import javax.activation.*;
      public class MXJGmail extends MaxObject {
      private static final String SMTP_HOST_NAME = "smtp.gmail.com"; private static final int SMTP_HOST_PORT = 465; private static final int NORMAL_OUTLET = 0; private static final int EXCEPTION_OUTLET = 1;
      private String username = null; private String password = null; private String to = null; private String cc = null; private String bcc = null; private String from = "nobody"; private String subject = null; private String text = null; private String fileName = null; private String contentType = "text/html";
      public MXJGmail( Atom args[] ) { declareIO( 1,2 ); declareAttribute("username"); declareAttribute("password"); declareAttribute("to"); declareAttribute("cc"); declareAttribute("bcc"); declareAttribute("subject"); declareAttribute("text"); declareAttribute("fileName");
      from = username + "@gmail.com"; }
      public void bang () { deliver(); }
      public void clear( String message, Atom args[] ) { username = password = to = cc = bcc = subject = text = fileName = null; from = "nobody"; }
      public void deliver() {
      //Get System Properties object Properties props = System.getProperties();
      // Define properties // it MUST be smtpS for gmail props.put( "mail.transport.protocol", "smtps" ); props.put( "mail.smtps.host", SMTP_HOST_NAME ); props.put( "mail.smtps.auth", "true" );
      // tells the system NOT to wait for verification // of sent status from gmail props.put( "mail.smtps.quitwait", "false" );
      try {
      // Get a mail Session object // Pass SMTP properties to private constructor of new // Session object Session session = Session.getDefaultInstance( props );
      // deal with transport directly because of tls and ssl // which are required for gmail Transport transport = session.getTransport();
      // Create a new Message object MimeMessage message = new MimeMessage( session );
      //Pass the Mail Session as an argument and construct //a MimeMessage with the Session // Populate Message object if ( from != "nobody" ) { message.setFrom( new InternetAddress( from ) ); } else { message.setFrom(); } if ( to != null ) { message.addRecipients( Message.RecipientType.TO, InternetAddress.parse( to ) ); } if ( cc != null ) { message.addRecipients( Message.RecipientType.CC, InternetAddress.parse( cc ) ); } if ( bcc != null ) { message.addRecipients( Message.RecipientType.BCC, InternetAddress.parse( bcc )); } if ( subject != null ) { message.setSubject( subject ); }
      //Create message body part BodyPart messageBodyPart = new MimeBodyPart();
      //Specify that we want a Part interface for a new //MIME object; construct object and assign it to //messageBodyPart if ( text != null ) { messageBodyPart.setText( text ); }
      if ( fileName != null ) {
      //create a Multipart object to hold the BodyPart Multipart multipart = new MimeMultipart(); multipart.addBodyPart( messageBodyPart );
      //pass the textset BodyPart as an argument to the //addBodyPart method of the multipart object //Create the attachment body part messageBodyPart = new MimeBodyPart(); DataSource source = new FileDataSource( fileName );
      //make a capsule for the file that //was referenced in the arguments messageBodyPart.setDataHandler( new DataHandler(source) );
      //pass DataSource to DataHandler so it can be //interpreted by messageBodyPart messageBodyPart.setFileName( fileName );
      //create an official name for the file name //referenced in the arguments - so that the //MIME reader on the other end knows //what to call it multipart.addBodyPart( messageBodyPart );
      //pass the BodyPart to the addBodyPart() method of the //Multipart object so it can be added; //insert the multipart into the message message.setContent( multipart );
      }
      //send the message with mail transport object transport.connect( SMTP_HOST_NAME, SMTP_HOST_PORT, username, password ); transport.sendMessage( message, message.getRecipients( Message.RecipientType.TO ) ); transport.close();
      outlet(NORMAL_OUTLET, "sent");
      } catch ( AddressException ae ) { showException( null, ae ); outlet( EXCEPTION_OUTLET, "AddressException" ); } catch ( MessagingException me ) { showException( null, me ); outlet( EXCEPTION_OUTLET, "MessagingException" ); } } }
    • Mar 27 2008 | 8:03 am
      thanks a lot!
      i'll check it out today.
      klif
    • Aug 07 2008 | 5:02 pm
      Works great! Thanks for the solution! But how to be, if I don't want to attach anything - just message don't send! It's possible by MXJGmail ?
    • Aug 07 2008 | 5:18 pm
      Works great! Thanks for the sharing ! And one question - how to send message without any attached file? Thanks for your time!
    • Oct 28 2009 | 10:14 am
      It works great!
      But I have the same suggestion as 'outoff', could you also make it possible to send a mail without an attachment? And is there anyway to not have the filename of the attachment changed? (If I send a file '/Desktop/Test.txt' it becomes 'DesktopTest.txt'
      I wonder how you solved this 'STARTTLS command' error:
      com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first. 23sm2472694eya.28 at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1668) at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1207) at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:735) at javax.mail.Transport.send0(Transport.java:191) at javax.mail.Transport.send(Transport.java:120) at net.mail.send.deliver(send.java:71) exception: MessagingException
      Would it be a lot of work to also make gmail work with 'mxj net.mail.recv'?
      Kind regards, Bas
    • Oct 22 2011 | 10:53 pm
      Hello, I was really happy to find this solution out here in the forum. What was posted here is exactly what I need to do: use gmail to send an attachment from max.
      Although the maxpatch seems to make sens, I am unsure as to what I am suppose to do with the Java code provided. The first thing I did was to create a .java file with it (using Smultron). Then, I tried compiling it in the Terminal (I am on a MAC running 10.7.2), but it doesn't work.
      So I downloaded Eclipse and created a class from the .java file. When I tried the patch again, the max window said: "(mxj) Class MXJGmail is not a subclass of com/cycling74/max/MaxObject"...
      That's where I am right now. I read the tutorials for the MXJ object and I think I have pretty good idea of how it works and how it should work. Unfortunately, I am far from being a Java master.
      Any help to make this work would be greatly appreciated! Thanks
    • Nov 17 2012 | 6:37 pm
      Could not load class"MXJGmail" is the message I am getting. I have the activation and mail jars in place and the mxj net.mail.send looks valid. Any suggestions?
    • Jan 05 2013 | 4:18 pm
      I tried the patch and mxj file from Myer Nore but without success. I got the same error message as Lazer luke: Could not load class"MXJGmail"
      I don't have the MXJGmail.class file. Does someone have this file? Or know what i am missing?
      My java knowledge is very poor..
      Thanks,..
    • Jan 05 2013 | 7:51 pm
      finally i created the class file and the mxj loaded successfully, thanks to the good description of Adam Murray http://compusition.com/web/articles/maxmsp-eclipse
    • Feb 28 2013 | 9:30 am
      Does somebody know how to to change to "from" field? Now if a mail is send the sender is called name@gmail.com. It would be nice if you can change this to "Name Surname". I tried to change several things in script but without any luck.. is it even possible?
      in the first instance, it does not have to be variable. This would be nice but not necessary.
      The script is from Myer Nore, see 9 posts above this one.
      I don't think it is very difficult but my java knowledge is unfortunately too bad... I tried to change the "nobody" field in the different lines, most of the time when i compiled the script i didn't get any errors but it didn't changed the from field.
      Many thanks in advance!
    • Nov 18 2013 | 1:39 am
      Hi Guys I having problems to send an email from max, i want to send images to an email,
      this is the message I am getting to,.. Could not load class”MXJGmail” .
      I have the activation and mail jars in place and the mxj net.mail.send looks valid. Any suggestions? does http://compusition.com/web/articles/maxmsp-eclipse really works??
      something easier to export an aplication ?
    • Nov 18 2013 | 12:33 pm
      did you add the java folder into the max.java.config.txt file?
    • Nov 06 2016 | 8:49 pm
      AWESOME!!! Works first time (max 7.3.1 on osx 10.9.5)
      Many many thanks for this :)