Re: Help Sending Mail

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Until today, there was a very nifty MIME Message Lint tool to check
your email message here:
http://www.apps.ietf.org/msglint.html

The homepage is now the default Apache install page though, and that
URL is 404.

I'm posting it in hopes that somebody knows a good similar tool and/or
that it will come back to life before you read this, or shortly
thereafter.

On Mon, December 10, 2007 10:33 pm, Me2resh Lists wrote:
> Dear All,
>
> i wrote this class below to send Mail. but when i use it. i get the
> sender
> No Body. and from the address of the server, not the From address that
> i
> specify. and the MIME Headers as text in the message itself. and the
> attachment is pasted as binary text also.
> can anyone help please ??
>
> here is the code :
> --------------------------------------------------------------------
> <?php
>
> $Mail = new MainClass();
>
> $Mail->Construct("Ahmed", "me2resh.lists@xxxxxxxxx", "Test Mail",
> "Hello,
> this is my first message");
> $Mail->AddTo("ahmed@xxxxxxxxxxxxxxxxxxxxx", "Ahmed");
> $Mail->AddCc("me2resh@xxxxxxx", "Me2resh");
> $Mail->AddBcc("ahmed@xxxxxxxxxxxxxxxxxxxx", "hola");
> $Mail->AddAttach("favicon.ico");
> $Mail->SendMail();
>
> echo "<pre>";
> print_r($Mail);
>
> /**
>  *
>  */
> class MainClass{
>
>     /**
>      *
>      */
>
>     var $To = "";
>     var $Cc = "";
>     var $Bcc = "";
>     var $From = "";
>     var $Name = "";
>     var $Subject = "";
>     var $Message = "";
>     var $Headers = "";
>
>     function Construct($name, $from, $subject, $message){
>         //construct message
>         if ($name == ""){
>             $name = $from;
>         }
>         $this->Name = $name;
>         $this->From = $from;
>         $this->Subject = $subject;
>         $this->Message = $message;
>     }//end of Construct
>
>
>     function AddTo($email, $name){
>     // add reciepnt to To array
>         if ($name == ""){
>             $name = $email;
>         }
>         if ($this->To == ""){
>             $this->To .= $name.' <'.$email.'>';
>         }else{
>             $this->To .= ",".$name.' <'.$email.'>';
>         }
>     }// end of AddTo
>
>
>     function AddCc($email, $name){
>     // add reciepnt to Cc array
>     if ($name == ""){
>             $name = $email;
>         }
>         if ($this->Cc == ""){
>             $this->Cc .= $name.' <'.$email.'>';
>         }else{
>             $this->Cc .= ",".$name.' <'.$email.'>';
>         }
>     }
>
>
>     function AddBcc($email, $name){
>     // add reciepnt to Bcc array
>     if ($name == ""){
>             $name = $email;
>         }
>         if ($this->Bcc == ""){
>             $this->Bcc .= $name.' <'.$email.'>';
>         }else{
>             $this->Bcc .= ",".$name.' <'.$email.'>';
>         }
>     }
>
>     function AddAttach($attach){
>     //add attach to array
>         //if (is_uploaded_file($attach)) {
>              // Read the file to be attached ('rb' = read binary)
>              $file = fopen($attach,'rb');
>              $data = fread($file,filesize($attach));
>              fclose($file);
>
>             // Generate a boundary string
>             $semi_rand = md5(time());
>             $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
>
>             // Add the headers for a file attachment
>             $this->Headers .= "\nMIME-Version: 1.0\n" .
>                         "Content-Type: multipart/mixed;\n" .
>                         " boundary=\"{$mime_boundary}\"";
>
>             // Add a multipart boundary above the plain message
>             $this->Message = "This is a multi-part message in MIME
> format.\n\n" .
>                        "--{$mime_boundary}\n" .
>                        "Content-Type: text/plain;
> charset=\"iso-8859-1\"\n"
> .
>                        "Content-Transfer-Encoding: 7bit\n\n" .
>                        $this->Message . "\n\n";
>             // Base64 encode the file data
>              $data = chunk_split(base64_encode($data));
>               // Add file attachment to the message
>             $this->Message .= "--{$mime_boundary}\n" .
>                         "Content-Type: {filetype($attach)};\n" .
>                         " name=\"{$attach}\"\n" .
>                         "Content-Disposition: attachment;\n" .
>                         " filename=\"{$attach}\"\n" .
>                         "Content-Transfer-Encoding: base64\n\n" .
>                         $data . "\n\n" .
>                         "--{$mime_boundary}--\n";
>                      //   }// end of if
>
>     }// end of add attach
>
>     function SendMail(){
>         $this->Headers .= "\r\n";
>         $this->Headers .= 'To: '.$this->To."\r\n";
>         $this->Headers .= 'From:
> '.$this->Name.'<'.$this->From.'>'."\r\n";
>         $this->Headers .= 'Cc: '.$this->Cc."\r\n";
>         $this->Headers .= 'Bcc: '.$this->Bcc."\r\n";
>         mail($this->From, $this->Subject, $this->Message,
> $this->Headers);
>     }
> }// end of class
>
>
> ?>
>
>
>
>
>
>
>
> Here is the text in the email :
>
> ----------------------------------------------------------------
>
> MIME-Version: 1.0
> Content-Type: multipart/mixed;
>  boundary="==Multipart_Boundary_xd609c629ba34ecb645a7572abb61eb27x"
> To: Ahmed <ahmed@xxxxxxxxxxxxxxxxxxxxx>
> From: Ahmed<me2resh.lists@xxxxxxxxx>
> Cc: Me2resh <me2resh@xxxxxxx>
> Bcc: hola <ahmed@xxxxxxxxxxxxxxxxxxxx>
>
>
> This is a multi-part message in MIME format.
>
> --==Multipart_Boundary_xd609c629ba34ecb645a7572abb61eb27x
> Content-Type: text/plain; charset="iso-8859-1"
> Content-Transfer-Encoding: 7bit
>
> Hello, this is my first message
>
> --==Multipart_Boundary_xd609c629ba34ecb645a7572abb61eb27x
> Content-Type: {filetype(favicon.ico)};
>  name="favicon.ico"
> Content-Disposition: attachment;
>  filename="favicon.ico"
> Content-Transfer-Encoding: base64
>
> AAABAAEAEBAAAAEAGABoAwAAFgAAACgAAAAQAAAAIAAAAAEAGAAAAAAAAAMAAAAAAAAAAAAAAAAA
> AAAAAAASEhIHBwcHBwcJCQkoKChLS0tZWVlOTk4MDAwHBwcHBwcHBwcHBwcHBwcHBwcmJiYKCgok
> JCSPj4/h4eH+/v7+/v7+/v7+/v4pKSkAAAAAAAAAAAAAAAAAAAAAAAAgICB4eHj5+fn+/v7/////
> ///////+/v7+/v52dnYAAAAAAAAAAAAAAAAAAAAAAAAgICBGRkb9/f3////////+/v709PTPz8/B
> wcG0tLTQ0NDf39+BgYEAAAAAAAAAAAAgICAKCgq2trb+/v7+/v64uLi9vb39/f3+/v7+/v7+/v7+
> /v739/cpKSkAAAAAAAAgICAKCgpRUVH+/v7e3t6VlZX+/v7+/v7////////09PR/f39/f3+RkZEA
> AAAAAAAgICAAAAARERH7+/uurq7n5+f+/v7////////////+/v7+/v61tbXZ2dk8PDwAAAAgICAA
> AAAAAACbm5uFhYX19fX+/v7+/v7U1NS1tbWysrLHx8fBwcGpqal0dHQeHh4iIiIAAAADAwPr6+vU
> 1NRKSkqMjIzs7OyYmJj9/f3+/v7X19csLCxra2vg4ODKyspQUFAAAAACAgLn5+f8/PwPDw83Nze9
> vb2wsLC6urq5ubnFxcXu7u7+/v77+/tYWFggICAAAAAAAAA0NDRhYWEEBAQEBATg4OD+/v7+/v7+
> /v7+/v7+/v7+/v7+/v6Dg4MgICAAAAAAAAAAAAAAAAAAAAAAAACfn5/////////+/v729vaurq5z
> c3N2dnZPT08gICAGBgYAAAAAAAAAAAAAAAAAAAA1NTW8vLypqalra2sWFhYAAAAAAAAAAAAAAAAg
> ICANDQ0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgICAZGRkAAAAA
> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgICA7OzsXFxcXFxcXFxcXFxcX
> FxcXFxcXFxcXFxcXFxcXFxcXFxcXFxcXFxcXFxc1NTUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
>
>
> --==Multipart_Boundary_xd609c629ba34ecb645a7572abb61eb27x--
>
>
>
> please help, any help would be appreciated.
>
> Regards,
> Me2resh
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux