Java sendfailedexception
Hi,
When I try to send a mail from my app it is throwing
javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
class javax.mail.SendFailedException: 598 mail is rejected
any ideas?
Looks like your mail server doesn't want to accept mail from you.
The error message from the mail server isn't very clear about why
it isn't accepting your mail so we have to guess. One guess would be
that it wants you to login first. See the JavaMail FAQ for how to authenticate
to your mail server.
Similar Messages
-
Java mail api: SendFailedException when trying to send Mail via SMTP
Hello,
I'm trying to send a mail via java mail api using a server that requires smtp authentication.
I'm currently using the following code:
protocol = "smtp";
host = "auth.smtp.profimailer.de";
port = 25;
String from="[email protected]";
String to="[email protected]";
props.put("mail.smtp.host", host);
props.put("mail.smtp.auth", "true");
Authenticator auth = new PopupAuthenticator();
session=Session.getInstance(props,auth);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from,"[email protected]"));
message.addRecipient(Message.RecipientType.TO,new InternetAddress(to,"ToName"));
message.setSubject("Hello JavaMail");
message.setText("Welcome to JavaMail");
Transport.send(message);
static class PopupAuthenticator extends Authenticator {
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("e12345676", "mypass");
}When trying to run this code, I get the following exception:
D:\eclipse30RC1\workspace\ClassifyIt\bin>java -cp .;../lib/javamail.jar de.jwannenmacher.classify.TestMail > test.txt
javax.mail.SendFailedException: Send failed;
nested exception is:
javax.mail.SendFailedException: Sender "[email protected]" <jens
@jens-wannenmacher.de> was rejected: 501
at javax.mail.Transport.doSend(Transport.java:223)
at javax.mail.Transport.send(Transport.java:92)
at de.jwannenmacher.mail.pop3client.POP3Client.getAllNewMessages(POP3Cli
ent.java:176)
at de.jwannenmacher.classify.TestMail.main(TestMail.java:22)
Any suggestions on this?
Thanks and best regards,
JensHi,
yes smtp is a standard and I think you could use this with almost every smtp server.
If your smtp server doesn't require authentication you can access it without an authenticator
I think...
Best regards,
Jens -
Java Mail: SendFailedException
I see below error only on few sun boxes and not all, please let me know the cause and also solution for this..... Thanks in advance
javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.MessagingException: 553 5.5.4 <ccu>... Domain name required for sender address ccuWell, this isn't strictly a Messaging Server question, but the error message is pretty plain.
The address you're sending FROM doesn't have a domain part.
bare "user" is not a valid e-mail address,. it must be"user@domain" -
Cannot send email from WD Java
hi Experts,
I have created an email WD Java Application, this application sends an email to the users on click of a button.
My Problem is this application runs well on SP11, but we have upgraded our dev portal to SP14.
On SP14 mail is not send. Please help its really very urgent.
I am pasting the code used for sending email.
wdContext.currentEmailElement().setFrom(wdContext.currentContextElement().getEmpMailID());
wdContext.currentEmailElement().setCc("");
wdContext.currentEmailElement().setBcc("");
wdContext.currentEmailElement().setSubject("Personal Travel Request.");
wdContext.currentEmailElement().setTo("[email protected]");
Properties props = new Properties();
String host = "rmail070.zmail.ril.com";
props.put("rmail070.zmail.ril.com", host);
Session session = Session.getInstance(props, null);
MimeMessage message = new MimeMessage(session);
Address toAddress = new InternetAddress();
Address fromAddress = new InternetAddress();
Address ccAddress = new InternetAddress();
Address bccAddress = new InternetAddress();
try
/* Creates an email object with different parts, one for the
text and another for the attached file */
MimeMultipart multipart = new MimeMultipart();
BodyPart messageBodyPart = new MimeBodyPart();
/* the following statements build up the email */
if (! wdContext.currentEmailElement().getFrom().equals(""))
fromAddress = new InternetAddress(wdContext.currentEmailElement().getFrom());
message.setFrom(fromAddress);
} if (! wdContext.currentEmailElement().getTo().equals(""))
toAddress = new InternetAddress(wdContext.currentEmailElement().getTo());
message.setRecipient(Message.RecipientType.TO,toAddress);
if (! wdContext.currentEmailElement().getCc().equals(""))
ccAddress = new InternetAddress(wdContext.currentEmailElement().getCc());
message.setRecipient(Message.RecipientType.CC,ccAddress);
if (! wdContext.currentEmailElement().getBcc().equals(""))
bccAddress = new InternetAddress(wdContext.currentEmailElement().getBcc());
message.setRecipient(Message.RecipientType.BCC,bccAddress);
if (!wdContext.currentEmailElement().getSubject().equals(""))
message.setSubject(wdContext.currentEmailElement().getSubject());
if (! wdContext.currentEmailElement().getBody().equals(""))
messageBodyPart.setText(wdContext.currentEmailElement().getBody());
multipart.addBodyPart(messageBodyPart);
/* a new part will be added, in the complete email this will
be the attachment */
messageBodyPart = new MimeBodyPart();
// try{
// String filename =WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(),"test.pdf");
// DataSource source = new FileDataSource(filename);
// messageBodyPart.setDataHandler(new DataHandler(source));
// messageBodyPart.setFileName(source.getName());
// messageBodyPart.setHeader("Content-Type","application/pdf");
// multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
Transport.send(message);
// catch(WDAliasResolvingException e)
// e.getMessage();
catch (AddressException e)
wdComponentAPI.getMessageManager().reportWarning(e.
getLocalizedMessage());
e.printStackTrace();
catch (SendFailedException e)
wdComponentAPI.getMessageManager().reportWarning(e.getLocalizedMessage());
e.printStackTrace();
catch (MessagingException e)
wdComponentAPI.getMessageManager().reportWarning(e.getLocalizedMessage());
e.printStackTrace();
Points will be rewarded to helpful answers.
Regards,
Sanjyoti.Hi,
see this link it will be helpful for u
[http://help.sap.com/saphelp_nw04/helpdata/en/f7/f289c67c759a41b570890c62a03519/content.htm|http://help.sap.com/saphelp_nw04/helpdata/en/f7/f289c67c759a41b570890c62a03519/content.htm]
regards
Hazrath -
Error while sending mail when using Java Mail API
Hi Experts,
I am trying to execute a webdynpro application which uses the Java Mail API to send emails. The exception that I get on executing the application is :
Sending failed; nested exception is: javax.mail.SendFailedException: Invalid Addresses; nested exception is: javax.mail.SendFailedException: 550 5.7.1 Unable to relay for [email protected]
Can anybody please help me sort out the issue.
Regards
AbdullahHi,
Usually one get this error if the SMTP server is configured not to relay mails (a security measure) or the SMTP server need the mail to be sent from a trusted IP or with proper authentication. Some SMTP servers are configured to block junk mails.
Pls check with your mail server administrator.
Regards -
How to send mail through java program in solaris server
hi
i am writing java code to send the mail using my company SMTP
,the program is working fine when i run and deploy in windows environment
but at the same time when i deploy the war to sun solaris server ,it is not working
and throwing the Error saying
java.lang.Exception: Invalid Addresses; nested exception is: javax.mail.SendFailedException: 553 sorry, that domain isn't allowed to be relayed thru this MTA without authentication #5.7.1 at jsp.SendMail._jspService(_SendMail.java:137)
i am using the Authentication also using user id and password of same domain and it is able to authenticate
in windows but not in Solaris
where i am making mistake plz
guide.
Saurabhthanks Alan
but i think there is some other problem because same code is
working when i am using in windows as well as i am using authentication method
also but it is not working when running in Solaris Environment
here is the code i am using to send the mail
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", "smtp.mycompany.com");//smtp protocol for IIBF
props.put("mail.smtp.starttls.enable","true");//setting start TLS to be true
props.put("mail.smtp.auth", "true");// authentication is false
props.put("mail.smtp.port", port);//setting the port number it can be either 25 or 587
props.put("mail.smtp.username", "noreply");
props.put("mail.smtp.password","noreply");
props.put("mail.debug", "true");
Authenticator auth = new SMTPAuthenticator();
Session session1 = Session.getDefaultInstance(props);
java.util.Properties sessionProperties = new java.util.Properties();
sessionProperties.put("mail.smtp.auth", "true");
message.setFrom(new javax.mail.internet.InternetAddress(From ,"name"));
message.addRecipient(javax.mail.Message.RecipientType.TO, new javax.mail.internet.InternetAddress(To));
message.setText(TextCo);
message.setSubject(subject);
message.setContent(boyd, "text/plain");
message.reply(true);
Transport trans = session1.getTransport("smtp");
trans.connect(SMTP_HOST_NAME, SMTP_AUTH_USER, SMTP_AUTH_PWD);
boolean ddd = trans.isConnected();
message.saveChanges();
trans.sendMessage(message, message.getAllRecipients());
above code is working properly in windows but not in Solaris
plz guide what next to do
thankx in advance
saurabh -
Java.lang.NullPointerException: When Get the PDF File Name
Hi,
i try to follow the blog on <b>Handling FileUpload and FileDownload in NetWeaver Developer Studio(NWDS) 2004S</b> on /people/rekha.malavathu2/blog/2006/12/12/handling-fileupload-and-filedownload-in-netweaver-developer-studionwds-2004s
as i create a fileupload and i wish to get the file name and the pdf, then i to run and deploy it but i get <b>java.lang.NullPointerException</b>
the code are as below when i click on send email button
IPrivateEmail.IFileUploadNodeNode node = wdContext.nodeFileUploadNode();
IPrivateEmail.IFileUploadNodeElement fileUploadEle = node.createFileUploadNodeElement();
try{
IWDResource resource = WDResourceFactory.createResource(wdContext.currentContextElement().getFileUploadUI().read(true), wdContext.currentContextElement().getFileUploadUI().getResourceName(), WDWebResourceType.PDF, true);
fileUploadEle.setFileUploadAttr(resource);
fileUploadEle.setFileUploadName(wdContext.currentContextElement().getFileUploadUI().getResourceName());
node.addElement(fileUploadEle);
}catch(Exception e){
wdComponentAPI.getMessageManager().reportSuccess("ERROR"+e.getMessage());
but i wonder which part of the code i did wrongly.. as i wish to insert into my send email code
Properties props = new Properties();
String host = "SMTP HOST";
props.put("mail.smtp.host", host);
Session session = Session.getInstance(props, null);
MimeMessage message = new MimeMessage(session);
Address toAddress = new InternetAddress();
Address fromAddress = new InternetAddress();
Address ccAddress = new InternetAddress();
Address bccAddress = new InternetAddress();
try
MimeMultipart multipart = new MimeMultipart();
BodyPart messageBodyPart = new MimeBodyPart();
if (! wdContext.currentEmailElement().getFrom().equals(""))
fromAddress = new InternetAddress(wdContext.currentEmailElement().getFrom());
message.setFrom(fromAddress);
if (! wdContext.currentEmailElement().getTo().equals(""))
toAddress = new InternetAddress(wdContext.currentEmailElement().getTo());
message.setRecipient(Message.RecipientType.TO, toAddress);
if (! wdContext.currentEmailElement().getCc().equals(""))
ccAddress = new InternetAddress(wdContext.currentEmailElement().getCc());
message.setRecipient(Message.RecipientType.CC, ccAddress);
if (! wdContext.currentEmailElement().getBcc().equals(""))
bccAddress = new InternetAddress(wdContext.currentEmailElement().getBcc());
message.setRecipient(Message.RecipientType.BCC, bccAddress);
if (! wdContext.currentEmailElement().getSubject().equals(""))
message.setSubject(wdContext.currentEmailElement().getSubject());
if (! wdContext.currentEmailElement().getBody().equals(""))
messageBodyPart.setText(wdContext.currentEmailElement().getBody());
multipart.addBodyPart(messageBodyPart);
messageBodyPart = new MimeBodyPart();
String filename = IWDResource.getResourceName();
DataSource source = new FileDataSource(filename);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(source.getName());
messageBodyPart.setHeader("Content-Type","application/pdf");
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
Transport.send(message);
catch (AddressException e)
wdComponentAPI.getMessageManager().reportWarning(e.getLocalizedMessage());
e.printStackTrace();
catch (SendFailedException e)
wdComponentAPI.getMessageManager().reportWarning(e.getLocalizedMessage());
e.printStackTrace();
catch (MessagingException e)
wdComponentAPI.getMessageManager().reportWarning(e.getLocalizedMessage());
e.printStackTrace();
so i wonder could anyone help me out.. as i need to get the pdf filename order to put into the variable call <b>filename</b> at the send mail code.
below is the error message
java.lang.NullPointerException
at com.sap.example.uploademail.Email.wdDoInit(Email.java:124)
at com.sap.example.uploademail.wdp.InternalEmail.wdDoInit(InternalEmail.java:146)
at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.doInit(DelegatingView.java:61)
at com.sap.tc.webdynpro.progmodel.controller.Controller.initController(Controller.java:215)
at com.sap.tc.webdynpro.progmodel.view.View.initController(View.java:445)
at com.sap.tc.webdynpro.progmodel.controller.Controller.init(Controller.java:200)
at com.sap.tc.webdynpro.progmodel.view.ViewManager.getView(ViewManager.java:709)
at com.sap.tc.webdynpro.progmodel.view.ViewManager.bindRoot(ViewManager.java:579)
at com.sap.tc.webdynpro.progmodel.view.ViewManager.init(ViewManager.java:155)
at com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.doOpen(WebDynproWindow.java:295)
at com.sap.tc.webdynpro.clientserver.window.ApplicationWindow.show(ApplicationWindow.java:183)
at com.sap.tc.webdynpro.clientserver.window.ApplicationWindow.open(ApplicationWindow.java:178)
at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.init(ClientApplication.java:364)
at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.initApplication(ApplicationSession.java:748)
at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:283)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingStandalone(ClientSession.java:759)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:712)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:261)
at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:149)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doGet(DispatcherServlet.java:46)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)facing same issue.
jdev 10.1.3.3.0, on expanding the database connection, I get a null pointer exception.
On the testing the connection it says 'success' though.
any inputs ? -
Dears,
I have a database package to send an email to an employee, whole package working well except the send mail part, the error raised from java code i used says ( Can't send command to SMTP host No trusted certificate found).
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class SendMail {
// Sender, Recipient, CCRecipient, and BccRecipient are
// commaseparated lists of addresses.
// Body can span multiple CR/LF-separated lines.
// Attachments is a ///-separated list of file names.
public static int Send(String SMTPServer,
String Sender,
String Recipient,
String CcRecipient,
String BccRecipient,
String Subject,
String Body,
String ErrorMessage[],
String Attachments) {
// Error status
int ErrorStatus = 0;
// Create some properties and get the default Session
Properties props = System.getProperties();
//props.put("MyMailingServer", SMTPServer);
props.put("mail.smtp.starttls.enable", "false");
// mail.smtp.starttls.enable=false;
props.put("mail.smtp.host", SMTPServer);
props.put("mail.smtp.port", 25);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.auth", "user");
props.put("mail.smtp.auth", "password");
Session session = Session.getDefaultInstance(props, null);
try {
// Create a message
MimeMessage msg = new MimeMessage(session);
// extracts the senders and adds them to the message
// Sender is a comma-separated list of e-mail addresses as per RFC822
InternetAddress[] TheAddresses = InternetAddress.parse(Sender);
msg.addFrom(TheAddresses);
// Extract the recipients and assign them to the message.
// Recipient is a comma-separated list of e-mail addresses as per RFC822.
InternetAddress[] TheAddresses = InternetAddress.parse(Recipient);
msg.addRecipients(Message.RecipientType.TO,TheAddresses);
// Extract the Cc-recipients and assign them to the message.
// CcRecipient is a comma-separated list of e-mail addresses as per RFC822.
if (null != CcRecipient) {
InternetAddress[] TheAddresses = InternetAddress.parse(CcRecipient);
msg.addRecipients(Message.RecipientType.CC,TheAddresses);
// Extract the Bcc-recipients and assign them to the message.
// BccRecipient is a comma-separated list of e-mail addresses as per RFC822.
if (null != BccRecipient) {
InternetAddress[] TheAddresses = InternetAddress.parse(BccRecipient);
msg.addRecipients(Message.RecipientType.BCC,TheAddresses);
// Subject field
msg.setSubject(Subject);
// Create the Multipart to be added the parts to
Multipart mp = new MimeMultipart();
// Create and fill the first message part
MimeBodyPart mbp = new MimeBodyPart();
mbp.setText(Body);
// Attach the part to the multipart
mp.addBodyPart(mbp);
// Attach the files to the message
if (null != Attachments) {
int StartIndex = 0, PosIndex = 0;
while (-1 != (PosIndex = Attachments.indexOf("///",StartIndex))) {
// Create and fill other message parts;
MimeBodyPart mbp = new MimeBodyPart();
FileDataSource fds =
new FileDataSource(Attachments.substring(StartIndex,PosIndex));
mbp.setDataHandler(new DataHandler(fds));
mbp.setFileName(fds.getName());
mp.addBodyPart(mbp);
PosIndex += 3;
StartIndex = PosIndex;
// Last, or only, attachment file
if (StartIndex < Attachments.length()) {
MimeBodyPart mbp = new MimeBodyPart();
FileDataSource fds = new FileDataSource(Attachments.substring(StartIndex));
mbp.setDataHandler(new DataHandler(fds));
mbp.setFileName(fds.getName());
mp.addBodyPart(mbp);
// Add the Multipart to the message
msg.setContent(mp);
// set the Date: header
msg.setSentDate(new Date());
// Send the message
Transport.send(msg);
} catch (MessagingException MsgException) {
ErrorMessage[0] = MsgException.toString();
Exception TheException = null;
if ((TheException = MsgException.getNextException()) != null)
ErrorMessage[0] = ErrorMessage[0] + "\n" + TheException.toString();
ErrorStatus = 1;
return ErrorStatus;
} // End Send Class
} // End of public class SendMaili changed my smtp server and now i am getting the following error...please help
C:\trainee>java Emailer
Cannot send email. javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 504 <nb123@tcs05>: Sende
r address rejected: need fully-qualified address
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 504 <nb123@tcs05>: Sende
r address rejected: need fully-qualified address
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 504 <nb123@tcs05>: Sende
r address rejected: need fully-qualified address -
Problem in sending mail using java mail api
This is the pogram I am using as of now to send a mail to yahoo id.
import javax.mail.*;
import javax.mail.internet.*;
public class SendingMail2
public SendingMail2()
try
String from = "ravikiran_sunrays";
String to = "[email protected]";
String subject = "the subject u wanna send ";
String cc="[email protected]";
String bcc="[email protected]";
String text="the matter that u wanna send ";
java.util.Properties prop = System.getProperties();
prop.put("mail.smtp.host","mail.yahoo.com");
//prop.put("http.proxyHost",System.getProperty("http.proxyHost"));
//prop.put("http.proxyPort","8080");
//prop.put("http.proxyPort",System.getProperty("http.proxyPort"));
//prop.put("http.proxyHost","172.19.48.201");
//System.getProperties().setProperty("http.proxyPort","8080");
//System.getProperties().setProperty("http.proxyHost","172.19.48.201");
Session ses = Session.getInstance(prop,null);
MimeMessage message = new MimeMessage(ses);
try
Address fromAddress = new InternetAddress(from);
message.setFrom(fromAddress);
message.setSubject(subject);
Address[] toAddress = InternetAddress.parse(to);
Address[] cc_address=InternetAddress.parse(cc);
Address[] bcc_address=InternetAddress.parse(bcc);
message.setRecipients(Message.RecipientType.TO,toAddress);
message.setRecipients(Message.RecipientType.CC,cc_address);
message.setRecipients(Message.RecipientType.BCC,bcc_address);
message.setSentDate(new java.util.Date());
message.setText(text);
Transport.send(message);
System.out.println("Mail Successfully Sent");
catch(Exception e)
System.out.println("Problem " + e);
catch(Exception e)
System.out.println("Problem " + e);
public static void main(String[] args)
SendingMail2 sendingMail2 = new SendingMail2();
This is the exception I am getting when I try 2 execute that program.
avax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.MessagingException: Unknown SMTP host: mail.yahoo.com;
nested exception is:
java.net.UnknownHostException: mail.yahoo.comlisten buddy
this is a class i made it is easy to understand it sends mails and check inbox just adduser from telnet with remote manager in james create the three accounts i am using and then use this class and its methods
also the next class that contains the mails test my class and what i am saying
import java.io.*;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
public class MailClient
extends Authenticator
public static final int SHOW_MESSAGES = 1;
public static final int CLEAR_MESSAGES = 2;
public static final int SHOW_AND_CLEAR =
SHOW_MESSAGES + CLEAR_MESSAGES;
protected String from;
protected Session session;
protected PasswordAuthentication authentication;
public MailClient(String user, String host)
this(user, host, false);
public MailClient(String user, String host, boolean debug)
from = user + '@' + host;
authentication = new PasswordAuthentication(user, user);
Properties props = new Properties();
props.put("mail.user", user);
props.put("mail.host", host);
props.put("mail.debug", debug ? "true" : "false");
props.put("mail.store.protocol", "pop3");
props.put("mail.transport.protocol", "smtp");
session = Session.getInstance(props, this);
public PasswordAuthentication getPasswordAuthentication()
return authentication;
public void sendMessage(
String to, String subject, String content)
throws MessagingException
System.out.println("SENDING message from " + from + " to " + to);
System.out.println();
MimeMessage msg = new MimeMessage(session);
msg.addRecipients(Message.RecipientType.TO, to);
msg.setSubject(subject);
msg.setText(content);
Transport.send(msg);
public void checkInbox(int mode)
throws MessagingException, IOException
if (mode == 0) return;
boolean show = (mode & SHOW_MESSAGES) > 0;
boolean clear = (mode & CLEAR_MESSAGES) > 0;
String action =
(show ? "Show" : "") +
(show && clear ? " and " : "") +
(clear ? "Clear" : "");
System.out.println(action + " INBOX for " + from);
Store store = session.getStore();
store.connect();
Folder root = store.getDefaultFolder();
Folder inbox = root.getFolder("inbox");
inbox.open(Folder.READ_WRITE);
Message[] msgs = inbox.getMessages();
if (msgs.length == 0 && show)
System.out.println("No messages in inbox");
for (int i = 0; i < msgs.length; i++)
MimeMessage msg = (MimeMessage)msgs;
if (show)
System.out.println(" From: " + msg.getFrom()[0]);
System.out.println(" Subject: " + msg.getSubject());
System.out.println(" Content: " + msg.getContent());
if (clear)
msg.setFlag(Flags.Flag.DELETED, true);
inbox.close(true);
store.close();
System.out.println();
====================================
testing this class
=======================================
public class JamesConfigTest
public static void main(String[] args)
throws Exception
// CREATE CLIENT INSTANCES
MailClient redClient = new MailClient("red", "localhost");
MailClient greenClient = new MailClient("green", "localhost");
MailClient blueClient = new MailClient("blue", "localhost");
// CLEAR EVERYBODY'S INBOX
redClient.checkInbox(MailClient.CLEAR_MESSAGES);
greenClient.checkInbox(MailClient.CLEAR_MESSAGES);
blueClient.checkInbox(MailClient.CLEAR_MESSAGES);
Thread.sleep(500); // Let the server catch up
// SEND A COUPLE OF MESSAGES TO BLUE (FROM RED AND GREEN)
redClient.sendMessage(
"blue@localhost",
"Testing blue from red",
"This is a test message");
greenClient.sendMessage(
"blue@localhost",
"Testing blue from green",
"This is a test message");
Thread.sleep(500); // Let the server catch up
// LIST MESSAGES FOR BLUE (EXPECT MESSAGES FROM RED AND GREEN)
blueClient.checkInbox(MailClient.SHOW_AND_CLEAR);
=======================================================
it suppose to print this
Clear INBOX for red@localhost
Clear INBOX for green@localhost
Clear INBOX for blue@localhost
SENDING message from red@localhost to blue@localhost
SENDING message from green@localhost to blue@localhost
Show and Clear INBOX for blue@localhost
From: green@localhost
Subject: Testing blue from green
Content: This is a test message
From: red@localhost
Subject: Testing blue from red
Content: This is a test message
thanks a lot
but i need ur help plzzzzzzzzzzzz
i can create account from telnet
but how i can create a new account from java .. a jsp page that i made to create a new account on the server
plzzzzzzzz help me
bye -
Java mail api error- Please Help
Hi, i have set up an smtp server on my local machine. i have given the smtp host address as 127.0.0.1
I am getting the following error though. please help me out with the problem
C:\trainee>java Emailer
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for [email protected]
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for [email protected]
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for [email protected]
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for [email protected]
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for [email protected]
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for [email protected]
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for [email protected]
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 Emailer.sendEmail(Emailer.java:151)
at Emailer.main(Emailer.java:194)
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for [email protected]
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for [email protected]
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for [email protected]
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for [email protected]
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1047)
... 5 more
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for [email protected]
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for [email protected]
... 6 more
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for [email protected]
... 6 moreIt's a configuration error in your smtp server.
See the JavaMail FAQ for more information. -
Sending an email in java: (help a Beginner !)
hi,
i am new to java mail and trying to send a test mail and here's my code
Properties props = new Properties();
props.put("mail.host"," smtp ");
Session mail = Session.getInstance(props,null);
mail.setDebug(true);
final Message msg = new MimeMessage(mail);
Address to = new InternetAddress("to");
Address from = new InternetAddress("from");
msg.setFrom(from);
msg.setRecipient(Message.RecipientType.TO,to);
msg.setSubject("Java TEST ");
Transport.send(msg);
(with the assumption that i have correct details of the server and to and from addresses)
but i get the following exception :
javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.MessagingException: Could not connect to SMTP host: smtp.host, port: 25;
nested exception is:
java.net.NoRouteToHostException: No route to host: connect
(oh, and i also have the try and catch thing for the code)
can u help?
thxwith the assumption that i have correct details of the serverSeems like a bad assumption, seeing as you can't connect to what you put in as the name of your SMTP server. Talk to your network people and find out what the real name of the server is. (Probably not "smtp" or "smtp.host".) If you have it right, ask them why you can't connect to it.
-
Sending HTML E Mail using Java Mail
Can anybody please tell me how to send HTML email using JavaMail. I know I need the DataContentHandler for text/html mime type but where can I find one? If anybody has better suggestions you are welcome.
Folks,
I've used what you have suggested. Though it compiled, I kept getting this java error
--Exception in MailServer.java
javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.MessagingException: IOException while sending message;nested exception is:
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type text/html
at javax.mail.Transport.send0(Transport.java:204)
at javax.mail.Transport.send(Transport.java:73)
at MailTest.send(MailTest.java:419)
at MailTest.sendThruDefaultServer(MailTest.java:319)
at MailTest.main(MailTest.java:476)
[sendEmail() - Exception :javax.activation.UnsupportedDataTypeException
HELP! -
I am not able to send email using JAVA API to outer email
If I am trying to send email from my company account to yahoo I am getting following errors:
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
for [email protected]
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 MailSend.main(MailSend.java:116)
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to rel
ay for [email protected]
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1047)
... 4 more
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for mkba
[email protected]
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1047)
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 MailSend.main(MailSend.java:116)
Please let me know the reason for the same.Unable to relay - This happened because your Company network don't permit relay. Do talk to the network administrator and check with way safe you can send.
I got the same problem, now im using through gmail. -
Hi,
Please take a look at the following source code. It's a simple javamail application to send an Email, got from java.sun.com:
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class SimpleSender {
public static void main (String args[]) throws Exception {
String host = "mail.wishbd.com";
String from = "[email protected]";
String to = "[email protected]";
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject("Hello JavaMail");
message.setText("Welcome to JavaMail");
Transport.send(message);
The code compiles successfully, but when it is run, the following error shows up:
D:\>java SimpleSender
Exception in thread "main" javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
class javax.mail.SendFailedException: 550 not local host yahoo.com, not a gateway
at javax.mail.Transport.send0(Transport.java:218)
at javax.mail.Transport.send(Transport.java:80)
at SimpleSender.main(SimpleSender.java:18)
Now, if the "to" field is changed to (say) [email protected], the application runs and the message is sent succesfully to the address. You can check it for yourself by compiling. I have given here the full source code.
What's wrong? Why is the javax.mail.SendFailedException shown up? Could you please, help?
Thanks,
... M. ChistyLooks like your mail server is set up not to permit relaying, or sending email outside your local domain. See the mail server admin people.
SH -
Class javax.mail.SendFailedException
Hi,
Let me know regarding java mail. I am facing the error as follows,
===============Exception=====================
javax.servlet.ServletException: Sending failed;
nested exception is:
class javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
class javax.mail.SendFailedException: 550 not local host gmail.com, not a gateway
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.sendmail3_jsp._jspService(sendmail3_jsp.java:75)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
================sourcecode============================
<%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %>
<%
Properties props = new Properties();
props.put("mail.smtp.host", "66.34.40.98");
Session s = Session.getInstance(props,null);
MimeMessage message = new MimeMessage(s);
InternetAddress from = new InternetAddress("[email protected]");
message.setFrom(from);
InternetAddress to = new InternetAddress("[email protected]");
message.addRecipient(Message.RecipientType.TO, to);
message.setSubject("Test from JavaMail.");
message.setText("Hello from JavaMail!");
Transport.send(message);
%>
<html>
<p align="center">A Message has been sent.<br>Check your inbox.</p>
<p align="center">Click here to send another!</p>
</html>Is there any rule defined on the mailserver that BPEL is accessing via SMTP? Is it directly checking the address for validation or something?
Can you do a SMTP transaction on the BPEL server for this mail account only?
1) Create a notification process that sends a mail only for this user.
2) open a telnet session from the BPEL server commandline to do a SMTP conference.
http://nl.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol
Maybe you are looking for
-
I have OSX 10.7 Lion. I set up a separate email account for my wife. All of a sudden when she tries to enter and website from email we get the following error message. JavaScript; The notnull validator has already been loaded. From there we can'
-
XML Declaration missing in SOAP message
Hi, We have an interface that calls a webservice to create a Product in a 3rd Party System. Inbound Message : Material IDOC Outbound Message: Product XML for a Create method of a WebService. Outbound Adapter: SOAP Adapter Issue: Product XML is receiv
-
Procedure for IP Address change in MSCS
Hi, I need to change the IP address of SAP server, which is configured with MSCS. Please let me know the procedure for changing IP address in MSCS environment. We are using 2 nodes Active-Passive cluster. Regards, Ranjith
-
For anyone wondering if their Adobe apps will work with Mavericks and how well: http://helpx.adobe.com/x-productkb/global/mac-os-mavericks-compatability.html
-
Rapid Deployment Solution for SAP CRM - Landscape
Hi For the first time we have applied the Rapid Deployment Solution for SAP CRM ITSDO into our new DEV system. The activation of this RDS creates 2 transports (one WORKBENCH, one CUSTOMIZING) I now need to apply the RDS to our QA and PRD systems -