Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9115311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:24:03+00:00 2026-06-17T04:24:03+00:00

I am building a script that imap’s into a google mailbox, gets a message,

  • 0

I am building a script that imap’s into a google mailbox, gets a message, and extracts a link from the body. The link, when opened via php, starts a download process of a PDF file from an external source.

Here is what I need to do:

  1. Programmatically open the link which initiates a download
  2. Download the PDF, bypassing any dialog boxes obviously
  3. Store the PDF file to a local folder on the web server

I have been successful up to the point where I can initiate the download process and download the file. However, every attempt at opening the PDF finds the file to be corrupted and I can’t figure out why. Here’s what I’m trying now. The following is based on similar topics.

    $filename =  http://cckk.ca/KE645R26/geico.com_SEO_Domain_Dashboard_20121101_00.pdf

    header('Content-Description: File Transfer');
    header('Content-Type: application/pdf');
    header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($filename));
    ob_clean();
    flush();
    readfile($filename);
    exit;

I am thinking that maybe there’s an issue with the filename I’m passing?

Note: This script will be setup as a CRON task that is run on the server every few seconds, in order to constantly fetch from OUR own mailbox, so this is not going to have any type of user interaction or be a security risk to a user.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:24:05+00:00Added an answer on June 17, 2026 at 4:24 am

    Try:

    $filename = 'http://cckk.ca/KE645R26/geico.com_SEO_Domain_Dashboard_20121101_00.pdf';
    
    file_put_contents(
        '/your/server/path/folder/' . basename($filename), // where to save file
        file_get_contents($filename)
    );
    
    exit;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read the tutorial, https://developers.google.com/apps-script/articles/building-sites-app-part2 that uses spreadsheet service in Google sites. The code
I'm building a little script that will connect to an IMAP account and grab
I'm building a large import script that uses functionality from a separate code base
I m building a mail parser script that will fetch content from a mail
I am building a script that's powered by google maps where user chooses the
I'm building a PHP script that sends an email to people on their birthdays.
A php script is building the following (very complicated script that is too long
I've got a script that is capable of building up a longish transaction of
I'm currently building my own login script and have noticed that most append the
we are building a PHP script that we need at work to create reports

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.