• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem sending mail with attachments-getting filenotfound exception

 
jyothi nalam
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using JavaMail API and trying to attach pdf file which is on a server. I am able to retrieve the file from the browser.



Please help me resolve this.
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One cannot create a File object from a URL. You need to open a URLConnection to access the content of a URL.
 
jyothi nalam
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was about to give that a try before posting my issue before. But your reply confirmed to go ahead. thanks a lot.
I have another problem now. Now i am successfully able to send the mail with attachment.

But the problem is if there is an invalid address, I am not able to catch it. mail is sent to valid addresses but i am receiving a mail directly from system administrator about the failure to send mail to invalid addresses.
And I do not see any exception in my log


Please help me solve this.

Thanks in advance
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Email is a "fire and forget" protocol. If you are able to open a connection to the mail server then you will only get an error if the syntax of the email address is faulty. If the syntax is correct but the address does not exist then you will not know until later when the server sends you an non-delivery message. This is nothing you can do about this. For security reasons, some servers never send a non-delivery message.
 
jyothi nalam
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for your reply.

I was previously using commons apache mail to send the mail. If there is any invalid address, the entire send is failing for even valid address. Is javamail api the only option for partial sends or can we tweak the commons mail settings. I had to rewrite my entire application to enable partial sends.

Thank You.
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jyothi nalam wrote:I was previously using commons apache mail to send the mail. If there is any invalid address, the entire send is failing for even valid address.


I know little about Apache mail but this cannot be the whole story. An invalid syntax of an email address is detectable by the client software. A domain name that does not exist is detectable by the client server. But if the recipient at some valid domain does not exist then it is only immediately detectable of the outgoing server (SMTP ?) rejects it immediately; it is my experience that this does not normally happen since the server will place the emails in a queue and then return.

 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, unfortunately we only have that vague term "invalid e-mail address" to work with. So naturally people don't understand what other people are talking about.

So how about some examples of what you consider to be an "invalid" address, jyothi?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic