Error when sending mail
5 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Thursday, December 18, 2003 09:13 AM

I have made a javax mail program to send mails. But it doesn´t work. I got the following error message?

			
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
class javax.mail.SendFailedException: 530 5.7.1 Relaying not allowed: j_
skovbon@hotmail.com

Can anybody tell me what´s wrong?



Thanks

Re: Error when sending mail

Posted By:   Henry_Chiong  
Posted On:   Wednesday, January 28, 2004 02:36 PM

You probably have invalid email addresses. Add this code to your MessagingException.



try {

}
catch (MessagingException me)
{
Exception e = me;
if (e instanceof SendFailedException) {
SendFailedException sfe = (SendFailedException) e;
Address[] invalid = sfe.getInvalidAddresses();
if (invalid != null) {
for (int i = 0; i < invalid.length; i++)
System.out.println("Invalid Email Address " +
invalid[i]);
}
}
}



I hope this help.

Re: Error when sending mail

Posted By:   Octavio_Luna  
Posted On:   Monday, January 26, 2004 09:41 AM


Hi

I'm sure that the error is not your program, the Exception are telling you that the SMTP Server that you are using CAN NOT accept sending mails from other domain than the one programmed within



By example if youre trying to do somethin like this:

smtp: yourmailserver.com

from: prueba@somewhereelse.com


to: anyone@hotmail.com

bla, bla....



Your server won't permit it because it thinks that youre trying to use it for spam.



you'll have to change it to:

smtp: yourmailserver.com

from: prueba@yourmailserver.com


to: anyone@hotmail.com

bla, bla....



where "prueba@yourmailserver.com" is a valid email address in your domain.



Reead about "Relaying in Mail Servers" in Google ore somewhere else.





Octavio

Re: Error when sending mail

Posted By:   Anonymous  
Posted On:   Monday, January 12, 2004 09:50 PM

you should requied mail authentication?try to authenticate

Re: Error when sending mail

Posted By:   Anonymous  
Posted On:   Monday, January 12, 2004 07:59 PM

package name;
import javax.mail.Authenticator;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.Multipart;
import javax.mail.Message;
import javax.mail.BodyPart;
import javax.mail.Message.RecipientType;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.InternetAddress;

import java.util.Properties;

public class Mailer
{

public String mimeType;

private MimeMessage message;

public void setSession(){

Properties props = new Properties();
JAuthenticate pAuth = new JAuthenticate();
props.put("mail.smtp.host", "mail.address");
props.put("mail.smtp.auth", "true");
Session s = Session.getInstance(props, pAuth);
message = new MimeMessage(s);

}

public void setRecipients(String[] toWhom) throws javax.mail.MessagingException{

for(int i=0; i message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(toWhom[i]));
}
}

public void setSubject(String subject) throws javax.mail.MessagingException{

message.setSubject(subject);
}


public void setMimeType(String mimeType) throws javax.mail.MessagingException{

this.mimeType = mimeType;
}

public void setContent(String content) throws javax.mail.MessagingException{

BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setContent(content,"text/html");
MimeMultipart multipart= new MimeMultipart("alternative");
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
}

public void setFrom() throws javax.mail.MessagingException{

message.setFrom(new InternetAddress("admin@icmspot.com"));

}

public void setFrom(String from) throws javax.mail.MessagingException{

message.setFrom(new InternetAddress(from));


}

public void addAttachment(File file)
{
String contentType = message.getContentType();
if (contentType.indexOf("multipart/mixed")>=0)
{
for (int m=0; m {
BodyPart bp = multipart.getBodyPart(m);
String attachmentName = bp.getFileName("ss.jsp");
//process attachment
}
}
}

public void removeAttachment(int position)
{

}

public void removeAllAttachments()
{

}
public int getAttachmentsCount()
{
String contentType = message.getContentType();
if (contentType.indexOf("multipart/mixed")>=0)
{
for (int m=0; m {
BodyPart bp = multipart.getBodyPart(m);
String attachmentName = bp.getFileName("ss.jsp");
//process attachment
}
}

}
public void send() throws javax.mail.MessagingException{

Transport.send(message);
}


} // class

Re: Error when sending mail

Posted By:   alessandro_colombo  
Posted On:   Wednesday, January 7, 2004 01:24 PM

you are using an smtp server that does not allow relay.
just set your usual smtp server instead of "your.smtp.server".


Properties props = new Properties();
props.put("mail.smtp.host", "your.smtp.server");


Paolo Denti
About | Sitemap | Contact