I have the following code that adds the first name and last name onto a predefined image.
function create_image($fname, $lname)
{
 $image = imagecreatefromjpeg('sample.jpg');
 $color = imagecolorallocate($image, 255, 255, 255);
 $font_path = '../fonts/GSMT.TTF';
 $font_size = 18;
 $first_name = $name;
 $last_name = $lname;
 $name = $fname." ". $lname;
// Print Text On Image
imagettftext($image, $font_size, 0, 100, 160, $color, $font_path, $name);
header('Content-type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
}
I use the following email script;
function mailer($email_adrress, $registration_id)
{
$mail = new PHPMailer;
$mail->isSMTP(); // set mailer to use SMTP
$mail->Host = 'mail.server.com'; // set mail server
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Username = 'email@address.com'; // SMTP username
$mail->Password = 'password'; // SMTP password
$mail->Port = 587; // TCP port to connect to
$mail->IsHTML(true);      
$mail->From = 'johndoe@gmail.com';
$mail->FromName = 'John Doe'; // from name     
$mail->addAddress($email_adrress); // recipient                            
$mail->Subject = 'emailer';
$mail->Body    = "Congratulations you have been Successfully registered.   
if(!$mail->send()) 
{
    die("error mail not sent);
} 
}
When the create_image function is called the image gets created successfully. But my question is instead of printing the image onto the browser how do i mail it. Should i temporarily save the image till the mail is sent and then delete it, or is there another approach?
 
     
     
    