This discussion is archived
9 Replies Latest reply: Apr 23, 2013 2:23 PM by bshannon RSS

550 Unable to relay NTML

670314 Newbie
Currently Being Moderated
Hi,

I'm trying to send an email from MsExhange with NTML Auth.

the problem is that JAVAMAIL return this error:

javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
     javax.mail.SendFailedException: 550 5.7.1 Unable to relay


The code is:

public static void SendMailSSL(String SMTPHost,
String SMTPPort,
String SMTPDomain,
String SMTPUsern,
String SMTPUserp,
String SMTPAuth,
String from,
String to,
String cc,
String bcc,
String subject,
String body,
oracle.sql.BLOB attachmentData,
String attachmentType,
String attachmentFileName)

{
int rc = 0;
String timeOut = "3000";
String[] arr;
int portMsg = Integer.parseInt(SMTPPort);
int auth = Integer.parseInt(SMTPAuth);

try
{
Properties props = System.getProperties();
props.put("mail.smtp.host", SMTPHost);
props.put("mail.smtp.port", portMsg);
props.put("mail.smtp.timeout", timeOut);

if (auth == 1) {
props.setProperty("mail.smtp.auth", "true");
}

Session session = Session.getDefaultInstance(props, null);
session.setDebug(true);

Message msg =
new MimeMessage(session);

msg.setFrom(new InternetAddress(from));

if (to != "_noRecipients_")
{
arr = to.split(";");
for(int i=0; i<arr.length; i++){
msg.addRecipient(Message.RecipientType.TO,
new InternetAddress(arr));
}
}

if (cc != null)
{
arr = cc.split(";");
for(int i=0; i<arr.length; i++){
msg.addRecipient(Message.RecipientType.CC,
new InternetAddress(arr[i]));
}
}

if (bcc != null)
{
arr = bcc.split(";");
for(int i=0; i<arr.length; i++){
msg.addRecipient(Message.RecipientType.BCC,
new InternetAddress(arr[i]));
}
}

if ( subject != null & subject.length() > 0 )
msg.setSubject(subject);
else msg.setSubject("(no subject)");

msg.setSentDate(new Date());

if (attachmentData != null)
{
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setContent((body != null ? body : ""),"text/html");
mbp1.setDisposition(Part.INLINE);

MimeBodyPart mbp2 = new MimeBodyPart();
String type =
(attachmentType != null ? attachmentType : dftMime);

String fileName = (attachmentFileName != null ?
attachmentFileName : dftName);

mbp2.setDisposition(Part.ATTACHMENT);
mbp2.setFileName(fileName);
mbp2.setHeader("Content-Type", type);

mbp2.setDataHandler(new
DataHandler(new BLOBDataSource(attachmentData, type))
);
mbp2.setHeader("Content-Transfer-Encoding", "base64");

MimeMultipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);
msg.setContent(mp);
}
else
{
msg.setContent((body != null ? body : ""),"text/html");
}

Transport transport = session.getTransport("smtp");
transport.connect(SMTPHost, portMsg,SMTPUsern, SMTPUserp);

transport.sendMessage(msg, msg.getAllRecipients());
transport.close();

rc = 1;
} catch (Exception e)
{         
throw new RuntimeException(e);
}
}

Any idea

Thanks
  • 1. Re: 550 Unable to relay NTML
    bshannon Pro
    Currently Being Moderated
    What version of JavaMail are you using?

    If you examine the debug output, does it show JavaMail authenticating to your server?
    Is the SMTPAuth parameter passed in as "1"?

    You might need to change Session.getDefaultInstance to Session.getInstance.
    http://www.oracle.com/technetwork/java/javamail/faq/index.html#commonmistakes

    If none of that solves your problem, see this FAQ entry:
    http://www.oracle.com/technetwork/java/javamail/faq/index.html#norelay
  • 2. Re: 550 Unable to relay NTML
    670314 Newbie
    Currently Being Moderated
    Hi,

    How can i know my javamail version?

    The question is that we had a .net program and works ok in the same machine...

    Thanks for your response
  • 3. Re: 550 Unable to relay NTML
    bshannon Pro
    Currently Being Moderated
    In the mail.jar file, in META-INF/MANIFEST.MF, there will be version information. If there is no version information,
    you have a very old version and should definitely upgrade. Get the latest version at http://javamail.java.net.
  • 4. Re: 550 Unable to relay NTML
    670314 Newbie
    Currently Being Moderated
    Thanks

    But tow questions...

    How can i upgrade the javamail? And how can i show the debug of javamail? Im executing javamail from plsql and the information of result is poor

    Thanks so much
  • 5. Re: 550 Unable to relay NTML
    bshannon Pro
    Currently Being Moderated
    How to turn on debugging:
    http://www.oracle.com/technetwork/java/javamail/faq/index.html#debug

    I know nothing about PL/SQL so I can't help you there.

    If you didn't install JavaMail to begin with, you may need to find the person who did
    and ask them for help.
  • 6. Re: 550 Unable to relay NTML
    670314 Newbie
    Currently Being Moderated
    Javamail is installed with the Oracle 11G, not installed alone

    This is the METAINF

    Manifest-Version: 1.0
    SCCS-ID: @(#)javamail.mf 1.4 00/09/26
    Extension-Name: javax.mail
    Specification-Title: JavaMail(TM) API Design Specification
    Specification-Version: 1.2
    Specification-Vendor: Sun Microsystems, Inc.
    Implementation-Version: 1.2
    Implementation-Vendor: Sun Microsystems, Inc.
    Implementation-Vendor-Id: com.sun

    Thanks

    Edited by: user10601354 on 23-abr-2013 13:00
  • 7. Re: 550 Unable to relay NTML
    bshannon Pro
    Currently Being Moderated
    That's ancient, at least 12 years old. It's not going to work with NTLM authentication at all.
    You'll need to figure out how to upgrade the version of JavaMail in Oracle 11g.
  • 8. Re: 550 Unable to relay NTML
    670314 Newbie
    Currently Being Moderated
    But i don't understand that the 1.2 is installed with 11g .... ???

    Thanks for all
  • 9. Re: 550 Unable to relay NTML
    bshannon Pro
    Currently Being Moderated
    Me neither. I don't know if 11g comes with an old version of JavaMail, or if someone installed it for you.
    There's probably a forum specific to the Oracle DB where you could ask this.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points