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

A

Andrea Maschio

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:<[email protected]

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top