Do so, I put adjust in front of the commands you should adjust in your case:
if($_SERVER['REQUEST_METHOD'] == 'POST') {
if(isset($_POST['texto'], $_POST['imagem'], $_POST['email'])) {
$jpg_image = imagecreatefromjpeg($_POST['imagem']); // criar imagem
$fontColor = imagecolorallocate($jpg_image, 255, 255, 255); // cor do texto
$font_path = './cour.ttf'; // Ajustar, tipo de fonte, neste caso está na mesma pasta deste script
$text = $_POST['texto'];
imagettftext($jpg_image, 25, 0, 0, 30, $fontColor, $font_path, $text); // posição/tamanho do texto
$file = md5(time()). '.jpg'; // nome do ficheiro
imagejpeg($jpg_image, 'imgsTests/' .$file); // Ajustar, pasta destino
$imgSaved = 'http://migueldvl.com/heya/imgsTests/' .$file; // Ajustar path absoluto para imagem
$message = '<html><body><img src="' .$imgSaved. '"></body></html>'; // Ajustar mensagem
$headers = "From: " . strip_tags($_POST['email']) . "\r\n"; // Ajustar
$headers .= "Reply-To: ". strip_tags($_POST['email']) . "\r\n"; // Ajustar
$headers .= "CC: [email protected]\r\n"; // Ajustar
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
mail($_POST['email'], 'My Subject', $message, $headers); // Ajustar, subject
echo 'Imagem Enviada:<br><img src="' .$imgSaved. '">';
imagedestroy($jpg_image);
}
else {
echo 'Faltam dados';
}
die();
}
?>
<form method="POST">
<input type="email" name="email" placeholder="email"><br>
<input type="text" name="texto" placeholder="texto">
<select name="imagem">
<option value="https://upload.wikimedia.org/wikipedia/commons/1/1e/Stonehenge.jpg">Image1</option>
<option value="http://www.personal.psu.edu/jul229/mini.jpg">Image2</option>
<option value="https://oss.adm.ntu.edu.sg/jays0001/wp-content/uploads/sites/38/2015/09/betterbusiness_jpg.jpg">Image3</option>
</select>
<input type="submit">
</form>
You want to send only one image by email or you have the option to send an html by mounting image and text?
– Gustavo Thomazelli
Can be an html mounting image and text.
– Laranja Mecânica