Autor Zpráva
Anonymní
Profil *
$priloha="vseobecne_podminky.doc";
$fd=fopen($priloha, "r");
$data=fread($fd, filesize($priloha));
fclose($fd);

include_once("../classes/class.mime_mail.php");
$mime_mail = new Mime_mail();

$to="neco@nekam.com";

$mime_mail->from = "nekoho.cz <info@email.cz>";
$mime_mail->to = $to;
$mime_mail->subject = "Potvrzení přihlášky";
$message = "textik";
$message.= " textik pokracovani";
$mime_mail->body=$message;
$mime_mail->add_attachment($data, 'vseobecne_podminky.doc', 'application/msword');
$mime_mail->send();

Vytvori se sice priloha, ale prazdna... navic ani telo zpravy nic neobsahuje. Resili jste toto uz nekdo? Mail se odesle...
Diky
Martin
Profil
možná by to chtělo vidět i tu třídu.
Anonymní
Profil *
hmm trida je standartni..... (a nebo neznate neco jineho na odesilani mailu s prilohou?)


class Mime_mail
{
//================================================================//

// Attributes

//================================================================//
var $parts;
var $to;
var $from;
var $headers;
var $subject;
var $body;

function Mime_mail()
{
$this->parts = array();
$this->to = "";
$this->from = "";
$this->subject = "";
$this->body = "";
$this->headers = "";
}

function add_attachment($message, $name="", $ctype="application/octet-stream", $encode='', $charset='')
{
$this->parts[] = array("ctype" => $ctype, "message" => $message, "encode" => $encode, "name" => $name, "charset" => $charset);
}

function build_message($part)
{
$message = $part["message"];
if($part['encode']=='' || $part['encode']=="base64") {
$message = chunk_split(base64_encode($message));
$encoding = "base64";
}
return "Content-Type: ".$part["ctype"].($part["charset"]?"; charset=\"{$part['charset']}\"":"").($part["name"]? "; name = \"".$part[ "name"]."\"; filename = \"".$part[ "name"]."\"" : "")."\nContent-Transfer-Encoding: $encoding\n\n$message\n";
}

function build_multipart()
{
$boundary = "b".md5(uniqid(time()));
$multipart = "Content-Type: multipart/mixed; boundary = $boundary\n\nThis is a MIME encoded message.\n\n--$boundary";
for($i=sizeof($this->parts)-1; $i>=0; $i--) {
$multipart .= "\n".$this->build_message($this->parts[$i])."--$boundary";
}
return $multipart.= "--\n";
}

function get_mail($complete=true, $body_type='text/plain')
{
$mime = "";
if(!empty($this->from))
$mime .= "From: ".$this->from."\n";
if(!empty($this->headers))
$mime .= $this->headers. "\n";
if($complete) {
if(!empty($this->to)) {
$mime .= "To: $this->to\n";
}
if(!empty($this->subject)) {
$mime .= "Subject: $this->subject\n";
}
}
if(!empty($this->body))
$this->add_attachment($this->body, "", $body_type, '', 'windows-1250');
$mime .= "MIME-Version: 1.0\n".$this->build_multipart();
return $mime;
}

function send($body_type='text/plain')
{
$mime = $this->get_mail(false, $body_type);
//echo "<br />{$mime}<br />";
if(@mail($this->to, $this->subject, "", $mime))
return true;
else
return false;
}
// end of class

};
Grizzly
Profil *
Mně funguje normálně tento příkaz:

$mime->addAttachment($file, 'text/html');

..není nutné otevírat ten soubor ručně...
mic
Profil *
Používám to samé, al mám problém. Chci přiložit PDF soubor zhruba 60kb ale po doručení zprávy má příloha 21 b a obsahuje cestu k souboru přílohy ....
Toto téma je uzamčeno. Odpověď nelze zaslat.

0