Notice: query (INSERT INTO lemat_stats_browser (day,browser,ilosc,internal) VALUES ('2024-11-21','Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)',1,'2')) failed at /home/lemat/lemat.priv.pl/stats.php:151: Array ( [0] => 22001 [1] => 1406 [2] => Data too long for column 'browser' at row 1 ) in /home/lemat/lemat.priv.pl/panel_adm/dbclass.inc.php on line 15

Warning: Cannot modify header information - headers already sent by (output started at /home/lemat/lemat.priv.pl/panel_adm/dbclass.inc.php:15) in /home/lemat/lemat.priv.pl/stats.php on line 174
Wysyłanie maila w formacie HTML - Lemat, strona prywatna
Lemat, strona prywatna

Wysyłanie maila w formacie HTML

mailashtml() wysyła tylko HTML, mailasmultipart() wysyła i plain-textem i w HTML, usiłując przez strip_tags() wygenerować sobie plain-text. To oczywiście nie zawsze wychodzi.

define('SERWIS_NAME','Strona');
define('SERWIS_EMAIL_ADDRESS','nobody@egzample.tld');
define('SERWIS_EMAIL_ADDRESS_MAIL_HEADER_FROM','"'.SERWIS_NAME.'" <'.SERWIS_EMAIL_ADDRESS.'>');

$charset='iso-8859-2';

function mailashtml($email,$skrot,$message) {
global $charset;
$NL="\n";
$naglowki='From: '.SERWIS_EMAIL_ADDRESS_MAIL_HEADER_FROM.$NL.
'Reply-To: '.SERWIS_EMAIL_ADDRESS.$NL.
'MIME-Version: 1.0'.$NL.
'Content-Type: text/html; charset="'.$charset.'"'.$NL.
'Content-Transfer-Encoding: 8bit';

$skrot = '=?'.$charset.'?B?'.base64_encode($skrot).'?=';
mail($email,$skrot,$message,$naglowki);
}

function mailasmultipart($email,$skrot,$message) {
global $charset;
$NL="\n";

$mime_boundary = '----=_'.uniqid('');
$naglowki='From: '.SERWIS_EMAIL_ADDRESS_MAIL_HEADER_FROM.$NL.
'Reply-To: '.SERWIS_EMAIL_ADDRESS.$NL.
'MIME-Version: 1.0'.$NL.
'Content-Type: multipart/alternative; boundary="'.$mime_boundary.'"';

$skrot = '=?'.$charset.'?B?'.base64_encode($skrot).'?=';
$plain=strip_tags(str_replace(array('<br>','&amp;','</p>','<p>'),array($NL,'&',$NL,''),$message));

$body='This is a multi-part message in MIME format.'.$NL.$NL.
'--'.$mime_boundary.$NL.
'Content-Type: text/plain; charset="'.$charset.'"'.$NL.
'Content-Transfer-Encoding: 8bit'.$NL.$NL.
$plain.$NL.$NL.
'--'.$mime_boundary.$NL.
'Content-Type: text/html; charset="'.$charset.'"'.$NL.
'Content-Transfer-Encoding: 8bit'.$NL.$NL.
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv="Content-Type content=text/html; charset='.$charset.'">
<style>
BODY {
font-family: Verdana;
font-size: 12px;
}
</style>
</HEAD>
<BODY>'.
$message.
'</BODY></HTML>'.$NL.$NL.
'--'.$mime_boundary.'--';

mail($email,$skrot,$body,$naglowki);
}

Data utworzenia : 2008-01-07

Skomentuj ten tekst

Protected by spf
[Nospam-PL.NET]
Seti@Home
www.php.net
© Lemat 2004 - ∞