I am attempting to send a file stored in Amazon S3...
# lucee
i
I am attempting to send a file stored in Amazon S3 as an email attachment using cfmail in Lucee 5.3.8.206. The emails are not being sent and when I check the tasks in the lucee admin it is reporting that the file does not exist. Am I wrong in assuming that adding a file with a path of s3:///someBucket/somefile as an attachment should work? I have checked that the file does exist using fileexists() so it is definitely there and the mail param tag itself doesn't complain about the file not existing either. If I am trying to do something that can't be done then I can work around it - just wanted to check if anyone had any insight before doing so.
e
it depends on the permissions and how the service of lucee has access to the file. Usually comes down to a permissions issue. There are easier ways on any os to mount the S3 bucket as a native file system and then manipulate the files accordingly.
i
I did initially think about permissions but from the perspective of my app it's definitely not a permissions issue. The file is written to S3 by the application as part of the user generating the email (they upload a file which preparing a bulk email to send). The next step in the process is the app actually sending the email and to do so it uses cfmailparam to attach the file it just uploaded to S3. I have confirmed that the file is readable by the app testing fileread('s3:///myfilelocation) so it's not a permissions issue. Unless of course by the time Lucee tries to actually send the email it is not in the context of my app any more - in which case it won't be able to access the file on S3. I guess that's really my question. Does cfmailparam accept an S3 file path as a valid location for a file? It does not error in the app itself so I assumed yes. But then when Lucee tries to send the email it cannot because it can't see the file.
g
I think it has to do with the fact that the mail is sent by java (underlying) and Java itself does not know how to deal with S3 mapped files.
e
To check if its permissions, run as the underlying java server service and attempt to manually obtain the file. In Linux it's SUDO in Windows there is RUNAS. As for the performance side, I can say there are major performance gains to be had using OS operations to mount S3 buckets as file systems. As for your code, instead of using s3/bucketname/file I would use cfcurl or cfhttp and get the file via https://s3.yhourRegion.amazon-aws.com/yourBucketName/file and temporarily copy it to a temp filename/location then email it.
i
Thanks both! That's pretty much where I have go to in my thinking. I'm glad I'm not missing anything.