malcomm_online/mail_class.php

105 lines
3.3 KiB
PHP
Raw Blame History

<?php
$connect = mysql_connect("sql.atm.home.pl","atm3","alan87")
or die ("Nie mozna polaczyc sie z serwerem");
$db = mysql_select_db("atm3", $connect)
or die ("Nie mozna wybrac nbazy danych");
$query = "select b.nazwa,a.id_rap,a.nrzlecenia,a.ulica,a.miejscowosc,a.nrseryjny,a.typ,a.data,b.nazwa from raporty a,raporty_pliki b where a.id_rap=b.id_rap and a.wyslano='0' and a.plik='1'";
$wynnik = mysql_query($query) or die(mysql_error());
while($w=mysql_fetch_array($wynnik))
{
$nrzlecenia = $w[nrzlecenia];
$ulica = $w[ulica];
$miejscowosc = $w[miejscowosc];
$nrseryjny = $w[nrseryjny];
$typ = $w[typ];
$data = $w[data];
$id = $w[id_rap];
$plik = $w[nazwa];
echo $w[nazwa];
class eMail {
var $to;
var $subject;
var $content;
var $headers;
var $marker;
var $type;
var $xMailer = "iGol Mail";
function eMail($type = "1", $from = "online@malcomm.pl", $replyto = "online@malcomm.pl")
{
$this->type = $type;
$this->headers .= "From: " . $from . "\n";
$this->headers .= "Reply-to: " . $replyto . "\n";
$this->headers .= "X-Mailer: " . $this->xMailer . "\n";
$this->headers .= "MIME-Version: 1.0\n";
if ($type == 1) { // text/plain
$this->headers .= "Content-Type: text/plain; charset=iso-8859-2\n";
} else {
srand((double)microtime() * 1000000);
$this->marker = md5(uniqid(rand()));
$this->headers .= "Content-Type: multipart/mixed;\n";
$this->headers .= "\tboundary=\"___" . $this->marker . "==\"\n\n";
$this->content = "--___" . $this->marker . "==\n";
$this->content .= "Content-Type: text/plain; charset=\"iso-8859-2\"\n";
$this->content .= "Content-Transfer-Encoding: 8bit\n\n";
}
}
function eMailAttachment($mimeType, $fileName, $data)
{
if ($this->type != 1) {
$this->content .= "\n\n--___" . $this->marker . "==\n";
$this->content .= "Content-Type: " . $mimeType . "; name=\"" . $fileName . "\"\n";
$this->content .= "Content-Transfer-Encoding: base64\n";
$this->content .= "Content-Disposition: attachment; filename=\"" . $fileName . "\"\n\n";
$this->content .= chunk_split(base64_encode($data));
}
}
function eMailSend($to)
{
if ($this->type != 1) {
$this->content .= "--___" . $this->marker . "==--\n\n"; // close marker
}
mail ($to, $this->subject, $this->content, $this->headers);
}
function eMailContent($subject, $content)
{
$this->subject = $subject;
$this->content .= $content;
}
}
$handle = fopen ("logo.jpg", "r");
$logo = fread($handle, filesize("logo.jpg"));
fclose($handle);
$tresc = 'Protok<6F><6B> wykonania us<75>ugi:
Nr Zlecenia : '.$nrzlecenia.'
Data : '.$data.'
Ulica : '.$ulica.'
Miejscowo<EFBFBD><EFBFBD> : '.$miejscowosc.'
Nr seryjny : '.$nrseryjny.'
Typ : '.$typ.'
WIADOMO<EFBFBD><EFBFBD> GENEROWANA AUTOMATYCZNIE - PROSIMY NA NI<4E> NIE ODPOWIADA<44>
System OnLine
MalComm
';
$wysylka = new eMail(2); // zwroc uwage na ustawienie typu 2
$wysylka->eMailContent('Protok<6F><6B> wykonania us<75>ugi - nr zlecenia '.$nrzlecenia.'', $tresc);
//$wysylka->eMailAttachment('text/plain', 'mail.txt', 'Zawarto<74><6F> testowa');
$wysylka->eMailAttachment('image/gif', 'protokol.jpg', $logo);
$wysylka->eMailSend('jakub.parlinski@malcomm.pl');
}
?>