HELP! com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1

This is the error we are getting, i am able to sendout this with no problems if i send it to someone with our domain name.. like myself jcollazo@mmsquared but i can't send it to an external account like a yahoo, msn, gmail etc.. Any ideas?

ERROR:

javax.mail.SendFailedException: Invalid Addresses;

nested exception is:

com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 <irishlass54@comcast.net>... Relaying denied. Proper authentication required.

at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1196)

at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:584)

at javax.mail.Transport.send0(Transport.java:169)

at javax.mail.Transport.send(Transport.java:98)

at SimpleSender.sendpdf(SimpleSender.java:139)

at NoF.main(NoF.java:657)

Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 <irishlass54@comcast.net>... Relaying denied. Proper authentication required.

at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1047)

... 5 more

THIS is the code we are using....

import javax.mail.*;

import javax.mail.internet.*;

import javax.activation.*;

import java.util.*;

import java.io.*;

/**

* Send out Notice of Facilitation E-Mails. There is a "main" for

*testing the sender, but the expected use is to call the static

*member SimpleSender.sendpdf( . . . );

* This class uses http://java.sun.com/products/javamail.

* This class expects Java2 Enterprise Edition, but can be run from

* J2SE if you download activation.jar and mail.jar from the javamail

* website. It should work in JDK 1.4 or higher.

*

* @author Jim Gast, jim@theGasts.net

*/

public class SimpleSender

{

/**

* The SMTP server for MM2

*/

public static final String SMTP_SERVER = "66.179.174.223";

// public static final String SMTP_SERVER = "smtp.charter.net";

/**

* All notice-of-facilitation E-Mails will look like they came

* from this (possibly fictitious) email address. If a

* customer wants to supply a return address (e.g. an AXES email)

* we can make this a parameter.

*/

public static final String SMTP_FROM = "jcollazo@mmsquared.com";

// public static final String SMTP_FROM = "jgast@charter.net";

/**

* makeEmptyMessage() makes an empty java.mail.internet.MimeMessage

* for subsequent sending as an E-Mail.

* @return an empty message to be filled in.

*/

public static Message makeEmptyMessage() {

Properties props = System.getProperties();

// -- Attaching to default Session, or we could start a new one --

props.put("mail.smtp.host", SMTP_SERVER);

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

// -- Create a new message --

Message msg = new MimeMessage(session);

return msg;

}

/**

* getFileBodyPart creates a BodyPart that contains a FileDataSource

*to go into the E-Mail. It uses DataHandler from

*javax.activation so there needs to be a DataContentHandler

*for the mimeType you choose.

* @param filenamethe name of the file to be inserted.

* @param mimeTypea valid mimeType that has a DataContentHandler.

* @returnthe BodyPart containing the content.

* @throws javax.mail.MessagingException

*/

public static BodyPart getFileBodyPart(String filename, String mimeType)

throws javax.mail.MessagingException {

BodyPart bp = new MimeBodyPart();

try {

bp.setContent(new MimeBodyPart(new FileInputStream(filename)),

mimeType);

} catch (Exception e) {

e.printStackTrace();

}

bp.setDataHandler(new DataHandler

(new FileDataSource(filename)));

return bp;

}

/**

* sendpdf creates an e-mail with a plaintext body and a pdf

* attachment.

* @param tothe e-mail address of the recipient

* @param subjectthe subject put on the E-mail

* @param textFilethe ASCII version of the E-mail. NOTE:

* this file should include one line for the

*mimeType (typically text/plain) and a blank

*line separating headers from the body.

* @param pdfFilethe PDF file to be attached to the E-Mail.

*/

public static void sendpdf(String to, String subject,

String textFile, String pdfFile)

{

try

{

// -- Create a new message --

Message msg = makeEmptyMessage();

// -- Set the FROM and TO fields --

msg.setFrom(new InternetAddress(SMTP_FROM));

msg.setRecipients(Message.RecipientType.TO,

InternetAddress.parse(to, false));

// -- We could include CC recipients too --

// if (cc != null)

// msg.setRecipients(Message.RecipientType.CC

// ,InternetAddress.parse(cc, false));

// -- Set the subject and body text --

msg.setSubject(subject);

// -- Set some other header information --

msg.setHeader("X-Mailer", "MM2Email");

msg.setSentDate(new Date());

// Use "alternative if you are sending HTML and plaintext

//so the recipient only sees one of the two alternates.

// MimeMultipart mp = new MimeMultipart("alternative");

MimeMultipart mp = new MimeMultipart("related");

MimeBodyPart textPart =

new MimeBodyPart(new FileInputStream(textFile));

mp.addBodyPart(textPart);

BodyPart pdfPart =

getFileBodyPart(pdfFile, "application/x-pdf");

// pdfPart.setDataHandler(

// new DataHandler(new FileDataSource("nof.pdf"),

// "text/plain"));

String ctString = "APPLICATION/PDF; name=" + pdfFile;

pdfPart.setHeader("Content-Type", ctString);

// Set Content-Disposition to attachment for an E-Mail attachment.

// Set Content-Disposition to inline if making a web-page, instead.

String cdString = "attachment; filename=" + pdfFile;

pdfPart.setHeader("Content-Disposition", cdString);

mp.addBodyPart(pdfPart);

msg.setContent(mp);

// -- Send the message --

Transport.send(msg);

// System.out.println("Message sent OK.");

}

catch (Exception ex)

{

ex.printStackTrace();

}

}

/**

* The main method can be used to unit test the class.

*It expects a plaintext file nof.txt containing at least

*a one-line mime type and a blank line to end the headers.

*It also expects a PDF file named nof.pdf.

*/

public static void main(String args[])

{

try

{

// String smtpServer="smtp.charter.net";

// String to="nstafford@mmsquared.com";

// String from="irishlass54@comcast.net";

// String subject="This is from java";

// String body="This E-Mail came from a java app at mm2";

// send(smtpServer, to, from, subject, body);

//sendpdf("jgast@tds.net", "AXES order number 3255202",

//"nof.txt", "nof.pdf");

sendpdf("nstafford@mmsquared.com", "NOF",

"nof.txt", "nof.pdf");

sendpdf("nkontoleon@axestrade.com", "NOF",

"nof.txt", "nof.pdf");

//sendpdf("pgaffney@axestrade.com", "NOF",

//"nof.txt", "nof.pdf");

//sendpdf("akyle@axestrade.com", "NOF",

//"nof.txt", "nof.pdf");

}

catch (Exception ex)

{

System.out.println("Usage: java SimpleSender"

+" smtpServer toAddress fromAddress subjectText bodyText");

}

System.exit(0);

}

}

[7621 byte] By [mm2jcollazoa] at [2007-11-26 16:20:58]
# 1
http://java.sun.com/products/javamail/FAQ.html#norelay
DrClapa at 2007-7-8 22:44:35 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...