aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes problem sending mail with attachments-getting filenotfound exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "problem sending mail with attachments-getting filenotfound exception" Watch "problem sending mail with attachments-getting filenotfound exception" New topic
Author

problem sending mail with attachments-getting filenotfound exception

jyothi nalam
Greenhorn

Joined: Oct 25, 2006
Posts: 24
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
Ranch Hand

Joined: Aug 27, 2012
Posts: 963
    
  10

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

Joined: Oct 25, 2006
Posts: 24
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
Ranch Hand

Joined: Aug 27, 2012
Posts: 963
    
  10

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

Joined: Oct 25, 2006
Posts: 24
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
Ranch Hand

Joined: Aug 27, 2012
Posts: 963
    
  10

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
Bartender

Joined: Oct 14, 2005
Posts: 18135
    
    8

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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem sending mail with attachments-getting filenotfound exception
 
Similar Threads
SetSubType usage?
Client to server file upload
File attachments using Java Mail API
How to send email with no attachment?
Multiple Attachments for EMail Message