javax mail smtp + proxy auth problem

Discussion in 'Java' started by kiel44, Jul 19, 2006.

  1. kiel44

    kiel44 Guest

    Hi



    I have a little problem but big for me L



    I use javax.mail for sending and receiving email in my client application



    I used props.put("mail.smtp.auth", "true") and everything works fine.

    But I have problem because I have to use smtp authorization and proxy
    authorization.

    User have to put proxy login and password, and only then he will have rights
    to connect to internet.



    How to do this?



    My working code without proxy auth looks like that:





    -----------------------------------------------------------

    public void postMail() throws MessagingException

    {

    try {

    boolean debug = true;

    Properties props = new Properties();

    props.put("mail.smtp.host", this.SMTP_HOST_NAME);

    props.put("mail.smtp.auth", "true");

    props.setProperty("mail.transport.protocol", "smtp");

    System.setProperty("mail.mime.charset", "iso-8859-2");



    Authenticator auth = new SMTPAuthenticator();

    Session session = Session.getDefaultInstance(props, auth);



    session.setDebug(debug);

    Message msg = new MimeMessage(session);



    InternetAddress addressFrom = new InternetAddress(this.emailFromAddress);

    msg.setFrom(addressFrom);



    InternetAddress[] addressTo = new
    InternetAddress[this.emailList.length];

    for (int i = 0; i < this.emailList.length; i++)

    {

    addressTo = new InternetAddress(this.emailList);

    }

    msg.setRecipients(Message.RecipientType.TO, addressTo);



    BodyPart messageBodyPart = new MimeBodyPart();

    messageBodyPart.setText(this.emailMsgTxt);

    Multipart multipart = new MimeMultipart();

    multipart.addBodyPart(messageBodyPart);



    try{

    messageBodyPart = new MimeBodyPart();

    DataSource source = new
    FileDataSource(this.plikDoWyslania.getAbsolutePath());

    messageBodyPart.setDataHandler(new DataHandler(source));

    messageBodyPart.setFileName(this.plikDoWyslania.getName());

    multipart.addBodyPart(messageBodyPart);

    } catch (Exception exception) {



    }

    msg.setSubject(this.emailSubjectTxt);

    // msg.setContent(this.emailMsgTxt, "text/html");

    msg.setContent(multipart);



    Transport t = session.getTransport("smtp");

    t.send(msg);



    //Transport.send(msg);



    } catch (MessagingException e){

    e.printStackTrace();

    throw new MessagingException( );





    }

    }





    Thanks for any help.



    Regards



    Marius
     
    kiel44, Jul 19, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nialltimpson

    Javax.mail / smtp hostquestion

    nialltimpson, Feb 20, 2005, in forum: Java
    Replies:
    4
    Views:
    453
    Roland
    Feb 21, 2005
  2. Replies:
    3
    Views:
    1,120
    Roedy Green
    Jan 24, 2006
  3. Mark Carter
    Replies:
    2
    Views:
    931
    Jp Calderone
    Dec 30, 2003
  4. Alex Hunsley
    Replies:
    4
    Views:
    3,639
    Tim Williams (gmail)
    Jun 29, 2004
  5. Raaijmakers, Vincent \(GE Infrastructure\)

    RE: sending of mail (smtp) - connection refused - but smtp serveris running!

    Raaijmakers, Vincent \(GE Infrastructure\), Jun 29, 2004, in forum: Python
    Replies:
    0
    Views:
    904
    Raaijmakers, Vincent \(GE Infrastructure\)
    Jun 29, 2004
Loading...

Share This Page