www.webdeveloper.com
Results 1 to 8 of 8

Thread: send image via email

  1. #1
    Join Date
    Nov 2005
    Posts
    223

    send image via email

    Hi,
    I made a newsletter script that sends an email using a rich text editor called "FCK Editor".

    This editor allow you to insert an image and send it along with a text and i did insert an image and previewed it and looks fine. But, once i send the email, i get \"\" in the picture place of my email.
    How can i make the picture appear in my email.

    Here is the code:
    PHP Code:
    <?php
    if (isset($_POST['send_e'])) {
        
    $email_from =     $_POST["email_from"];
        
    $email_to     =     $_POST["email_to"];
        
    $title         =     $_POST["title"];
        
    $body         =     nl2br($_POST["FCKeditor1"]);
        
        if (empty(
    $title) || empty($body) || empty($email_to) || empty($email_from)) {
            
    error_box("All Fields Cannot Be Left Blank");
            
    html_rightbar();
            include_once(
    "admin_footer.php");
            exit;
        }
        
    //echo "$body";
        //exit;
        
            
    $to         $email_to;
            
    $headers "MIME-Version: 1.0\r\n"
            
    $headers .= "Content-type: text/html; charset=windows-1256\r\n"
            
    $headers .= "From: Info <$email_from>\r\n"
            
    $headers .="Return-Path: $email_from\r\n";
            
    $headers .="Return-Receipt-To: $email_from\r\n";
            
    $headers .="X-Mailer: My Smart Newsletter \r\n";
            
    $headers .="Message-ID: ".rand(00000000,999999999)."-info@yoursite.com\r\n";
            
    $Send mail($to"$title,$body,"$headers"); 
        
        
        if (
    $Send) {
            
    msg_box("Success","Email Sent Successfully");
            echo 
    "<meta http-equiv='refresh' content='1;URL=main.php'>";
        }
    } else {
        
    open_table("Mailing » Send Individual Mails");
        
        
    ?>
        <form method="POST" action="">
            <tr>
                <td valign="top">Email From<br/>
                    <input type="text" name="email_from" size="35" value="info@yourdomain.com">
                </td>
            </tr>
            <tr>
                <td valign="top">Email To<br/>
                    <input type="text" name="email_to" size="35">
                </td>
            </tr>
            <tr>
                <td valign="top">Title<br/>
                    <input type="text" name="title" size="35">
                </td>
            </tr>
            <tr>
                <td valign="top">Body<br>
                    <div>
                        <input type="hidden" id="FCKeditor1" name="FCKeditor1" value="" style="display:none" />
                        <input type="hidden" id="FCKeditor1___Config" value="" style="display:none" />
                        <iframe id="FCKeditor1___Frame" src="fck_en/editor/fckeditor.html?InstanceName=FCKeditor1&amp;Toolbar=Default" width="500%" height="420" frameborder="yes" scrolling="no">
                        </iframe>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center" valign="top">
                    <input type="submit" name="send_e" value="Send" onclick="return confirm('are you sure you want to send this ?');">
                    <input type="reset" name="reset" value="Clear">
                </td>
            </tr>
        </form>
        <?php
        close_table
    ();
    }
    ?>
    One more question, i tested this code in 2 sites located in different servers. it works fine in one site, and it does not send in the other server although it gives success message but it didn't send an email. I also checked the bulk/junk folder, the email was n't sent at all.
    Any idea ?
    Thanks
    M
    Last edited by themoon; 08-15-2008 at 10:09 AM.

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,138
    Check the hosts FAQ on sending php mail. Some hosts have a strict policy and have extra functions to use before and after the send mail function.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  3. #3
    Join Date
    Nov 2005
    Posts
    223
    ok, thanks
    what about the problem of not being able to view the image that inserted by the editor. I keep getting something like an escape character like this: \"\"
    Thanks

  4. #4
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,138
    As I have never sent an image by mail using this method, I couldn't help you BUT... a search of this web forum will give you plenty of threads that do show you how.

    Or if you wait a while, someone may be able to point you to the appropriate help.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  5. #5
    Join Date
    Nov 2005
    Posts
    223
    anyone had experience in inserting an image via this editor ?

    thanks
    M

  6. #6
    Join Date
    May 2003
    Posts
    599
    this image you are previewing in the editor...it is on a website already, right? Your not relying on FCKeditor to do the upload for you, right?

    Also, when you view the source of the received email, are you at least seeing the img tag, where the image should be?
    We do precision guesswork

  7. #7
    Join Date
    Nov 2005
    Posts
    223
    yes, i'm not relying on the editor to upload the image. THe image is already on a webiste. i just put its path.
    And i don't find the image tag in the source code of the received email.
    I'm trying to find whichever possible way to send an email containing an image
    as a greeting card to my list of users.

    I'm not sure if there is a special header to be added in my php code.
    or there might be some configuration in fckeditor that allow you to upload and
    send images via the editor using php.

    Thanks in advance.

  8. #8
    Join Date
    Apr 2007
    Posts
    133
    firstly ensure the correct use of headers
    PHP Code:
    $message nl2br($message);
    $headers "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "From: mysite<info@mysite.co.uk>\r\n";
    $headers .= "Return-path: mysite<info@mysite.co.uk>\r\n";
    //$headers = "BCC: messagesent@mysite.com\r\n";

    // Send
    $rc mail($email$subject$message$headers); 
    Then in the message area ensure to include the full path src, html and body tags.

    The full 'Basic' code
    PHP Code:
    $message "<html><body background ='http://www.mysite.co.uk/images/grid_medblue.gif'><p><img src='http://www.mysite.co.uk/images/mysite.gif'><br /><br />Hello,</p><p>Have You taken a look at <a href='http://www.mysite.co.uk'>www.mysite.co.uk</a>. Take a look at <a href='http://www.mysite.co.uk/example.php'>www.mysite.co.uk/example.php</a> to see the site in full </p></body></html>";

    $message nl2br($message);
    $headers "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "From: mysite<info@mysite.co.uk>\r\n";
    $headers .= "Return-path: mysite<info@mysite.co.uk>\r\n";
    //$headers = "BCC: messagesent@mysite.com\r\n";

    // Send
    $rc mail($email$subject$message$headers);

    }
     if (
    $rc) {
    // what to do if sent 
    } else {
    failed etcerror reporting..................


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles