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 8552599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:27:31+00:00 2026-06-11T14:27:31+00:00

can any one help me in understanding what happening in my codes? whether its

  • 0

can any one help me in understanding what happening in my codes? whether its a error in programming or is it due to php engine is malfuctioning?
following are the code of a class which I am making to send emails very easly..
What I am trying to achieve :- I have defined functions for performing every task needend to send a mail from a simple text to a advance mail with multipart email with plain text, html formated and with attachment.

/*----------------------------------------------------------------------------------
   this function will take care of setting the mail depending users input what            he enters the message will be set up
 ----------------------------------------------------------------------------------*/
    public function set_mail_message($value)
{
$temp_message="";


// ----- detecting whether message submitted has html elements..]

if(strlen($value) != strlen(strip_tags($value)))
    {
    //...... message contains HTMLelements, so content type shud be 
    //....HTML type but for the compatiblity with older email clients
    //....we will set it to the both first html then plain text type..

    $temp_message.="This is a multipart message in MIME format";
    $temp_message.= "--".$this->boundary."\n";

    $temp_message.= "Content-type:text/html; charset=\"iso-8859-1\"\n";
    $temp_message.= "Content-Transfer-Encoding:7bit \n\n";

    $temp_message.= $value."\n";
    $temp_message.= "-- $this -> boundary \n";


//----------these codes from here-------------------------------

    $temp_message.= "Content-type:text/plain; charset=\"iso-8859-1\"\n";
    $temp_message.= "Content-Transfer-Encoding:7bit \n\n";
    $temp_message.= strip_tags($value)."\n";

 //--------------- upto HERE ARE OK................

//************ attach the attachment  prepared by function**********************/
        if($this->attachment_status == TRUE)
        {
        $temp_message.= "--".$this -> boundary."\n";

        $temp_message.= "Content-type: " . $Attachment_MIME_Type. "; \n name=\"$attachment_name\"\n";
        $temp_message.= "Content-Transfer_Encoding: base64\n\n";
        $temp_message.= $attachment_data."\n\n\";
        }       

    //----finishing the message configuration..........

    }
    else
    {
    // - ----content type is only PLAIN/TEXT---with or without attachmet-----
 //----------------BUT SAME CODES HERE FROM HERE :------------
    $temp_message.= '--'.$this->boundary.'\n';
    $temp_message.= 'Content-type:text/plain; charset=\"iso-8859-1\"\n'; 
    $temp_message.= 'Content-Transfer-Encoding:7bit \n\n';
    $temp_message.= $value.'\n';

//------------------UPTO HERE ARE SAME AS PREVIOUS BUT GIVING ERROR----------


//-------put attachment if set up by calling the set_mail_attachment function-------/
        if($this->attachment_status == TRUE)
        {
        $temp_message.= '--'.$this -> boundary.'\n';

        $temp_message.= 'Content-type: ' . $Attachment_MIME_Type. '; \n name=\'$attachment_name\'\n';
        $temp_message.= 'Content-Transfer_Encoding: base64\n\n';
        $temp_message.= $attachment_data.'\n\n';
        } 
        //----attachment has been put now close the boundary---

    $temp_message.= '--'.$this ->boundary.'--\n';
    }
$this ->message = $temp_message;

}



/*this function will take care of attchment and if this function is called and a 
atachment a selected only then the attachment part in set_mail_message() will be
defined*/   


   public function set_mail_attachment($value)
{

$attachment_data;

if(!empty($value) && file_exists($value))
    {
    $this -> attachment_status = TRUE;
//--here file type and file Name must be found somehow
//-- so that we can define them when seinding mail -------

    $Attachment_MIME_Type = 'image/jpeg';
    $attachment_name = 'attachment.jpeg';




    //------file must be read in binary format-------
    $file_resource = fopen($value,'rb')or die ('Error! There is an error in attachment');
    $attachment_data = fread($file_resource,filesize($value));
    fclose($file_resource);
    }

}

PROBLEM IS : as commented in code at two points the code are same but in second part same code generates parse error,to solve it i need to change dauble quote with single quotes,but doing this when i am calling the these both function and if i pass the argument in as Double quoted string then same parse error i get and if I use single quotes instead of double then I got another error: UNexpected $end..

I traversed my code many time tried to find soltions on net too. but NOT getting success in debugging this..
please if you can test the code please test it yourself too,so that problem can be traced.

Please help me..
my thanks in a

  • 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-11T14:27:32+00:00Added an answer on June 11, 2026 at 2:27 pm

    did you notice how in the question, the color formatting of your code block changes to red after this line?: $temp_message.= $attachment_data."\n\n\";

    thats because \" is an escaped character, and its not actually closing your string.

    it should be: $temp_message.= $attachment_data."\n\n";

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

Sidebar

Related Questions

Can any one help in transforming my xml though XSLT. I am new to
Can any one help me, i already checked resizing demo but this work through
can any one help me with code that subtract 1 from a digit stored
can any one help me in creating a regular expression for password validation. The
Can any one help me how to sort rows by relevance for the following
Can Any one help me reading this XML and Looping through <MedicationDispensed> I get
Hi Can any one help me how i can use NSAttributedStrings with UISearchBar. actually
I am new in Pocket PC and Smart phone. so can any one help
I want to bound JVM with a fixed memory limit. Can any one help
Can any one recommend resources for adding SNMP support for my device? my understanding

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.