E Mail Sending problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simulator
Forum Newbie
Posts: 1
Joined: Fri Oct 12, 2007 1:43 am

E Mail Sending problem

Post by simulator »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi all 


I am getting one weird problem while sending mail ...

when i use Content-Type: text/plain; then mail goes fine 

but when i use Content-Type: text/html;  still mail goes fine but the whole body goes as attachment...

I dont want the body postion to go as attachment....

Please help///  

Code is :

Code: Select all

private function BuildMail()
    {
        $this->headers["Content-Type"] = "$this->format; charset=$this->charset";
        $this->headers["Content-Transfer-Encoding"] = $this->encoding;
        $this->SayHELO();
        $this->mail .= "MAIL FROM: $this->sender\r\n";
        $this->SetRecipients();
        $this->mail .= "DATA\r\n";
        $this->mail .= "Subject: $this->subject\r\n";
        $this->mail .= "From: $this->sender\r\n";
        $arr = implode(", ", $this->to);
        $this->mail .= "To: $arr\r\n";
        if(count($this->cc) > 0){
            $arr = implode(", ", $this->cc);
            $this->mail .= "Cc: $arr\r\n";
        }
        if(count($this->Bcc) > 0){
            $arr = implode(", ", $this->Bcc);
            $this->mail .= "BCc: $arr\r\n";
        }
        foreach($this->headers as $hdr => $val){
            $this->mail .= "$hdr: $val\r\n";
        }
        $this->mail .= "$this->data";
        $this->mail .= "\r\n.\r\n";
    }
    /**
     * Sends the email once the properties are set
     */
    function Send()
    {
            $this->BuildMail();
        if($this->Open()){
           $ret = "Connection  opened to server " . $this->smtp_server . " on port " . $this->port;
                        $this->mail = $this->mail."$ret";
          
            if(fwrite($this->smtp, $this->mail)){
                fwrite($this->smtp, "QUIT\r\n");
                        sleep(1);
                $ret = fgets($this->smtp);
                        $this->mail = $this->mail."$ret";
            } else{
                $ret = "500: Could not send the email (perhaps a malformed mail?)";
                        
                }
            $this->Close();
        } else{
            $ret = "500: Could not open a connection to server " . $this->smtp_server . " on port [1]" . $this->port;
      
                
            }
            $this->mail = $this->mail."$ret";
            $this->Log();
        return $ret;
    }

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
jeffery
Forum Contributor
Posts: 105
Joined: Mon Apr 03, 2006 3:13 am
Location: Melbourne, Australia
Contact:

Post by jeffery »

use something like swift mailer : viewforum.php?f=52 makes your life easier
Post Reply