Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9068217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:08:22+00:00 2026-06-16T17:08:22+00:00

I tried this code from the post, but this code is sending two emails

  • 0

I tried this code from the post, but this code is sending two emails on a single run of file.

Email file is sending email two times using php mail function

Let me know what i am doing wrong –

<?php
function mytextoverimage( $mytext ) {
$headurl = 'http://dummyimage.com/600x400/ffffee/00d5ff.jpg';
header('Content-type: image/jpeg');
$jpg_image = imagecreatefromjpeg($headurl);
$black = imagecolorallocate($jpg_image, 1, 1, 1);
$font_path = 'myfont/arial.ttf';
$text = $mytext;
imagettftext($jpg_image, 24, 0, 175, 85, $black, $font_path, $text);
imagejpeg($jpg_image);
imagedestroy($jpg_image);
}

$to = "myemail@gmail.com";
$subject = "This is a image conversion from Developer Zone";
$headers = "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= 'From: developer@phpdev.com' . "\r\n" .
'Reply-To: testabc@testabc.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$message = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Title</title>
</head>
<body>
<table width="100%" cellspacing="5" cellpadding="0" border="0" bgcolor="#f0f0f0" style="color:666666;text-align:left; font:12px Verdana, Geneva, sans-serif">
<tr>
<td >'.mytextoverimage('Developer').'</td></tr></table></body></html>';

    mail($to,$subject,$message,$headers); die;

Let me know what i am doing wrong, is this the correct method I am using this —

<img src="'.mytextoverimage('Developer').'" />

I followed this URL but hard to crack any help from this page- http://php.net/manual/en/function.imagejpeg.php

I even tried keeping that method mytextoverimage() in another file but still no help, email sending twice 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:08:24+00:00Added an answer on June 16, 2026 at 5:08 pm

    Your mytextoverimage() function doesn’t return anything – it just sends a jpeg image to the browser.

    I’ve reworked your code to send the same image via email – note that just the image is sent, no HMTL.

    If you want to send an image as part of an HTML document, you need to go a step further and create a multipart message – check out How to attach and show image in mail using php?

    This works for Gmail on Iceweasel 10.0.11.

    <?php
    function mytextoverimage( $mytext )
    {
        $headurl = 'http://dummyimage.com/600x400/ffffee/00d5ff.jpg';
        $jpg_image = imagecreatefromjpeg($headurl);
        $black = imagecolorallocate($jpg_image, 1, 1, 1);
        $font_path = 'myfont/arial.ttf';
        $text = $mytext;
        imagettftext($jpg_image, 24, 0, 175, 85, $black, $font_path, $text);
        ob_start(); //Get the image data from the output buffer
        imagejpeg($jpg_image);
        imagedestroy($jpg_image);
        return chunk_split(base64_encode(ob_get_clean())); //return the image data, encoded for email transfer
    }
    
    $to = "myemail@gmail.com";
    $subject = "This is a image conversion from Developer Zone";
    // --- Note the change from text/html to image/jpeg ---
    $headers = "Content-type: image/jpeg;\r\n";
    //$headers = "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= 'From: developer@phpdev.com' . "\r\n" .
    'Reply-To: testabc@testabc.com' . "\r\n" .
    'Content-Transfer-Encoding: base64' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
    $message = mytextoverimage('Developer');
    
        mail($to,$subject,$message,$headers); die;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i've tried using this code and this to make a random quote generator, but
I tried this code to open a file in Python: f = open("/Desktop/temp/myfile.txt","file1") It
i have tried this code to redirect a php page.but it s not working
how to make php can read log file in /var/log/.... I tried this code
I tried with this code to post on the wall (Twitter) of a user
I tried to run this code: #define ROW_CNT 8; #define COLUMN_CNT 24; #define FIRST_COLUMN
I tried to use this code but it doesn't work. http://developer.apple.com/library/ios/#samplecode/PageControl/Introduction/Intro.html Ld /Users/waitonza/Library/Developer/Xcode/DerivedData/Dr_Ngoo-aanknxmuodcgjicaigxevljxokeq/Build/Products/Debug-iphonesimulator/Dr Ngoo.app/Dr
I found this code on here from this post: jQuery Accordion: links don't work
I've got this code from this post and everything is ok except one thing,
I have tried this code to send a file and insert the details about

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.