HTML + CSS in email?

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Res Bas

Res Bas

27/04/2008 16:10:00
Quote Anchor link
Hallo,

Ik heb het internet afgezocht om er achter te komen hoe een email te sturen via PHP met HTML en CSS er in. Ik heb momenteel dit:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
$content = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="en-us" />
<style type="text/css" media="screen">
    
    /* common
    --------------------------------------------------*/
    
    body {
        margin: 0px;
        padding: 0px;
        color: #666;
        background: #e5e0c9 url("http://countrysim.net/emailimg1/bgTile.gif") repeat;
    }
    #BodyImposter {
        color: #666;
        background: #e5e0c9 url("http://countrysim.net/emailimg1/bgTile.gif") repeat;
        width: 100%;
        margin: 0px;
        padding: 0px;
        text-align: center;
    }
    #BodyImposter li,
    #BodyImposter p,
    #BodyImposter td {
        font-size: 12px;
        line-height: 1.5em;
        font-family: Helvetica, Arial, sans-serif;
        text-align: justify;
    }
    #BodyImposter p,
    #BodyImposter ol,
    #BodyImposter ul {
        margin: 0em 0em 1em 0em;
    }
    #BodyImposter img {
        border: 0px;
    }
    #Primary img {
        float: right;
        margin: 5px 0px 15px 15px;
        border: 1px solid #d3d3d3;
        padding: 6px;
    }
    #BodyImposter small {
        font-size: 10px;
        line-height: 1.3em;
    }
    #BodyImposter ol {
        padding-left: 1em;
    }
    #Primary ul {
        padding-left: 1em;
        padding-right: 1em;
    }
    #BodyImposter ol li {
        margin: 0px;
        padding: 0px;
    }
    #BodyImposter ul li {
        background: url("http://countrysim.net/emailimg1/bullet.gif") no-repeat 0em 0.5em;
        padding: 0px 0px 0px 8px;
        margin: 0px;
        list-style: none;
    }
    
    /* links
    --------------------------------------------------*/
    
    #BodyImposter a {
        text-decoration: underline;
    }
    #Primary a:link,
    #Primary a:visited {
        color: #000;
        background: #fff;
    }
    #Helpful a:link,
    #Helpful a:visited,
    #Legal a:link,
    #Legal a:visited {
        color: #666;
        background: transparent;
    }
    #BodyImposter a:hover {
        text-decoration: none;
    }
    #BodyImposter a:active {
        color: #000;
        background: #fff;
        text-decoration: none;
    }
    
    /* heads
    --------------------------------------------------*/
    
    #BodyImposter h1,
    #BodyImposter h2 {
        color: #945620;
        background: #fff;
        font-family: Georgia, Palatino, serif;
        font-weight: normal;
        line-height: normal;
        margin: 0em 0em 0.5em 0em;
        padding: 0px;
        text-align: left;
    }
    #Masthead h1 {
        font-size: 28px;
        color: #fff;
        background: #333;
        margin: 0px;
    }
    #Primary h2 {
        font-size: 22px;
        padding-top: 35px;
        text-align: center;
    }
    
    /* boxes
    --------------------------------------------------*/
    
    #Box {
        color: #666;
        background: #fff;
        border: 1px solid #d3d3d3;
        margin: 0px auto;
    }
    #Content {
        border: 1px solid #d3d3d3;
    }
    #Helpful,
    #Legal {
        margin: 0px auto;
    }
    #Helpful p,
    #Legal p {
        margin: 0px;
        padding: 0px;
        text-align: center;
    }
    #Masthead {
        color: #fff;
        background: #333;
    }
    #Masthead h1,
    #Masthead p {
        text-align: left;
    }
    #Masthead p {
        font-size: 14px;
        margin: 0px;
    }
    #Masthead p #Date {
        float: right;
    }
    #Masthead {
        width: 100%;
        text-align: center;
    }

    
</style>
</head>

<body>
<div id="BodyImposter" style="color: #666; background-color: #e5e0c9;">
    <table id="Helpful" cellspacing="0" cellpadding="15" width="610">
        <tr>
            <td style="font-family: Helvetica, Arial, sans-serif;">
                <p>You are receiving this email because someone has registered at <a href="http://www.countrysim.net/">CountrySim</a> using this email. If you have not registered at <a href="http://www.countrysim.net/">CountrySim</a>, please ignore this email.</p>
            </td>
        </tr>
    </table>
    <table id="Box" cellspacing="0" cellpadding="15" width="580" style="color: #666; background-color: #fff;">
        <tr>
            <td>
                <table id="Masthead" cellspacing="0" cellpadding="20" width="580">
                    <tr>
                        <td style="color: #fff; background: #333; font-family: Helvetica, Arial, sans-serif;">
                            <h1 style="font-family: Georgia, Palatino, serif;">CountrySim</h1>
                            <p><span id="Date">'.date("l, F jS Y",time ()).'</span> Registration Details</p>
                        </td>
                    </tr>
                </table>
                <table id="Content" cellspacing="0" cellpadding="20" width="580" style="color: #666; background-color: #fff;">
                    <tr valign="top">
                        <td id="Primary" style="font-family: Helvetica, Arial, sans-serif;">
                            <h2 style="font-family: Georgia, Palatino, serif;">Thank you for creating your own nation.</h2>
<p>Please do not lose this email. This email contains your login information for CountrySim.net.</p>
<p>Please login at <a href="http://www.countrysim.net/login.php">CountrySim</a> using these details:<br>
Username: '.$username.'<br>
Password: '.$password.'</p>
<p>We thank you for your being interested in CountrySim. We hope you will have a good time playing this game.</p>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <table id="Legal" cellspacing="0" cellpadding="15" width="610">
        <tr>
            <td style="font-family: Helvetica, Arial, sans-serif;">
                <p>&copy; Reshad Bashir 2007-2008<br>
                All Rights Reserved</p>
            </td>
        </tr>
    </table>
</div>
</body>
</html>';
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: [email protected]\r\n";
mail($email,"CountrySim Registration Details",$content,$headers);


Let vooral op
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

Want als ik hem stuur, leest mijn email de HTML wel, maar de CSS niet. Moet ik er nog niets bij in de $headers?
 
PHP hulp

PHP hulp

17/05/2024 08:54:03
 

27/04/2008 16:20:00
Quote Anchor link
Dat komt omdat de meeste mail-programma's niet met CSS kunnen omgaan... Ik zou proberen zoveel mogelijk met HTML te doen, en géén/zo weinig mogelijk css te gebruiken.

Koen
 
Martijn B

Martijn B

27/04/2008 16:49:00
Quote Anchor link
De meeste email programma,s kunnen volgens mij prima omgaan met CSS/HTML.

Gebruik alleen geen divjes, en je raad het al het is een MS probleem.

Je bent dus aangewezen op tabellen.
 
Res Bas

Res Bas

27/04/2008 17:10:00
Quote Anchor link
Oke, dank jullie wel!
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.