I was wondering if you guys could help me. 'cause I've been looking on how to do this in google but it ended up failed, so I don't know how to do it again.
I have a form that when the costumer fill those form, then those form will be sent to their email and mine. The format of the form that sent to their email is just a regular form, Whereas the filled form that sent to mine is a id card that filled with pictures and costumer identity. Now I want the id card that I made with html inside phpmailer body to convert it to image or pdf, so that I could just download it once on my email.
this is the code that I want to convert
$mail = new PHPMailer();
$mail->IsSMTP();// set mailer to use SMTP
$mail->Host = "mail.sample.com"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "noreply@sample.com"; // SMTP username
$mail->Password = "password"; // SMTP password
$mail->From = "noreply@sample";
$mail->FromName = "Sample";
$mail->AddAddress("Sample@gmail.com");
$mail->IsHTML(true);// set email format to HTML
$mail->Subject = "Form";
$mail->Body = "
<html>
<head>
<title>Rectangle</title>
</head>
<body>
<div id='kartu'>
<div style='background-color: #fe031b; width: 750px; padding: 2px; border: 2px solid black; margin: 25px;'>
<img src='images/ucilogo.png' height='100px' width='750px'>
<p><img src='".$uploadfile."' width='150px' height='189px' />
<img src='images/rules.png' width='300px' height='180px' align='right'></p>
<p><img src='".$uploadttd."' width='150px' height='80px' />
<img src='images/ttdpres.png' width='280px' height='100px' align='right'></p>
<div style='font-family:georgia;font-size:16px;'>".$nama." ".$namaakhir."</div>
</div>
<div style='background-color: #fe031b; width: 750px; height:450px; padding: 2px; border: 2px solid black; margin: 25px;'>
<table border='0' align='center' width='750px' style='table-layout:fixed;word-wrap:break-word;font-size:18px;
font-family:georgia;padding-top:20px;'/>
<tr>
<td style='width:150px;'>
UCI Category
</td>
<td style='width:5px;'>:</td>
<td style='width:200px;'>
".$kategori_uci."
</td>
<td style='width:150px;'>
Gender
</td>
<td style='width:5px;'>:</td>
<td style='width:150px;'>
".$gender."
</td>
</tr>
<tr>
</tr>
<td></td>
<td></td>
<tr>
<td>
National Category
</td>
<td>:</td>
<td>
".$kategori_nas."
</td>
<td>
Blood Type
</td>
<td>:</td>
<td>
".$tipe_darah."
</td>
</tr>
</tr>
<td></td>
<td></td>
<tr>
<tr>
<td>
Last Name
</td>
<td>:</td>
<td>
".$namaakhir."
</td>
<td>
Number
</td>
<td>:</td>
<td>
".$no_urutan."
</td>
</tr>
</tr>
<td></td>
<td></td>
<tr>
<tr>
<td>
First Name
</td>
<td>:</td>
<td>
".$nama."
</td>
<td>
Date Of Birth
</td>
<td>:</td>
<td>
".$tgl_lahir."
</td>
</tr>
</tr>
<td></td>
<td></td>
<tr>
<tr>
<td>
Nationality
</td>
<td>:</td>
<td>
".$nationality."
</td>
<td>
Club
</td>
<td>:</td>
<td>
".$nama_klub."
</td>
</tr>
</tr>
<td></td>
<td></td>
<tr>
<tr>
<td>
Region
</td>
<td>:</td>
<td>
".$provinsi."
</td>
</tr>
</tr>
<td></td>
<td></td>
<tr>
<tr>
<td>
Address
</td>
<td>:</td>
<td>
".$alamat."
</td>
</tr>
</table>
<img style='float:right;' src='images/logoissi.png'>
<div style='font-size:18px;font-family:georgia;'>
Issued On :Jakarta ".date('d-M-Y')."</div>
<div style='font-size:18px;font-family:georgia;'>
UCI Code ;INA ".$tgllahir."</div>
<div style='font-size:18px;font-family:georgia;'>
Year ".date('Y')."</div>
</div>
</div>
</body>
</html>";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Mail not send";
Please help me because I'm so confused and I'm also still new in this programming code. Thanks
the image src has to be an absolute path to an existing server where the file is present!
simply place your image on your webserver (i.e. under http://yourserver.com/mail/images/name.jpg
) and insert the correct url as your <img src>
.
Since the user doesn not have access to a relative path as a source, he has to literally download it from your server through your email. i hope this helps