如何在PHP中编辑邮件外观?

时间:2017-04-02 07:55:06

标签: php email appearance

我想知道这会如何改变通过PHP发送给我的电子邮件的外观?

Here's the email:

I'd like to look something like this for example

这是一个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我或我需要一些框架来完成

2 个答案:

答案 0 :(得分:0)

您需要执行以下操作:

  1. 以html格式准备邮件内容。

    <html> <body> //write your stuff </body> </html>

  2. 提供图像的绝对路径而不是相对路径。因此,仅提供图像名称是不够的。您需要提供该映像驻留在服务器中的确切路径。所以,它会从那里加载它。

答案 1 :(得分:0)

您可以将您的电子邮件作为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