-3

I wonder how that can change the appearance of e-mail that comes to me via PHP?

Here's the email:

I'd like to look something like this for example

This is a PHP code:

<?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");
}
?> 

I wonder if this can be done via php me or I need some framework

Ravi
  • 30,829
  • 42
  • 119
  • 173
M Production
  • 59
  • 1
  • 2
  • 9
  • Use html (setting email's content type to `text/html`) – gmc Apr 02 '17 at 07:57
  • I recommend using a tried and tested mail library like SwitfMail, PHPMailer or similar for this. It's gonna save you time from reinventing the wheel. When sending html-emails, You should also add a plain text part for the email clients that can't read HTML emails or have it turned off, which is easy with one of the common libraries. – M. Eriksson Apr 02 '17 at 08:03

2 Answers2

0

You need to do following:

  1. Prepare your mail contents in html format.

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

  2. Provide absolute path of your image instead of relative path. So, just providing image name is not sufficient. You need to provide exact path where that image resides in your server. So that, it will load it from there.

Ravi
  • 30,829
  • 42
  • 119
  • 173
0

You can send your email as an HTML email. For example:

<?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);
?>

For more information you can visit this.

Yuval Pruss
  • 8,716
  • 15
  • 42
  • 67