如何在 PHP 中编辑邮件外观?
How to edit mail appearance in PHP?
我想知道如何改变通过 PHP 发给我的电子邮件的外观?
这是一个PHP代码:
<?php
$Ime = $_POST["Ime"];
$Prezime = $_POST["Prezime"];
$NaslovOglasa = $_POST["NaslovOglasa"];
$Email = $_POST["Email"];
$SadrzajOglasa = $_POST["SadrzajOglasa"];
$Kontakt = $_POST["Kontakt"];
if (isset($_POST['Istaknut_Oglas'])) {
$IstaknutOglas = "Da";
} else {
$IstaknutOglas = "Ne";
}
if (isset($_POST['Standardni_Paket'])) {
$StandardniPaket = "Da";
} else {
$StandardniPaket = "Ne";
}
$Za = "bratunac.info@gmail.com";
$Od = "Od: " . $Email . "\r\n";
$Info .= "|NOVI OGLAS|" . "\r\n";
$Info .= "Ime: " . $Ime . "\r\n";
$Info .= "Prezime: " . $Prezime . "\r\n";
$Info .= "Naslov oglasa: " . $NaslovOglasa . "\r\n";
$Info .= "Sadrzaj oglasa: " . $SadrzajOglasa . "\r\n";
$Info .= "Kontakt informacije: " . $Kontakt . "\r\n";
$Info .= "Istaknut oglas: " . $IstaknutOglas . "\r\n";
$Info .= "Standardni paket: " . $StandardniPaket . "\r\n";
$Info .= "" . "\r\n";
if(isset($_FILES['file_array'])){
$name_array = $_FILES['file_array']['name'];
$tmp_name_array = $_FILES['file_array']['tmp_name'];
$type_array = $_FILES['file_array']['type'];
$size_array = $_FILES['file_array']['size'];
$error_array = $_FILES['file_array']['error'];
for($i = 1; $i < count($tmp_name_array); $i++){
if(move_uploaded_file($tmp_name_array[$i], "adsuploads/".$name_array[$i])){
$Info .= "Fotografija ".$i.": ".$name_array[$i]. "\r\n";
}
}
mail($Za, $Od, $Info);
header("Location: http://bratunacinfo.000webhostapp.com/pages/postavi_oglas-3");
}
?>
我想知道这是否可以通过 php 我来完成,或者我需要一些框架
您需要执行以下操作:
以 html 格式准备您的邮件内容。
<html>
<body>
//write your stuff
</body>
</html>
提供图像的绝对路径而不是相对路径。因此,仅提供图像名称是不够的。您需要提供该图像在您的服务器中的确切路径。这样,它将从那里加载它。
您可以将电子邮件作为 HTML 电子邮件发送。例如:
<?php
$to = "someone@somedoamin.com";
$subject = "Some email title";
$content = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
";
$headers = "MIME-Version: 1.0\r\nContent-type:text/html;charset=UTF-8\r\n";
mail($to, $subject, $content, $headers);
?>
更多信息请访问this。
我想知道如何改变通过 PHP 发给我的电子邮件的外观?
这是一个PHP代码:
<?php
$Ime = $_POST["Ime"];
$Prezime = $_POST["Prezime"];
$NaslovOglasa = $_POST["NaslovOglasa"];
$Email = $_POST["Email"];
$SadrzajOglasa = $_POST["SadrzajOglasa"];
$Kontakt = $_POST["Kontakt"];
if (isset($_POST['Istaknut_Oglas'])) {
$IstaknutOglas = "Da";
} else {
$IstaknutOglas = "Ne";
}
if (isset($_POST['Standardni_Paket'])) {
$StandardniPaket = "Da";
} else {
$StandardniPaket = "Ne";
}
$Za = "bratunac.info@gmail.com";
$Od = "Od: " . $Email . "\r\n";
$Info .= "|NOVI OGLAS|" . "\r\n";
$Info .= "Ime: " . $Ime . "\r\n";
$Info .= "Prezime: " . $Prezime . "\r\n";
$Info .= "Naslov oglasa: " . $NaslovOglasa . "\r\n";
$Info .= "Sadrzaj oglasa: " . $SadrzajOglasa . "\r\n";
$Info .= "Kontakt informacije: " . $Kontakt . "\r\n";
$Info .= "Istaknut oglas: " . $IstaknutOglas . "\r\n";
$Info .= "Standardni paket: " . $StandardniPaket . "\r\n";
$Info .= "" . "\r\n";
if(isset($_FILES['file_array'])){
$name_array = $_FILES['file_array']['name'];
$tmp_name_array = $_FILES['file_array']['tmp_name'];
$type_array = $_FILES['file_array']['type'];
$size_array = $_FILES['file_array']['size'];
$error_array = $_FILES['file_array']['error'];
for($i = 1; $i < count($tmp_name_array); $i++){
if(move_uploaded_file($tmp_name_array[$i], "adsuploads/".$name_array[$i])){
$Info .= "Fotografija ".$i.": ".$name_array[$i]. "\r\n";
}
}
mail($Za, $Od, $Info);
header("Location: http://bratunacinfo.000webhostapp.com/pages/postavi_oglas-3");
}
?>
我想知道这是否可以通过 php 我来完成,或者我需要一些框架
您需要执行以下操作:
以 html 格式准备您的邮件内容。
<html> <body> //write your stuff </body> </html>
提供图像的绝对路径而不是相对路径。因此,仅提供图像名称是不够的。您需要提供该图像在您的服务器中的确切路径。这样,它将从那里加载它。
您可以将电子邮件作为 HTML 电子邮件发送。例如:
<?php
$to = "someone@somedoamin.com";
$subject = "Some email title";
$content = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
";
$headers = "MIME-Version: 1.0\r\nContent-type:text/html;charset=UTF-8\r\n";
mail($to, $subject, $content, $headers);
?>
更多信息请访问this。