I have tried to write a script that sends image as an embedded object rather that attachment OR a url link but it is not working. I am attaching the code. Please help me.
aeronvista 0 Newbie Poster
<?php
$firstname = $_POST['FirstName'];
$lastname = $_POST['Lastname'];
$date = $_POST['Date'];
$month = $_POST['Months'];
$year = $_POST['Year'];
$Gender = $_POST['Gender'];
$country = $_POST['Country'];
$Province = $_POST['ProvinceStateRegion'];
$CityTown = $_POST['CityTown'];
$emailaddress = $_POST['EmailAddess'];
$lookingfor = $_POST['LookingFor'];
$interestedin = $_POST['InterestedIn'];
$Duration = $_POST['Duration'];
$tnc_agree = $_POST['tnc_agree'];
$emailaddress = 'ayub@aeronvista.biz';
$to = "ContiAds! <aeronvista.solutions@gmail.com>"; // put here the email address you want this sent to
$cid = md5(time());
$subject = "New ContiAds SignUp!";
$body = "<html>".
"<head>".
"<title>Contact Request</title>".
"<style type='text/css'>".
"body,td,th {".
"font-family: Geneva, Arial, Helvetica, sans-serif;".
"font-size: 12px;".
"}".
".style1 {font-size: 24px}".
"</style></head>".
"<body>".
"<p align='center' class='style1'>ContiAds New Signup</p>".
"<table width='498' border='0' align='center' cellpadding='5' cellspacing='0'>".
"<tr>".
"<td colspan='2' valign='top' bgcolor='#333333' height='2px'></td>".
"</tr>".
"<tr>".
"<td width='104' valign='top'>Full Name:</td>".
"<td width='374'>".$firstname." ".$lastname."</td>".
"</tr>".
"<tr>".
"<td valign='top'>Date:</td>".
"<td>".$date."</td>".
"</tr>".
"<tr>".
"<td valign='top'>Month:</td>".
"<td>".$month."</td>".
"</tr>".
"<tr>".
"<td valign='top'>Year:</td>".
"<td>".$year."</td>".
"</tr>".
"<tr>".
"<td valign='top'>Gender:</td>".
"<td>".$Gender."</td>".
"</tr>".
"<tr>".
"<td valign='top'>Country:</td>".
"<td>".$country."</td>".
"</tr>".
"<tr>".
"<td valign='top'>Province:</td>".
"<td>".$Province."</td>".
"</tr>".
"<tr>".
"<td valign='top'>Email Address:</td>".
"<td>".$emailaddress."</td>".
"</tr>".
"<tr>".
"<td valign='top'>Looking For:</td>".
"<td>".$lookingfor."</td>".
"</tr>".
"<tr>".
"<td valign='top'>Interested In:</td>".
"<td>".$interestedin."</td>".
"</tr>".
"<tr>".
"<td valign='top'>Duration:</td>".
"<td>".$Duration."</td>".
"</tr>".
"<tr>".
"<td colspan='2' valign='top' bgcolor='#333333' height='2px'></td>".
"</tr>".
"<tr>".
"<td><img title=HICON.jpg alt=HICON.jpg src=3Dcid:$cid ></td>".
"</tr>".
"</table>".
"</body>".
"</html>";
//Always set content-type when sending HTML email
$rand = md5( time() );
$mime_boundary = 'Multipart_Boundary_' . $rand;
$headers = "From: " . $emailaddress . "\n" .
"Reply-To:" . $emailaddress . "\n" .
"MIME-Version: 1.0\n" .
"Content-Type: multipart/related; boundary= $mime_boundary"."R \n".
"--$mime_boundary"."R \n".
"Content-Type: multipart/alternative; boundary= $mime_boundary" . "A \n" .
"--$mime_boundary"."A \n".
"\n\n";
$message = "This is a multi-part message in MIME format.\n\n" .
"--" . $mime_boundary . "A \n" .
"Content-Type: text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$body . "\n"."--".$mime_boundary."A-- \n";
// Add file attachment to the message
$filename = "skymark.jpg";
$filepath = "images/$filename";
$success = true;
$len = strlen($filename) - 4;
$extension = substr($filename,$len); // get the file extension
$fileatt_type = 'image/' . strtolower(ltrim($extension, '.'));
$picture_name = $filename;
$attachment = file_get_contents($filepath);
$data = chunk_split( base64_encode($attachment) );
$message .= "--" . $mime_boundary . "R \n" .
"Content-Type: \"" . $fileatt_type . "\";" .
" name=\"" . $picture_name . "\"\n" .
"Content-Transfer-Encoding: base64\n" .
"Content-ID: <$cid>;\n" .
"X-Attachment-ID: $cid;\n" .
$data . "\n\n" .
"--" . $mime_boundary . "R-- \n";
// end file attachment
if($success == true) {
if (mail($to, $subject, $message, $headers)) {
echo "email sent to $to";
} else {
echo 'email failed';
}
}
?>
aeronvista 0 Newbie Poster
Is there any one to help me out
aeronvista 0 Newbie Poster
I think I have not phrased my question in a better way. thats why no one is answering
I am developing an php mail script page but don't know how to embed image in the html code itself . I don't want to put images on server side and use IMG SRC tag so that every time client will fetch it from server instead i'd like to embed the image in html code itself. I think for that purpose something like src=cid:-------- is used but I don't know how to use it.
The purpose for that is
1)Even after disconnecting from the internet client should be able to view the image.
2) I need not to attach the image file every time if it embedded in he HTML itself.
Please send your reply with an example.
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.