Please Help! java.mail trouble shooting for MMS sending over mm3

Discussion in 'Java' started by Andrea Maschio, Dec 5, 2003.

  1. I need to send mail relaying with an smtp server that checks the
    headers section of the data field. The "TO" field should be the same
    as the "RCPT TO:" command, but without domain information.
    Code is just an example and it may not work. What i need is this:

    HELO ...
    MAIL FROM:<..>
    //here it is the recipient with domain name
    RCPT TO:<

    DATA

    MIME-Version: 1.0
    Subject: #subject
    Date: Wed, 19 Nov 2003 16:42:53 +0100
    From: #from

    //here it is the number without domain name.
    To: +1234567890

    Content-Type: multipart/mixed;
    boundary="----_=_NextPart_002_01C3AEB3.CB517C80"

    ------_=_NextPart_002_01C3AEB3.CB517C80
    Content-Type: application/smil;

    [..]

    <code>
    import java.util.*;
    import javax.activation.*;
    import javax.mail.*;
    import javax.mail.internet.*;

    private String msgId;
    private java.util.Vector attachments;
    private int err;
    private String err_description;
    private String subject;
    private String textbody;
    private String to;
    private String from;

    Multipart mp = new MimeMultipart();
    Properties props = new Properties();
    Session session = Session.getDefaultInstance(props, null);

    MimeMessage msg = new MimeMessage(session);
    MimeBodyPart mbp1 = new MimeBodyPart();

    String host = #myserver;

    props.put("mail.smtp.host", host);
    session.setDebug(debug);
    try {
    msg.setFrom(new InternetAddress(from));
    //destinatari
    InternetAddress[] address = {new InternetAddress(to)};
    /*---------------------------------------------------
    recipients field sets "RCPT TO:" session field.
    the trouble is that this field is also changed by the
    msg.setHeaders("to", value) field */
    msg.setRecipients(Message.RecipientType.TO, address);

    //soggetto

    msg.setSubject(#my subject)
    msg.setSentDate(new Date());
    //msg.addHeader();
    //create MIME
    for (int i = 0; i < attachments.size(); i++) {

    String fileName = (String) (attachments.get(i));

    DataSource source1 = new FileDataSource(fileName);
    mbp1.setDataHandler(new DataHandler(source1));
    mbp1.setFileName(fileName);

    }

    //aggiungo la parte al MImeBody
    mp.addBodyPart(mbp1);

    //inserisco i contenuti nel messaggio
    /*--------------------------------------------
    i've tried changing these value, but it changes also the session's "to
    //property", it causes the "RCPT TO:" to be like what you set here, so
    it's without domain*/

    msg.setHeader("to", #number);

    msg.setContent(mp);
    msg.saveChanges();


    Transport.send(msg);
    }
    catch (MessagingException mex) {

    System.out.println(mex.toString())
    return false;

    }
    </code>
     
    Andrea Maschio, Dec 5, 2003
    #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. =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=

    Please save me from shooting myself in the head!

    =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=, Oct 18, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    803
    =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=
    Oct 19, 2005
  2. Sean Kenwrick

    [OT] Shooting yourself in the foot

    Sean Kenwrick, Jan 30, 2004, in forum: C Programming
    Replies:
    11
    Views:
    562
  3. Replies:
    0
    Views:
    1,416
  4. guptha
    Replies:
    0
    Views:
    596
    guptha
    Feb 2, 2010
  5. Miloud Kabsh

    trouble shooting/debugging asp hang

    Miloud Kabsh, Mar 4, 2004, in forum: ASP General
    Replies:
    2
    Views:
    102
    Miloud Kabsh
    Mar 6, 2004
Loading...

Share This Page