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

  • SEARCH
  • Home
  • 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 6562715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:44:30+00:00 2026-05-25T13:44:30+00:00

I made a PHP script yesterday which send an email with a PDF as

  • 0

I made a PHP script yesterday which send an email with a PDF as an attachment.

When I make a crontab with this script shedulded, I recieve the email but not the attachment.
When I launch the script manually, I have the email and the attachment.

Here is the PHP code of the sendMail function :

function sendMail()
{
            $corpse = file_get_contents(dirname(__FILE__).'/output/output.tpl');
            $mail = new PHPMailer;
            $mail->isMail();
            $mail->IsHTML(true);
            $mail->From='SenderMailAddress';
            $mail->FromName='SenderName';
            $mail->AddAddress('MyEmail');
            $date = date("Ymd", time());
            $yesterday = date("Ymd", strtotime("-1 day"));
            if ($this->type == cur)
                    $pj = "/opt/birt/ReportEngine/output/bookingperiod_".$date.".pdf";
            else
                    $pj = "/opt/birt/ReportEngine/output/bookingperiod_".$yesterday.".pdf";
            echo $pj;
            $mail->AddAttachment($pj);
            $mail->AddReplyTo('NoReplyAddress');
            $mail->Subject='SubjectOfTheMail';
            $mail->Body=$corpse;
            if (!$mail->Send())
                    echo "Error Sending: ".$mail->ErrorInfo;
            unset($mail);
}

The script that I put as a crontask :

TODAY=`date "+%Y-%m-%d"`

export BIRT_HOME=/opt/birt
echo $TODAY

cd /opt/birt/ReportEngine
php GenPeriod.php PDF $TODAY /*first generation of a PDF file which will be the attachment for the PHP script*/

cd MY_PATH_TO_PHPSCRIPT_FOLDER
php Launche.php cur

Do someone already encounter the same type of problem ?

How can you solve it ?

Thanks 😉

  • 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-05-25T13:44:31+00:00Added an answer on May 25, 2026 at 1:44 pm

    Try something like this and continue with verifing file permissions.

    function sendMail()
    {
            $corpse = file_get_contents(dirname(__FILE__).'/output/output.tpl');
            $mail = new PHPMailer;
            $mail->isMail();
            $mail->IsHTML(true);
            $mail->From='SenderMailAddress';
            $mail->FromName='SenderName';
            $mail->AddAddress('MyEmail');
            $date = date("Ymd", time());
            $yesterday = date("Ymd", strtotime("-1 day"));
            if ($this->type == cur)
                    $pj = "/opt/birt/ReportEngine/output/bookingperiod_".$date.".pdf";
            else
                    $pj = "/opt/birt/ReportEngine/output/bookingperiod_".$yesterday.".pdf";
            //echo $pj;
    
            $mail->Subject = (is_readable($pj)) ? 'The file is readable' : 'The file is NOT readable'; // DEBUG
    
            $mail->AddAttachment($pj);
            $mail->AddReplyTo('NoReplyAddress');
            //$mail->Subject='SubjectOfTheMail';
            $mail->Body=$corpse;
            if (!$mail->Send())
                    echo "Error Sending: ".$mail->ErrorInfo;
            unset($mail);
    }
    

    http://www.php.net/manual/en/function.is-readable.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i made a php script as below ran it and ouput is Record Added
Ok, so I have this PHP script that runs in a nice little infinite
I had made some questions regarding PHP-GTK (there are only 4 php-gtk tagged questions
I have a website built in PHP 4 with a framework made by hand
So I'm going to be working on a home made blog system in PHP
I just install apache,php and mysql rpm on AIX5.2, but I can't see the
I've just made some fixes to a web site that uses the Form2Mail PHP
I'm running php script updreading.php locally on my laptop (with Mac OS X 10.6.7).
I've got an upload button I've made in Flash that links to a PHP
In a folder say /folderX/ there are 4 .txt files. A php script currently

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.