ActionMailer attaching generated files

I have a script that is running as a runner script, its job is to find reports that have recently been published and send emails to the users notifying them of the reports. The reports are available online, but are also available via a generated PDF which the users can see by tacking on .pdf to the end of their URL.

I want to attach the pdf to the email that the runner script sends out. The problem I'm facing is that the runner script cannot 'find' the pdf and I dont know why - here are my guesses:

1. You have to authenticate to see the pdf reports (which is true, but im not sure if the action mailer needs to authenticate and cannot do that?)

2. I am only able to use the path of the pdf, not the full url. The pdf is available through a url obviously, but the url contains a subdomain - but because this is a runner script that runs behind the scenes, it has no context and therefor cannot determine the URL.

I'm not sure which one is causing the failure, anyone have any ideas?

I have a script that is running as a runner script, its job is to find reports that have recently been published and send emails to the users notifying them of the reports. The reports are available online, but are also available via a generated PDF which the users can see by tacking on .pdf to the end of their URL.

I want to attach the pdf to the email that the runner script sends out. The problem I'm facing is that the runner script cannot 'find' the pdf and I dont know why - here are my guesses:

1. You have to authenticate to see the pdf reports (which is true, but im not sure if the action mailer needs to authenticate and cannot do that?)

2. I am only able to use the path of the pdf, not the full url. The pdf is available through a url obviously, but the url contains a subdomain - but because this is a runner script that runs behind the scenes, it has no context and therefor cannot determine the URL.

Are you trying to attach the pdf by giving actionmailer the path from the url that generates the pdf (ie /some_controller/some_id/ generate.pdf or similar) ? That sounds very roundabout, and just out of the box you need to give actionmailer a path to an actual file on disk. You'd be far better off invoking the actual pdf generation code from your script.

Fred

Fred

Yes I am attempting to basically give it a URL, I'm not sure how else to do it..

Ryan Abbott wrote:

Yes I am attempting to basically give it a URL, I'm not sure how else to do it..

On Feb 1, 3:27�am, Frederick Cheung <frederick.che...@gmail.com>

Why are you mailing the PDF files anyway? The URL should be sufficient.

Best,

Yes I am attempting to basically give it a URL, I'm not sure how else to do it..

Well you've got code to generate a pdf document, use that to save it as a temporary file and attach that temporary file to the email.

Fred