Skip to main content
Participant
March 22, 2022
Question

mail attachments IO-Exception File not found

  • March 22, 2022
  • 2 replies
  • 132 views

Hi,

 

We have CF2018 v2018,0,13,329786 on windows server 2016.

Our problem is random messages with attachments gets undelivered from CF to SMTP relay. The problem is very random and seconds if not less, other messages sometimes with attachments get sent right after this error. 

 

mail.log:

"Error","scheduler-5","03/08/22","10:55:59","","javax.mail.MessagingException: IOException while sending message; nested exception is: java.io.FileNotFoundException: ..... 26534A53-C408-A386-C3308E8CD0C43D73.pdf (The system cannot find the file specified)"

 

mailsent.log -- shows that it was moved to the undelivr folder.

 

exception.log: -- 

javax.mail.MessagingException: IOException while sending message;
nested exception is:
java.io.FileNotFoundException: .......26534A53-C408-A386-C3308E8CD0C43D73.pdf (The system cannot find the file specified)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1365)
at coldfusion.mail.MailSpooler.sendMessage(MailSpooler.java:1541)
at coldfusion.mail.MailSpooler.deliver(MailSpooler.java:1354)
at coldfusion.mail.MailSpooler.sendMail(MailSpooler.java:1251)
at coldfusion.mail.MailSpooler.deliverStandard(MailSpooler.java:1690)
at coldfusion.mail.MailSpooler.run(MailSpooler.java:1655)
at coldfusion.scheduling.ThreadPool.run(ThreadPool.java:260)
at coldfusion.scheduling.WorkerThread.run(WorkerThread.java:71)

 

My question is, does Coldfusion control the time frame and location of where the temporary files are held before it gets sent to SMTP, and also can this be modified and if so where in CFadmin?

 

Thanks

Kurtis

This topic has been closed for replies.

2 replies

BKBK
Community Expert
Community Expert
March 23, 2022

ColdFusion says the mailer could not find the PDF. There is a high chance ColdFusion is right. So, have you confirmed the PDF already existed when the mail was sent? 

 

In any case, this error suggests an improvement to your code. Add validation code to verify whether the attached file exists:

<cfif fileExists(full_path_of_file_to_be_attached)>
<!--- Code to send the e-mail containing the attachment --->
<cfelse>
<!--- No mail sent. Error-handling: file to be attached does not exist --->
</cfif>
Charlie Arehart
Community Expert
Community Expert
March 23, 2022

Kurtis, this is indeed an interesting problem. But I think you may want to look at things differently: you wonder if it's a problem with the mail delivery, and a setting about any "time frame and location of where the temporary files are held before it gets sent to Smtp".

 

I would focus instead first on what process creates the attachment. I see it's a pdf. That could be created or put in that temp location by any number of cf tags or functions.  So which are you using? That may help us recommend options related to that.

 

For instance, some tags/functions implicitly write to the cf temp folder (set in config files at startup, and rarely needing to be changed) while others can be told to put a file somewhere. In the case of temp folder use, usually such builtin cf processes will delete the file at the end of the request. (I'm unaware of any settable delay.) Whereas, if you instead put the file someplace then you could (and would have to) control deleting it.

 

But then as you may know, the cf mail delivery mechanism is set by default (in the cf admin mail page) to check for mail to be delivered every 15 seconds. So when you create an email with cfmail, that's put in cf's mail/spool folder, and it will remain there from 0-15 seconds (by default) before being delivered. If a cf tag or function put the file in a temp folder and deleted it at end of request, it would indeed be gone by the time the mail was sent. 

 

One thought (which feels wrong) might be to put in a call to sleep() for 15 secs after the cfmail, to ensure the mail would have been delivered before any temp file is deleted at the end of the request...but if this is in a page visited by people, you don't want to keep them waiting. (And yes, one can foist the process off on a cfthread, but it would need to do BOTH the pdf file creation--if that's what's being put in a temp file/folder--AND then the cfmail, then the sleep.) 

 

But maybe this not needed. One last thought I wondered:  when one names an attachment to cfmail, does that perhaps itself make a copy of the file to a temp folder that is managed by the mail process? I'm not aware of that, and perhaps it's what your were wondering about. This may or may not be the issue (or even how things work), which is why I opened with all the rest above.

 

I'm writing this on my phone, and may not get to test anything about it today, but perhaps you can, or maybe someone else may chime in with more.

 

As I said, it's an interesting problem and one I've not seen presented before. That may mean there's something unusual about your processes or setup that is making you subject to this issue, rather uniquely. Let's see what others may say, or that you may find. 

 

Hope this may have helped, if just a bit. 

/Charlie (troubleshooter, carehart. org)