{lang: 'de'}
Flashhilfe.de - Flash Community

Html Mails per PHP verschicken

 


AntwortenRegistrieren Seite1  

daxs#1
Benutzerbild von daxs
Beiträge: 189
Wohnort: Rostock
Registriert: Jan 2007

04.05.2012, 11:35

Moin,

ich baue gerade ein Formular in welches ich Absender, Empfänger ... und Html-Code einfüge und es dann al html-mail verschicken möchte. Idee gut, klappt aber nicht wirklich. Mal sehe ich gar nichts, mal ungelayoutet ohne css und verlinkte bilder (Mit Thunderbird).

Wäre schön wenn mir jemand helfen könnte.

html_mail_verschicken.php:
PHP:
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
$absender_text='';
$antwort_text='';
$empfaenger_text='';
$betreff_text='';
$html_code_text='';
if(isset($_REQUEST['senden'])){   
    $absender_color='';
    $antwort_color='';
    $empfaenger_color='';
    $betreff_color='';
    $html_code_color='';
    $html_code = $_REQUEST['html_code'];
    /*$html_code = nl2br( htmlspecialchars($_REQUEST['html_code']));
    $html_code = str_replace("\'", "'", $html_code);
    $html_code = str_replace('\"', '"', $html_code);
    $html_code = str_replace("'", "\'", $html_code);
    $html_code = str_replace('"', '\"', $html_code);*/
    $Mailnachricht = $html_code;
    $template = $html_code;
    if(!$_REQUEST['absender']){
         $absender_color='color:#F00;';
    } else {
        $absender_text=$_REQUEST['absender'];
    }         
    if(!$_REQUEST['antwort']){
        $antwortan=$_REQUEST['absender'];
    } else {
        $antwortan=$_REQUEST['antwort'];
    }
    if(!$_REQUEST['empfaenger']){
         $empfaenger_color='color:#F00;';
    } else {
        $empfaenger_text=$_REQUEST['empfaenger'];
    }
    if(!$_REQUEST['betreff']){
         $betreff_color='color:#F00;';
    } else {
        $betreff_text=$_REQUEST['betreff'];
    }
    if(!$_REQUEST['html_code']){
         $html_code_color='color:#F00;';
    }     else {
        $html_code_text=$_REQUEST['html_code'];
    }
    if($_REQUEST['absender'] && $_REQUEST['empfaenger'] && $_REQUEST['html_code']){       
        $empfaenger = $_REQUEST['empfaenger']; //Mailadresse
        $absender   = $_REQUEST['absender'];
        $betreff    = $_REQUEST['betreff'];
        $trenner = md5( time() );
       
        /*$header  = "MIME-Version: 1.0\r\n";
        $header .= "Content-Type: multipart/mixed;\r\n";
        $header .= " boundary = " .$trenner;
                                 
        $header .= "From: $absender\r\n";
        $header .= "Reply-To: $antwortan\r\n";
        $header .= "\r\n";  // falls an CC gesendet werden soll
        $header .= "";*/

       
        $mailheader .= "Reply-To: " .$antwortan. "\r\n";
           $mailheader .= "Return-Path: noreply@" .$_SERVER['SERVER_NAME']. "\r\n";
        $mailheader .= "Message-ID: <" .time(). " noreply@" .$_SERVER['SERVER_NAME']. ">\r\n";
        $mailheader .= "X-Mailer: PHP v" .phpversion(). "\r\n";
        $mailheader .= "From: PHP Email Tutorial<noreply@" .$_SERVER['SERVER_NAME']. ">\r\n";
        $mailheader .= "MIME-Version: 1.0\r\n";
        $mailheader .= "Content-Type: multipart/mixed;\r\n";
        $mailheader .= " boundary = " .$trenner;
        $mailheader .= "\r\n\r\n";
       
        $mailbody  = "This is a multi-part message in MIME format\r\n";
        $mailbody .= "--" .$trenner. "\r\n";
        $mailbody .= "Content-Type: text/html; charset=UTF-8;\r\n";
        $mailbody .= "Content-Transfer-Encoding: 8bit;\r\n";
        $mailbody .= $template. "\r\n\r\n";
   
   
        mail(     $empfaenger,
                $betreff,
                $mailbody,
                $mailheader);       
        echo'<span class="goldene_schrift"><b>Absenden erfolgreich.</b></span>';
    }
}

ActionScript:
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
<form action="html_mailer.php" method="post">
<table width="500" border="0">
  <tr>
    <td valign="top" style=" <? echo $absender_color; ?>">Absender:</td>
    <td><textarea name="absender" style="width:300px; height:15px;"><? echo $absender_text; ?></textarea></td>
  </tr>
  <tr>
    <td valign="top" style=" <? echo $antwort_color; ?>">Antwort an:</td>
    <td><textarea name="antwort" style="width:300px; height:15px;"><? echo $antwort_text; ?></textarea></td>
  </tr>
  <tr>
    <td valign="top" style=" <? echo $empfaenger_color; ?>">Empf&auml;nger:
<span style="font-size:10px;">Mehrere Empf&auml;nger durch Kommata abtrennen.</span></td>
    <td><textarea name="empfaenger" style="width:300px; height:70px;"><? echo $empfaenger_text; ?></textarea></td>
  </tr>
  <tr>
    <td valign="top" style=" <? echo $betreff_color; ?>">Betreff:</td>
    <td><textarea name="betreff" style="width:300px; height:15px;"><? echo $betreff_text; ?></textarea></td>
  </tr>
  <tr>
    <td valign="top" style=" <? echo $html_code_color; ?>">Code der Html-E-Mail:</td>
    <td><textarea name="html_code" style="width:300px; height:400px;"><? echo $html_code_text; ?></textarea></td>
  </tr>
  <tr>
    <td valign="top"></td>
    <td><input type="submit" name="senden" style="width:308px;" /></td>
  </tr>
</table>   
</form>


Zu verschickende html:
ActionScript:
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
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Gut Bissenmoor</title>
<meta name = “viewport” content = “width = 650?>
<link href='http://fonts.googleapis.com/css?family=Cantarell:400,700' rel='stylesheet' type='text/css'>
<style type="text/css">
body {
     margin-left: 0px;
     margin-top: 0px;
     margin-right: 0px;
     margin-bottom: 0px;
     font-family: 'Cantarell', Verdana, Geneva, sans-serif;
     color: #412D1C;
     background-color: #E7E1D2;
}
#text{
     margin-top:25px;
     font-size:13px;
}
#text a:link{
     color: #412D1C;
}
#text a:visited{
     color: #412D1C;
}
#text a:hover{
     color: #412D1C;
}
#text a:active{
     color: #412D1C;
}
#text_link{
     font-size:13px;
     float:left;
     margin-top:120px;
     margin-right:20px;
}
#text_link a:link{
     color: #412D1C;
}
#text_link a:visited{
     color: #412D1C;
}
#text_link a:hover{
     color: #412D1C;
}
#text_link a:active{
     color: #412D1C;
}
#text_1{
     width:100%;
     text-align:center;
     font-size:8px;
     color:#E7E1D2;
}
#text_1 a:link {
     color: #E7E1D2;
}
#text_1 a:visited {
     color: #E7E1D2;
}
#text_1 a:hover {
     color: #E7E1D2;
}
#text_1 a:active {
     color: #E7E1D2;
}
</style>
</head>

<body><table width="100%" border="0" style="top:0px;margin-left: 0px;margin-top: 0px;margin-right: 0px;   margin-bottom: 0px;">
  <tr>
    <td>&nbsp;</td>
    <td width="640px;"><div id="wrapper" style="position:absolute; width:616px;">
      <div id="schatten_links" style="position:absolute; height:101%;  top:-15px; width:12px; left:-12px; background-image:url(http://www.[...].de/images/mail_schatten_links.png);">
        </div>
        <div id="schatten_rechts" style="position:absolute; height:101%; top:-15px; width:12px; right:-12px; background-image:url(http://www.[...].de/images/mail_schatten_rechts.png);">
        </div>
        <div id="logo" style="position:absolute; top:20px; right:5%; z-index:2;">
            <img src="http://www.[...].de/images/email_logo.png" height="50px;" />
        </div>
            <div style="width:76%; margin-left:12%; margin-top:140px; z-index:2">
                <div id="datum" style="margin-right:30px; text-align:right; font-size:12px;">
                    HEAD
                </div>
                <div id="head" style="margin-top:20px; font-size:17px;">
                    <b>HEAD2</b>
                </div>
                <div id="text">
                    Sehr geehrte Damen und Herren,

                   

                    freuen Sie sich auf goldene Zeiten mit der [...]
                   

                    Wir danken Ihnen für Ihr freundliches Interesse und verbleiben mit besten Grüßen.
                </div>
                <div id="unterschrift_1" style="margin-top:40px; font-size:13px; float:left; width:200px;">
                    Thomas

                    <span style="font-size:10px">Vorstandsvorsitzender</span>
                </div>
                <div id="unterschrift_2" style="margin-top:40px; width:200px; margin-left:240px; font-size:13px;">
                    Günter

                    <span style="font-size:10px">Vorstand</span>
                </div>
                <div id="text_link">
                    <a href="http://gutbissenmoor.de/G_B_broschuere.php" style="color: #412D1C;">Blättern Sie sich </a>
                </div>   
                <div id="bild_link" style="margin-top:40px;">
                    <a href="http://gutbissenmoor.de/G_B_broschuere.php"><img src="http://www.[...].de/images/email_download_1_thumb.png" width="100px" border="0" /></a>
                </div>
            </div>         
            <div id="rasen" style="margin-top:50px; overflow:hidden;">
                <img src="http://www.[...].de/images/rasen_gold_151_127_73.png" height="50px" />
            </div>
            <div id="text_1" style="background-image:url(http://www.[...].de/images/gold_151_127_73.jpg); background-repeat:repeat;">
                   
   

   

             </div>
      </div></td>
    <td>&nbsp;</td>
  </tr>
</table>


</body>
</html>



Im Anhang ist der Quelltext der Email.

Dankeschön.

daxs

Angehängte Dateien:
Adobe Acrobat PDF quelltext.pdf15.79 KB
Schlagwörter: HTML-mail
Geändert von daxs am 04.05.12 um 11:44 Uhr
springer#2
Benutzerbild von springer
Beiträge: 4909
Wohnort: zuhaus
Registriert: Apr 2004

04.05.2012, 12:32