/ Forside / Teknologi / Udvikling / PHP / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
PHP
#NavnPoint
rfh 3959
natmaden 3372
poul_from 3310
funbreak 2700
stone47 2230
Jin2k 1960
Angband 1743
Bjerner 1249
refi 1185
10  Interkril.. 1146
html mail, som kun virker hos nogle modtag~
Fra : John Kjoller


Dato : 23-06-05 11:55

Jeg har lavet et nyhedsbrev, - hvor man indtaster teksten som skal stå i
brevet, og markerer teksten, hvis den skal tages med i nyhedsbrevet - og man
gemmer et billede som skal vises sammen med nyhedsbrevet.

Det fungerer tilsyneladende. Næsten.

Bortset fra at en af mine bekendte ikke modtager nyhedsbrevet korrekt. Hun
får en mail, uden html. (kun selve teksten fra brevet)
Hun modtager fint html mails, hvis det f.eks er brevpapir fra Outlook.

Jeg selv modtager html nyhedsbrevet, helt korrekt. Og det gør et par andre
bekendte også.

Herunder paster jeg koden, som afsender brevet (I kan ikke se teksten, da
det jo er variabler hentet fra indtastnings felterne)

Kan nogen her mon gennemskue, hvorfor nogle modtagere ikke modtager mailen
korrekt?
Sig til hvis I har brug for mere info, eller lign.

Pfh tak
KH
John


Kode:

<?php

$hentinfo = mysql_query("SELECT * FROM nyhedsbrev") or die (mysql_error());
$info = mysql_fetch_array($hentinfo);

if ($info[medtag1] == "checked") { $billede1=$info[billede1]; } else
{$billede1="";}
if ($info[medtag2] == "checked") { $billede2=$info[billede2]; } else
{$billede2="";}

$toptekst=$info[toptekst];
$nyhed1=$info[nyhed1];
$nyhed2=$info[nyhed2];
$overskrift1=$info[overskrift1];
$overskrift2=$info[overskrift2];
$medtag1=$info[medtag1];
$medtag2=$info[medtag2];
$subject="Nyhedsbrev fra CSB Island Entertainment ".date("d/m Y");

error_reporting(E_ALL);
include('htmlMimeMail.php');


$hent = mysql_query("SELECT * FROM testliste ORDER BY id") or die
(mysql_error());

$adr="email";
while ($em = mysql_fetch_array($hent)) {
$indhold=""; $tekstindhold="";


if (($nyhed1)&&($medtag1=="checked")) { $indhold=$indhold.'<table
cellspacing="0" cellpadding="6" width="100%" background="halvgennem.gif">
<tr>
<td rowspan="2" width="137" align="center" valign="top" style="border-top:
1px solid #000000; border-left: 1px solid #000000; border-bottom: 1px solid
#000000;"><img vspace="6" border="0" src="'.$billede1.'" alt="" /></td>
<td height="30" class="almtekst" style="border-top: 1px solid #000000;
border-right: 1px solid #000000;"><b>'.$overskrift1.'</b></td>
</tr>
<td valign="top" class="almtekst" style="border-right: 1px solid #000000;
border-bottom: 1px solid #000000;">'.stripslashes(nl2br($nyhed1)).'</td>
</tr>
</table>
<br />';
$tekstindhold=$tekstindhold.'
'.$overskrift1.'

'.$nyhed1.'
'; }

if (($nyhed2)&&($medtag2=="checked")) { $indhold=$indhold.'<table
cellspacing="0" cellpadding="6" width="100%" background="halvgennem.gif">
<tr>
<td rowspan="2" width="137" align="center" valign="top" style="border-top:
1px solid #000000; border-left: 1px solid #000000; border-bottom: 1px solid
#000000;"><img vspace="6" border="0" src="'.$billede2.'" alt="" /></td>
<td height="30" class="almtekst" style="border-top: 1px solid #000000;
border-right: 1px solid #000000;"><b>'.$overskrift2.'</b></td>
</tr>
<td valign="top" class="almtekst" style="border-right: 1px solid #000000;
border-bottom: 1px solid #000000;">'.stripslashes(nl2br($nyhed2)).'</td>
</tr>
</table>
<br />';
$tekstindhold=$tekstindhold.'
'.$overskrift2.'

'.$nyhed2.'
';}


$mail = new htmlMimeMail();


$background = $mail->getFile('csbbaggrund.jpg');
$logo = $mail->getFile('csblogo.jpg');
$kasse = $mail->getFile('halvgennem.gif');
if ($billede1) { $bil1 = $mail->getFile($billede1); }
if ($billede2) { $bil2 = $mail->getFile($billede2); }

$text = $subject.'

'.$toptekst.'

'.$tekstindhold.'


<b>CSB Island Entertainment ApS</font></b>
Hovedgaden 14 B
DK-6720 Fanoe
Denmark
Tlf. +45 75 16 67 22
Fax. +45 75 16 67 23
<a href="mailto: csb@csbXXX.dk">csb@csbXXX.dk</a>
<a href="http://www.csb.dk">www.csb.dk

Hvis du ikke ønsker at modtage CSB Island Entertainments nyhedsbrev mere,
klik <a
href="her'>http://csb-island.dk/afmeld.php?emailoff='.$em[$adr].'">her
(Virker kun hvis du er online)
';
$html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>CSB-Island Entertainment nyhedsbrev</title>
<style><!-- body,P.msoNormal, LI.msoNormal {
margin-left: 0px;
margin-right: 30px;
margin-top: 0px;
margin-bottom: 0em;
color: "#ffffff";
font-size: 10pt;
font-weight: normal;
font-family: "Arial";
}
-->
</style>
<style type="text/css">
body {
color: #000000;
background-image: url("csbbaggrund.jpg")}

a {text-decoration: underline;}
a:link {color: blue;}
a:visited {color: blue;}
a:active {color: blue;}

#csblogo {
position:relative;
top:0px;
left:0px;}


#indhold {
position:relative;
top:0px;
left:0px;
display;inline;}

..almtekst {
font-family : arial;
font-size : 10pt;
color : #000000;
text-valign : top;
}

</style>

</head><body>
<div>
<div id="indhold" class="almtekst">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td width="158" valign="top"><a href="http://www.csb.dk"
target="_blank"><img border="0" width="158" height="158" src="csblogo.jpg"
alt="bes&oslash;g www.CSB.dk" /></a></td>
<td align="left" valign="top" width="*" class="almtekst"><br /><br /><br
/><br /><b>'.$subject.'</b><br /><br />'.$toptekst.'<br /><br />

'.$indhold.'

<br />
<b>CSB Island Entertainment ApS</font></b>
<br />Hovedgaden 14 B
<br />DK-6720 Fanoe
<br />Denmark
<br />Tlf. +45 75 16 67 22
<br />Fax. +45 75 16 67 23
<br /><a href="mailto: csb@csbXXX.dk">csb@csbXXX.dk</a>
<br /><a href="http://www.csb.dk">www.csb.dk
<br />
<br />Hvis du ikke ønsker at modtage CSB Island Entertainments nyhedsbrev
mere, klik <a
href="her'>http://csb-island.dk/afmeld.php?emailoff='.$em[$adr].'">her
(Virker kun hvis du er online)
<p>&nbsp;</p>
</td></tr></table>
</div>
</body>
</html>';
if (($medtag1=="checked")||($medtag2=="checked")) {
$mail->setHtml($html, $text, './');


$mail->setFrom('Jane Friis <jane@csbXXX.dk>');
$mail->setSubject($subject);



$result = $mail->send(array($em[$adr])); } else { echo'Ingen nyheder var
markeret! - Nyhedsbrev ikke afsendt.';} }



if (($medtag1=="checked")||($medtag2=="checked")) { echo $result ? 'Så er
nyhedsbrevet sendt!' : 'Fejl i afsendelsen'; }


?>




 
 
simon (23-06-2005)
Kommentar
Fra : simon


Dato : 23-06-05 14:57

kan jeg få lov til at se "htmlMimeMail.php" filen?
John Kjoller wrote in dk.edb.internet.webdesign.serverside.php:
> Jeg har lavet et nyhedsbrev, - hvor man indtaster teksten som skal stå i
> brevet, og markerer teksten, hvis den skal tages med i nyhedsbrevet - og man
> gemmer et billede som skal vises sammen med nyhedsbrevet.
>
> Det fungerer tilsyneladende. Næsten.
>
> Bortset fra at en af mine bekendte ikke modtager nyhedsbrevet korrekt. Hun
> får en mail, uden html. (kun selve teksten fra brevet)
> Hun modtager fint html mails, hvis det f.eks er brevpapir fra Outlook.
>
> Jeg selv modtager html nyhedsbrevet, helt korrekt. Og det gør et par andre
> bekendte også.
>
> Herunder paster jeg koden, som afsender brevet (I kan ikke se teksten, da
> det jo er variabler hentet fra indtastnings felterne)
>
> Kan nogen her mon gennemskue, hvorfor nogle modtagere ikke modtager mailen
> korrekt?
> Sig til hvis I har brug for mere info, eller lign.
>
> Pfh tak
> KH
> John
>
>
> Kode:
>
> <?php
>
> $hentinfo = mysql_query("SELECT * FROM nyhedsbrev") or die (mysql_error());
> $info = mysql_fetch_array($hentinfo);
>
> if ($info[medtag1] == "checked") { $billede1=$info[billede1]; } else
> {$billede1="";}
> if ($info[medtag2] == "checked") { $billede2=$info[billede2]; } else
> {$billede2="";}
>
> $toptekst=$info[toptekst];
> $nyhed1=$info[nyhed1];
> $nyhed2=$info[nyhed2];
> $overskrift1=$info[overskrift1];
> $overskrift2=$info[overskrift2];
> $medtag1=$info[medtag1];
> $medtag2=$info[medtag2];
> $subject="Nyhedsbrev fra CSB Island Entertainment ".date("d/m Y");
>
> error_reporting(E_ALL);
> include('htmlMimeMail.php');
>
>
> $hent = mysql_query("SELECT * FROM testliste ORDER BY id") or die
> (mysql_error());
>
> $adr="email";
> while ($em = mysql_fetch_array($hent)) {
> $indhold=""; $tekstindhold="";
>
>
> if (($nyhed1)&&($medtag1=="checked")) { $indhold=$indhold.'<table
> cellspacing="0" cellpadding="6" width="100%" background="halvgennem.gif">
> <tr>
> <td rowspan="2" width="137" align="center" valign="top" style="border-top:
> 1px solid #000000; border-left: 1px solid #000000; border-bottom: 1px solid
> #000000;"><img vspace="6" border="0" src="'.$billede1.'" alt="" /></td>
> <td height="30" class="almtekst" style="border-top: 1px solid #000000;
> border-right: 1px solid #000000;"><b>'.$overskrift1.'</b></td>
> </tr>
> <td valign="top" class="almtekst" style="border-right: 1px solid #000000;
> border-bottom: 1px solid #000000;">'.stripslashes(nl2br($nyhed1)).'</td>
> </tr>
> </table>
> <br />';
> $tekstindhold=$tekstindhold.'
> '.$overskrift1.'
>
> '.$nyhed1.'
> '; }
>
> if (($nyhed2)&&($medtag2=="checked")) { $indhold=$indhold.'<table
> cellspacing="0" cellpadding="6" width="100%" background="halvgennem.gif">
> <tr>
> <td rowspan="2" width="137" align="center" valign="top" style="border-top:
> 1px solid #000000; border-left: 1px solid #000000; border-bottom: 1px solid
> #000000;"><img vspace="6" border="0" src="'.$billede2.'" alt="" /></td>
> <td height="30" class="almtekst" style="border-top: 1px solid #000000;
> border-right: 1px solid #000000;"><b>'.$overskrift2.'</b></td>
> </tr>
> <td valign="top" class="almtekst" style="border-right: 1px solid #000000;
> border-bottom: 1px solid #000000;">'.stripslashes(nl2br($nyhed2)).'</td>
> </tr>
> </table>
> <br />';
> $tekstindhold=$tekstindhold.'
> '.$overskrift2.'
>
> '.$nyhed2.'
> ';}
>
>
> $mail = new htmlMimeMail();
>
>
> $background = $mail->getFile('csbbaggrund.jpg');
> $logo = $mail->getFile('csblogo.jpg');
> $kasse = $mail->getFile('halvgennem.gif');
> if ($billede1) { $bil1 = $mail->getFile($billede1); }
> if ($billede2) { $bil2 = $mail->getFile($billede2); }
>
> $text = $subject.'
>
> '.$toptekst.'
>
> '.$tekstindhold.'
>
>
> <b>CSB Island Entertainment ApS</font></b>
> Hovedgaden 14 B
> DK-6720 Fanoe
> Denmark
> Tlf. +45 75 16 67 22
> Fax. +45 75 16 67 23
> <a href="mailto: csb@csbXXX.dk">csb@csbXXX.dk</a>
> <a href="http://www.csb.dk">www.csb.dk
>
> Hvis du ikke ønsker at modtage CSB Island Entertainments nyhedsbrev mere,
> klik <a
> href="her'>http://csb-island.dk/afmeld.php?emailoff='.$em[$adr].'">her
> (Virker kun hvis du er online)
> ';
> $html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <html>
> <head>
> <title>CSB-Island Entertainment nyhedsbrev</title>
> <style><!-- body,P.msoNormal, LI.msoNormal {
&gt; margin-left: 0px;
&gt; margin-right: 30px;
&gt; margin-top: 0px;
&gt; margin-bottom: 0em;
&gt; color: "#ffffff";
&gt; font-size: 10pt;
&gt; font-weight: normal;
&gt; font-family: "Arial";
&gt; }
&gt; -->
> </style>
> <style type="text/css">
> body {
> color: #000000;
> background-image: url("csbbaggrund.jpg")}
>
> a {text-decoration: underline;}
> a:link {color: blue;}
> a:visited {color: blue;}
> a:active {color: blue;}
>
> #csblogo {
> position:relative;
> top:0px;
> left:0px;}
>
>
> #indhold {
> position:relative;
> top:0px;
> left:0px;
> display;inline;}
>
> ..almtekst {
> font-family : arial;
> font-size : 10pt;
> color : #000000;
> text-valign : top;
> }
>
> </style>
>
> </head><body>
> <div>
> <div id="indhold" class="almtekst">
> <table border="0" cellspacing="0" cellpadding="0" width="100%">
> <tr>
> <td width="158" valign="top"><a href="http://www.csb.dk"
> target="_blank"><img border="0" width="158" height="158" src="csblogo.jpg"
> alt="besøg www.CSB.dk" /></a></td>
> <td align="left" valign="top" width="*" class="almtekst"><br /><br /><br
> /><br /><b>'.$subject.'</b><br /><br />'.$toptekst.'<br /><br />
>
> '.$indhold.'
>
> <br />
> <b>CSB Island Entertainment ApS</font></b>
> <br />Hovedgaden 14 B
> <br />DK-6720 Fanoe
> <br />Denmark
> <br />Tlf. +45 75 16 67 22
> <br />Fax. +45 75 16 67 23
> <br /><a href="mailto: csb@csbXXX.dk">csb@csbXXX.dk</a>
> <br /><a href="http://www.csb.dk">www.csb.dk
> <br />
> <br />Hvis du ikke ønsker at modtage CSB Island Entertainments nyhedsbrev
> mere, klik <a
> href="her'>http://csb-island.dk/afmeld.php?emailoff='.$em[$adr].'">her
> (Virker kun hvis du er online)
> <p> </p>
> </td></tr></table>
> </div>
> </body>
> </html>';
> if (($medtag1=="checked")($medtag2=="checked")) {
> $mail->setHtml($html, $text, './');
>
>
> $mail->setFrom('Jane Friis <jane@csbXXX.dk>');
> $mail->setSubject($subject);
>
>
>
> $result = $mail->send(array($em[$adr])); } else { echo'Ingen nyheder var
> markeret! - Nyhedsbrev ikke afsendt.';} }
>
>
>
> if (($medtag1=="checked")($medtag2=="checked")) { echo $result ? 'Så er
> nyhedsbrevet sendt!' : 'Fejl i afsendelsen'; }
>
>
> ?>
>
>
>


--
Vil du lære at kode HTML, XHTML, CSS, SSI, ASP eller ASP.NET?
- Pædagogiske tutorials på dansk
- Kom godt i gang med koderne
KLIK HER! => http://www.html.dk/tutorials

Knud Gert Ellentoft (23-06-2005)
Kommentar
Fra : Knud Gert Ellentoft


Dato : 23-06-05 15:16

simon skrev:

Et svar på 1 (en) linje og bundciterede ca. 235 linjer.

Vær rar at læse http://www.html.dk/nyhedsgrupper/usenet.asp, især
»Gælder der nogle regler for nyhedsgrupperne?«

Tak.

PS. Se også gerne
http://home13.inet.tele.dk/smedpark/images/html.png det gule
foroven og teksten nederst, burde ikke være til at overse.
--
Knud
Topposter du svar, så ryger du på min ignoreringsliste.
Svar under det du citerer og citer kun det du svarer på - tak.
http://usenet.dk/netikette/citatteknik.html

John Kjoller (23-06-2005)
Kommentar
Fra : John Kjoller


Dato : 23-06-05 16:02

"simon" <pc.manden@gmail.com> skrev
> kan jeg få lov til at se "htmlMimeMail.php" filen?

Jep, den kommer her: (skal du mon så også se mimePart.php ??)

<?php
/**
* Filename.......: class.html.mime.mail.inc
* Project........: HTML Mime mail class
* Last Modified..: $Date: 2002/07/24 13:14:10 $
* CVS Revision...: $Revision: 1.4 $
* Copyright......: 2001, 2002 Richard Heyes
*/

require_once(dirname(__FILE__) . '/mimePart.php');

class htmlMimeMail
{
/**
* The html part of the message
* @var string
*/
var $html;

/**
* The text part of the message(only used in TEXT only messages)
* @var string
*/
var $text;

/**
* The main body of the message after building
* @var string
*/
var $output;

/**
* The alternative text to the HTML part (only used in HTML messages)
* @var string
*/
var $html_text;

/**
* An array of embedded images/objects
* @var array
*/
var $html_images;

/**
* An array of recognised image types for the findHtmlImages() method
* @var array
*/
var $image_types;

/**
* Parameters that affect the build process
* @var array
*/
var $build_params;

/**
* Array of attachments
* @var array
*/
var $attachments;

/**
* The main message headers
* @var array
*/
var $headers;

/**
* Whether the message has been built or not
* @var boolean
*/
var $is_built;

/**
* The return path address. If not set the From:
* address is used instead
* @var string
*/
var $return_path;

/**
* Array of information needed for smtp sending
* @var array
*/
var $smtp_params;

/**
* Constructor function. Sets the headers
* if supplied.
*/

function htmlMimeMail()
{
/**
* Initialise some variables.
*/
$this->html_images = array();
$this->headers = array();
$this->is_built = false;

/**
* If you want the auto load functionality
* to find other image/file types, add the
* extension and content type here.
*/
$this->image_types = array(
'gif' => 'image/gif',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpe' => 'image/jpeg',
'bmp' => 'image/bmp',
'png' => 'image/png',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'swf' => 'application/x-shockwave-flash'
);

/**
* Set these up
*/
$this->build_params['html_encoding'] = 'quoted-printable';
$this->build_params['text_encoding'] = '7bit';
$this->build_params['html_charset'] = 'ISO-8859-1';
$this->build_params['text_charset'] = 'ISO-8859-1';
$this->build_params['head_charset'] = 'ISO-8859-1';
$this->build_params['text_wrap'] = 998;

/**
* Defaults for smtp sending
*/
if (!empty($GLOBALS['HTTP_SERVER_VARS']['HTTP_HOST'])) {
$helo = $GLOBALS['HTTP_SERVER_VARS']['HTTP_HOST'];
} elseif (!empty($GLOBALS['HTTP_SERVER_VARS']['SERVER_NAME'])) {
$helo = $GLOBALS['HTTP_SERVER_VARS']['SERVER_NAME'];
} else {
$helo = 'localhost';
}

$this->smtp_params['host'] = 'localhost';
$this->smtp_params['port'] = 25;
$this->smtp_params['helo'] = $helo;
$this->smtp_params['auth'] = false;
$this->smtp_params['user'] = '';
$this->smtp_params['pass'] = '';

/**
* Make sure the MIME version header is first.
*/
$this->headers['MIME-Version'] = '1.0';
}

/**
* This function will read a file in
* from a supplied filename and return
* it. This can then be given as the first
* argument of the the functions
* add_html_image() or add_attachment().
*/
function getFile($filename)
{
$return = '';
if ($fp = fopen($filename, 'rb')) {
while (!feof($fp)) {
$return .= fread($fp, 1024);
}
fclose($fp);
return $return;

} else {
return false;
}
}

/**
* Accessor to set the CRLF style
*/
function setCrlf($crlf = "\n")
{
if (!defined('CRLF')) {
define('CRLF', $crlf, true);
}

if (!defined('MAIL_MIMEPART_CRLF')) {
define('MAIL_MIMEPART_CRLF', $crlf, true);
}
}

/**
* Accessor to set the SMTP parameters
*/
function setSMTPParams($host = null, $port = null, $helo = null, $auth =
null, $user = null, $pass = null)
{
if (!is_null($host)) $this->smtp_params['host'] = $host;
if (!is_null($port)) $this->smtp_params['port'] = $port;
if (!is_null($helo)) $this->smtp_params['helo'] = $helo;
if (!is_null($auth)) $this->smtp_params['auth'] = $auth;
if (!is_null($user)) $this->smtp_params['user'] = $user;
if (!is_null($pass)) $this->smtp_params['pass'] = $pass;
}

/**
* Accessor function to set the text encoding
*/
function setTextEncoding($encoding = '7bit')
{
$this->build_params['text_encoding'] = $encoding;
}

/**
* Accessor function to set the HTML encoding
*/
function setHtmlEncoding($encoding = 'quoted-printable')
{
$this->build_params['html_encoding'] = $encoding;
}

/**
* Accessor function to set the text charset
*/
function setTextCharset($charset = 'ISO-8859-1')
{
$this->build_params['text_charset'] = $charset;
}

/**
* Accessor function to set the HTML charset
*/
function setHtmlCharset($charset = 'ISO-8859-1')
{
$this->build_params['html_charset'] = $charset;
}

/**
* Accessor function to set the header encoding charset
*/
function setHeadCharset($charset = 'ISO-8859-1')
{
$this->build_params['head_charset'] = $charset;
}

/**
* Accessor function to set the text wrap count
*/
function setTextWrap($count = 998)
{
$this->build_params['text_wrap'] = $count;
}

/**
* Accessor to set a header
*/
function setHeader($name, $value)
{
$this->headers[$name] = $value;
}

/**
* Accessor to add a Subject: header
*/
function setSubject($subject)
{
$this->headers['Subject'] = $subject;
}

/**
* Accessor to add a From: header
*/
function setFrom($from)
{
$this->headers['From'] = $from;
}

/**
* Accessor to set the return path
*/
function setReturnPath($return_path)
{
$this->return_path = $return_path;
}

/**
* Accessor to add a Cc: header
*/
function setCc($cc)
{
$this->headers['Cc'] = $cc;
}

/**
* Accessor to add a Bcc: header
*/
function setBcc($bcc)
{
$this->headers['Bcc'] = $bcc;
}

/**
* Adds plain text. Use this function
* when NOT sending html email
*/
function setText($text = '')
{
$this->text = $text;
}

/**
* Adds a html part to the mail.
* Also replaces image names with
* content-id's.
*/
function setHtml($html, $text = null, $images_dir = null)
{
$this->html = $html;
$this->html_text = $text;

if (isset($images_dir)) {
$this->_findHtmlImages($images_dir);
}
}

/**
* Function for extracting images from
* html source. This function will look
* through the html code supplied by add_html()
* and find any file that ends in one of the
* extensions defined in $obj->image_types.
* If the file exists it will read it in and
* embed it, (not an attachment).
*
* @author Dan Allen
*/
function _findHtmlImages($images_dir)
{
// Build the list of image extensions
while (list($key,) = each($this->image_types)) {
$extensions[] = $key;
}

preg_match_all('/(?:"|\')([^"\']+\.('.implode('|',
$extensions).'))(?:"|\')/Ui', $this->html, $images);

for ($i=0; $i<count($images[1]); $i++) {
if (file_exists($images_dir . $images[1][$i])) {
$html_images[] = $images[1][$i];
$this->html = str_replace($images[1][$i], basename($images[1][$i]),
$this->html);
}
}

if (!empty($html_images)) {

// If duplicate images are embedded, they may show up as attachments, so
remove them.
$html_images = array_unique($html_images);
sort($html_images);

for ($i=0; $i<count($html_images); $i++) {
if ($image = $this->getFile($images_dir.$html_images[$i])) {
$ext = substr($html_images[$i], strrpos($html_images[$i], '.') + 1);
$content_type = $this->image_types[strtolower($ext)];
$this->addHtmlImage($image, basename($html_images[$i]), $content_type);
}
}
}
}

/**
* Adds an image to the list of embedded
* images.
*/
function addHtmlImage($file, $name = '',
$c_type='application/octet-stream')
{
$this->html_images[] = array(
'body' => $file,
'name' => $name,
'c_type' => $c_type,
'cid' => md5(uniqid(time()))
);
}


/**
* Adds a file to the list of attachments.
*/
function addAttachment($file, $name = '',
$c_type='application/octet-stream', $encoding = 'base64')
{
$this->attachments[] = array(
'body' => $file,
'name' => $name,
'c_type' => $c_type,
'encoding' => $encoding
);
}

/**
* Adds a text subpart to a mime_part object
*/
function &_addTextPart(&$obj, $text)
{
$params['content_type'] = 'text/plain';
$params['encoding'] = $this->build_params['text_encoding'];
$params['charset'] = $this->build_params['text_charset'];
if (is_object($obj)) {
return $obj->addSubpart($text, $params);
} else {
return new Mail_mimePart($text, $params);
}
}

/**
* Adds a html subpart to a mime_part object
*/
function &_addHtmlPart(&$obj)
{
$params['content_type'] = 'text/html';
$params['encoding'] = $this->build_params['html_encoding'];
$params['charset'] = $this->build_params['html_charset'];
if (is_object($obj)) {
return $obj->addSubpart($this->html, $params);
} else {
return new Mail_mimePart($this->html, $params);
}
}

/**
* Starts a message with a mixed part
*/
function &_addMixedPart()
{
$params['content_type'] = 'multipart/mixed';
return new Mail_mimePart('', $params);
}

/**
* Adds an alternative part to a mime_part object
*/
function &_addAlternativePart(&$obj)
{
$params['content_type'] = 'multipart/alternative';
if (is_object($obj)) {
return $obj->addSubpart('', $params);
} else {
return new Mail_mimePart('', $params);
}
}

/**
* Adds a html subpart to a mime_part object
*/
function &_addRelatedPart(&$obj)
{
$params['content_type'] = 'multipart/related';
if (is_object($obj)) {
return $obj->addSubpart('', $params);
} else {
return new Mail_mimePart('', $params);
}
}

/**
* Adds an html image subpart to a mime_part object
*/
function &_addHtmlImagePart(&$obj, $value)
{
$params['content_type'] = $value['c_type'];
$params['encoding'] = 'base64';
$params['disposition'] = 'inline';
$params['dfilename'] = $value['name'];
$params['cid'] = $value['cid'];
$obj->addSubpart($value['body'], $params);
}

/**
* Adds an attachment subpart to a mime_part object
*/
function &_addAttachmentPart(&$obj, $value)
{
$params['content_type'] = $value['c_type'];
$params['encoding'] = $value['encoding'];
$params['disposition'] = 'attachment';
$params['dfilename'] = $value['name'];
$obj->addSubpart($value['body'], $params);
}

/**
* Builds the multipart message from the
* list ($this->_parts). $params is an
* array of parameters that shape the building
* of the message. Currently supported are:
*
* $params['html_encoding'] - The type of encoding to use on html. Valid
options are
* "7bit", "quoted-printable" or "base64" (all
without quotes).
* 7bit is EXPRESSLY NOT RECOMMENDED. Default is
quoted-printable
* $params['text_encoding'] - The type of encoding to use on plain text Valid
options are
* "7bit", "quoted-printable" or "base64" (all
without quotes).
* Default is 7bit
* $params['text_wrap'] - The character count at which to wrap 7bit
encoded data.
* Default this is 998.
* $params['html_charset'] - The character set to use for a html section.
* Default is ISO-8859-1
* $params['text_charset'] - The character set to use for a text section.
* - Default is ISO-8859-1
* $params['head_charset'] - The character set to use for header encoding
should it be needed.
* - Default is ISO-8859-1
*/
function buildMessage($params = array())
{
if (!empty($params)) {
while (list($key, $value) = each($params)) {
$this->build_params[$key] = $value;
}
}

if (!empty($this->html_images)) {
foreach ($this->html_images as $value) {
$this->html = str_replace($value['name'], 'cid:'.$value['cid'],
$this->html);
}
}

$null = null;
$attachments = !empty($this->attachments) ? true : false;
$html_images = !empty($this->html_images) ? true : false;
$html = !empty($this->html) ? true : false;
$text = isset($this->text) ? true : false;

switch (true) {
case $text AND !$attachments:
$message = &$this->_addTextPart($null, $this->text);
break;

case !$text AND $attachments AND !$html:
$message = &$this->_addMixedPart();

for ($i=0; $i<count($this->attachments); $i++) {
$this->_addAttachmentPart($message, $this->attachments[$i]);
}
break;

case $text AND $attachments:
$message = &$this->_addMixedPart();
$this->_addTextPart($message, $this->text);

for ($i=0; $i<count($this->attachments); $i++) {
$this->_addAttachmentPart($message, $this->attachments[$i]);
}
break;

case $html AND !$attachments AND !$html_images:
if (!is_null($this->html_text)) {
$message = &$this->_addAlternativePart($null);
$this->_addTextPart($message, $this->html_text);
$this->_addHtmlPart($message);
} else {
$message = &$this->_addHtmlPart($null);
}
break;

case $html AND !$attachments AND $html_images:
if (!is_null($this->html_text)) {
$message = &$this->_addAlternativePart($null);
$this->_addTextPart($message, $this->html_text);
$related = &$this->_addRelatedPart($message);
} else {
$message = &$this->_addRelatedPart($null);
$related = &$message;
}
$this->_addHtmlPart($related);
for ($i=0; $i<count($this->html_images); $i++) {
$this->_addHtmlImagePart($related, $this->html_images[$i]);
}
break;

case $html AND $attachments AND !$html_images:
$message = &$this->_addMixedPart();
if (!is_null($this->html_text)) {
$alt = &$this->_addAlternativePart($message);
$this->_addTextPart($alt, $this->html_text);
$this->_addHtmlPart($alt);
} else {
$this->_addHtmlPart($message);
}
for ($i=0; $i<count($this->attachments); $i++) {
$this->_addAttachmentPart($message, $this->attachments[$i]);
}
break;

case $html AND $attachments AND $html_images:
$message = &$this->_addMixedPart();
if (!is_null($this->html_text)) {
$alt = &$this->_addAlternativePart($message);
$this->_addTextPart($alt, $this->html_text);
$rel = &$this->_addRelatedPart($alt);
} else {
$rel = &$this->_addRelatedPart($message);
}
$this->_addHtmlPart($rel);
for ($i=0; $i<count($this->html_images); $i++) {
$this->_addHtmlImagePart($rel, $this->html_images[$i]);
}
for ($i=0; $i<count($this->attachments); $i++) {
$this->_addAttachmentPart($message, $this->attachments[$i]);
}
break;

}

if (isset($message)) {
$output = $message->encode();
$this->output = $output['body'];
$this->headers = array_merge($this->headers, $output['headers']);

// Add message ID header
srand((double)microtime()*10000000);
$message_id = sprintf('<%s.%s@%s>', base_convert(time(), 10, 36),
base_convert(rand(), 10, 36),
!empty($GLOBALS['HTTP_SERVER_VARS']['HTTP_HOST']) ?
$GLOBALS['HTTP_SERVER_VARS']['HTTP_HOST'] :
$GLOBALS['HTTP_SERVER_VARS']['SERVER_NAME']);
$this->headers['Message-ID'] = $message_id;

$this->is_built = true;
return true;
} else {
return false;
}
}

/**
* Function to encode a header if necessary
* according to RFC2047
*/
function _encodeHeader($input, $charset = 'ISO-8859-1')
{
preg_match_all('/(\w*[\x80-\xFF]+\w*)/', $input, $matches);
foreach ($matches[1] as $value) {
$replacement = preg_replace('/([\x80-\xFF])/e', '"=" .
strtoupper(dechex(ord("\1")))', $value);
$input = str_replace($value, '=?' . $charset . '?Q?' . $replacement .
'?=', $input);
}

return $input;
}

/**
* Sends the mail.
*
* @param array $recipients
* @param string $type OPTIONAL
* @return mixed
*/
function send($recipients, $type = 'mail')
{
if (!defined('CRLF')) {
$this->setCrlf($type == 'mail' ? "\n" : "\r\n");
}

if (!$this->is_built) {
$this->buildMessage();
}

switch ($type) {
case 'mail':
$subject = '';
if (!empty($this->headers['Subject'])) {
$subject = $this->_encodeHeader($this->headers['Subject'],
$this->build_params['head_charset']);
unset($this->headers['Subject']);
}

// Get flat representation of headers
foreach ($this->headers as $name => $value) {
$headers[] = $name . ': ' . $this->_encodeHeader($value,
$this->build_params['head_charset']);
}

$to = $this->_encodeHeader(implode(', ', $recipients),
$this->build_params['head_charset']);

if (!empty($this->return_path)) {
$result = mail($to, $subject, $this->output, implode(CRLF, $headers),
'-f' . $this->return_path);
} else {
$result = mail($to, $subject, $this->output, implode(CRLF, $headers));
}

// Reset the subject in case mail is resent
if ($subject !== '') {
$this->headers['Subject'] = $subject;
}

// Return
return $result;
break;

case 'smtp':
require_once(dirname(__FILE__) . '/smtp.php');
require_once(dirname(__FILE__) . '/RFC822.php');
$smtp = &smtp::connect($this->smtp_params);

// Parse recipients argument for internet addresses
foreach ($recipients as $recipient) {
$addresses = Mail_RFC822::parseAddressList($recipient,
$this->smtp_params['helo'], null, false);
foreach ($addresses as $address) {
$smtp_recipients[] = sprintf('%s@%s', $address->mailbox,
$address->host);
}
}
unset($addresses); // These are reused
unset($address); // These are reused

// Get flat representation of headers, parsing
// Cc and Bcc as we go
foreach ($this->headers as $name => $value) {
if ($name == 'Cc' OR $name == 'Bcc') {
$addresses = Mail_RFC822::parseAddressList($value,
$this->smtp_params['helo'], null, false);
foreach ($addresses as $address) {
$smtp_recipients[] = sprintf('%s@%s', $address->mailbox,
$address->host);
}
}
if ($name == 'Bcc') {
continue;
}
$headers[] = $name . ': ' . $this->_encodeHeader($value,
$this->build_params['head_charset']);
}
// Add To header based on $recipients argument
$headers[] = 'To: ' . $this->_encodeHeader(implode(', ', $recipients),
$this->build_params['head_charset']);

// Add headers to send_params
$send_params['headers'] = $headers;
$send_params['recipients'] =
array_values(array_unique($smtp_recipients));
$send_params['body'] = $this->output;

// Setup return path
if (isset($this->return_path)) {
$send_params['from'] = $this->return_path;
} elseif (!empty($this->headers['From'])) {
$from = Mail_RFC822::parseAddressList($this->headers['From']);
$send_params['from'] = sprintf('%s@%s', $from[0]->mailbox,
$from[0]->host);
} else {
$send_params['from'] = 'postmaster@' . $this->smtp_params['helo'];
}

// Send it
if (!$smtp->send($send_params)) {
$this->errors = $smtp->errors;
return false;
}
return true;
break;
}
}

/**
* Use this method to return the email
* in message/rfc822 format. Useful for
* adding an email to another email as
* an attachment. there's a commented
* out example in example.php.
*/
function getRFC822($recipients)
{
// Make up the date header as according to RFC822
$this->setHeader('Date', date('D, d M y H:i:s O'));

if (!defined('CRLF')) {
$this->setCrlf($type == 'mail' ? "\n" : "\r\n");
}

if (!$this->is_built) {
$this->buildMessage();
}

// Return path ?
if (isset($this->return_path)) {
$headers[] = 'Return-Path: ' . $this->return_path;
}

// Get flat representation of headers
foreach ($this->headers as $name => $value) {
$headers[] = $name . ': ' . $value;
}
$headers[] = 'To: ' . implode(', ', $recipients);

return implode(CRLF, $headers) . CRLF . CRLF . $this->output;
}
} // End of class.
?>



Peter Brodersen (23-06-2005)
Kommentar
Fra : Peter Brodersen


Dato : 23-06-05 15:02

On Thu, 23 Jun 2005 12:55:22 +0200, "John Kjoller"
<john@skrivikkedette-basix.dk> wrote:

>Jeg selv modtager html nyhedsbrevet, helt korrekt. Og det gør et par andre
>bekendte også.

Kan du lægge nyhedsbrev-mailen online et sted i sin rå form? Så kan vi
se, om det ser hensigtsmæssigt ud.

--
- Peter Brodersen

John Kjoller (23-06-2005)
Kommentar
Fra : John Kjoller


Dato : 23-06-05 16:05

"Peter Brodersen" <usenet2005@ter.dk> skrev
> Kan du lægge nyhedsbrev-mailen online et sted i sin rå form? Så kan vi
> se, om det ser hensigtsmæssigt ud.
>

Ja.... jeg er ikke sikker på, jeg ved hvad du mener?

Mener du mailen, som den ser ud, når den modtages? (hos hende, der ikke
modtager den korrekt?)

Kh
john



Peter Brodersen (23-06-2005)
Kommentar
Fra : Peter Brodersen


Dato : 23-06-05 16:20

On Thu, 23 Jun 2005 17:04:59 +0200, "John Kjoller"
<john@skrivikkedette-basix.dk> wrote:

>Mener du mailen, som den ser ud, når den modtages? (hos hende, der ikke
>modtager den korrekt?)

Det er jo den samme mail, alle folk modtager - deres mailprogram
præsenterer den blot måske forskelligt.

Hvis du har mulighed for i dit mailprogram at vælge at se den rå mail
(inklusive headers), så vi kan se hvordan den ser ud i "råt" format,
så vil det være en hjælp.
--
- Peter Brodersen

John Kjoller (23-06-2005)
Kommentar
Fra : John Kjoller


Dato : 23-06-05 16:30

"Peter Brodersen" <usenet2005@ter.dk> skrev

> Det er jo den samme mail, alle folk modtager - deres mailprogram
> præsenterer den blot måske forskelligt.
>
> Hvis du har mulighed for i dit mailprogram at vælge at se den rå mail
> (inklusive headers), så vi kan se hvordan den ser ud i "råt" format,
> så vil det være en hjælp.

Jeg er i tvivl om det mon er dette du mener:

Internetbrevhoveder:
Received: from [80.196.101.239] by mail8.wannafind.dk [80.196.101.190] with
SmartMax MailMax for john@basixXXX.dk; Thu, 23 Jun 2005 10:36:05 +0200
Return-Path: <www@linux10.wannafind.dk>
X-SmartMax-AuthUser:
Received: (from www@localhost)
by linux10.wannafind.dk (8.11.6/8.11.6) id j5N8a4t30917;
Thu, 23 Jun 2005 10:36:04 +0200
Date: Thu, 23 Jun 2005 10:36:04 +0200
To: john@basixXXX.dk
Subject: Nyhedsbrev fra CSB Island Entertainment 23/06 2005
MIME-Version: 1.0
From: Jane Friis <jane@csbXXX.dk>
Content-Type: multipart/alternative;
boundary="=_0104b0ac263829eca2610655b51753b9"
Message-ID: <iij3w4.w090gz@www.csb.dk>


Html-mailen:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>CSB-Island Entertainment nyhedsbrev</title>
<style><!-- body,P.msoNormal, LI.msoNormal {
margin-left: 0px;
margin-right: 30px;
margin-top: 0px;
margin-bottom: 0em;
color: "#ffffff";
font-size: 10pt;
font-weight: normal;
font-family: "Arial";
}
-->
</style>
<style type="text/css">
body {
color: #000000;
background-image: url("cid:373a1bd7677ba30e0348ac95c5c21aa4")}

a {text-decoration: underline;}
a:link {color: blue;}
a:visited {color: blue;}
a:active {color: blue;}

#csblogo {
position:relative;
top:0px;
left:0px;}


#indhold {
position:relative;
top:0px;
left:0px;
display;inline;}

..almtekst {
font-family : arial;
font-size : 10pt;
color : #000000;
text-valign : top;
}

</style>

</head><body>
<div>
<div id="indhold" class="almtekst">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td width="158" valign="top"><a href="http://www.csb.dk"
target="_blank"><img border="0" width="158" height="158"
src="cid:9b5b07eb031f70d3659b27dfd94fbca3" alt="bes&oslash;g www.CSB.dk"
/></a></td>
<td align="left" valign="top" width="*" class="almtekst"><br /><br /><br
/><br /><b>Nyhedsbrev fra CSB Island Entertainment 23/06 2005</b><br /><br
/>I dette nyhedsbrev kan du læse lidt om både ditten og datten. Og det skal
nok blive spændende. Hold på hat og briller<br /><br />

<table cellspacing="0" cellpadding="6" width="100%"
background="cid:d8a64ce878228b405982e4986f88e9d9">
<tr>
<td rowspan="2" width="137" align="center" valign="top" style="border-top:
1px solid #000000; border-left: 1px solid #000000; border-bottom: 1px solid
#000000;"><img vspace="6" border="0"
src="cid:7b02718604cd6caf166cf8981bd3528b" alt="" /></td>
<td height="30" class="almtekst" style="border-top: 1px solid #000000;
border-right: 1px solid #000000;"><b>Ny hjemmeside hærger !</b></td>
</tr>
<td valign="top" class="almtekst" style="border-right: 1px solid #000000;
border-bottom: 1px solid #000000;">CSB har endelig fået den nye seje
hjemmeisde. Tillykke siger CSB til CSB. Efter mange lange dage og aftentimer
er det lykkedes veninde-duoen at få en ny cool hjemmeside stablet på
benene.<br />
CSB jubler.</td>
</tr>
</table>
<br /><table cellspacing="0" cellpadding="6" width="100%"
background="cid:d8a64ce878228b405982e4986f88e9d9">
<tr>
<td rowspan="2" width="137" align="center" valign="top" style="border-top:
1px solid #000000; border-left: 1px solid #000000; border-bottom: 1px solid
#000000;"><img vspace="6" border="0"
src="cid:aee87653c8d0b83577281bc9acfd637d" alt="" /></td>
<td height="30" class="almtekst" style="border-top: 1px solid #000000;
border-right: 1px solid #000000;"><b>Jane Friis er frivilligt blevet
baSix-mand.</b></td>
</tr>
<td valign="top" class="almtekst" style="border-right: 1px solid #000000;
border-bottom: 1px solid #000000;">CSB har indset at baSix er så besværlige
at arbejde med, at de er nødt til at hyre Jane Friis, som fuldtidsansat, -
kun på baSix.<br />
Jane glæder sig til de mange nye udfordinger som helt sikkert venter
hende.<br />
baSix jubler.</td>
</tr>
</table>
<br />

<br />
<b>CSB Island Entertainment ApS</font></b>
<br />Hovedgaden 14 B
<br />DK-6720 Fanoe
<br />Denmark
<br />Tlf. +45 75 16 67 22
<br />Fax. +45 75 16 67 23
<br /><a href="mailto: csb@csbXXX.dk">csb@csbXXX.dk</a>
<br /><a href="http://www.csb.dk">www.csb.dk
<br />
<br />Hvis du ikke ønsker at modtage CSB Island Entertainments nyhedsbrev
mere, klik <a
href="http://csb-island.dk/afmeld.php?emailoff=john@basixXXX.dk">her
(Virker kun hvis du er online)
<p>&nbsp;</p>
</td></tr></table>
</div>
</body>
</html>



John Kjoller (28-06-2005)
Kommentar
Fra : John Kjoller


Dato : 28-06-05 22:20

Er denne tråd mon død igen....?

Jeg har aldrig fundet en løsning. Var der ingen, der vidste noget, mon?

Kh
John



Tommy Ipsen (30-06-2005)
Kommentar
Fra : Tommy Ipsen


Dato : 30-06-05 10:47

John Kjoller wrote:
> Er denne tråd mon død igen....?
>
> Jeg har aldrig fundet en løsning. Var der ingen, der vidste noget, mon?

En lille hurtig ting er at mange mailklienter har problemer med CSS i
html-mails - derfor bør du så vidt muligt undgå det. Derudover skal du
selvfølgelig holde dine mails så simple som muligt og sørge for at de
overholder standarderne.

Ved ikke om du kan bruge disse generelle råd, men det kan jo være de
hjælper dig lidt videre.

Mvh Tommy

John Kjoller (30-06-2005)
Kommentar
Fra : John Kjoller


Dato : 30-06-05 10:54

"Tommy Ipsen" <tipsen@imada.sdu.dk> skrev
> En lille hurtig ting er at mange mailklienter har problemer med CSS i
> html-mails - derfor bør du så vidt muligt undgå det. Derudover skal du
> selvfølgelig holde dine mails så simple som muligt og sørge for at de
> overholder standarderne.
>

Det var måske nok værd at prøve at rydde lidt op i html'en i mailen.... Man
ved jo aldrig om det kan gøre forskellen.



Søg
Reklame
Statistik
Spørgsmål : 177501
Tips : 31968
Nyheder : 719565
Indlæg : 6408527
Brugere : 218887

Månedens bedste
Årets bedste
Sidste års bedste