How do I save the textarea (including any images) in WYMEditor using php

Just installed WYMEditor on a clients site. Using the 01-basic.html as the basis. My specific page is php, because I need to save the content to a MySql database field & mail() the content out.
here is the code:

ob_start(); // ensures anything dumped out will be caught

if(isset($_POST['new']) && $_POST['new']==1 && $errors =='')
$mm_date = date("Y-m-d H:i:s");
$body =$_REQUEST['body'];
$body = stripslashes($body);
$subject =$_REQUEST['subject'];
//send the email
// if ($_SESSION['username']<>'admin') {
$query = "SELECT email from users where username='".$_SESSION['username']."'"; 
$resultemail = mysql_query($query) or die ( mysql_error());
$rowemail = mysql_fetch_row($resultemail);
$too = $rowemail[0];
$from = $rowemail[0];

$username = $_SESSION['username'];

//send the email

                $to .= implode(", ", $_SESSION['emails']);
                $ffrom = "-f" . $from;
		$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';

$messageopen = "
<title>HTML email</title>

$messageclose = "

        $body = $messageopen.$body.$messageclose;

        $headers = "MIME-Version: 1.0" . "\r\n";
        $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

		$headers .= "From: $from \r\n";
        $headers .= 'BCC: '. implode(",", $_SESSION['emails']) . "\r\n";
		$headers .= "Reply-To: $from \r\n";
		$headers .= "Return-Path: <> /r/n";

                mail($too, $subject, $body, $headers, $ffrom);
        	while (ob_get_status()) 

$body = str_replace("'","`",$body);

                $ins_query="INSERT INTO mmerge(`mmdate`, `mmuser`, `mmsubject`, `mmbody`, `mmto`) VALUES ('$mm_date', '$username', '$subject', '$body', '$to')";
                mysql_query($ins_query) or die(mysql_error());
                header('Location: dashboard.php');
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="stylesheet" href="wymeditor/wymeditor/skins/default/skin.css">
    <link rel="stylesheet" href="css/simplestyle.css" /> 

<div class="ieform">

    <p><a href="">WYMeditor</a> is a web-based XHTML WYSIWYM editor.</p>
<form name="form" method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> 

<input type="hidden" name="new" value="1" />
<input type="text" name="subject" placeholder="Enter Subject*" size="30" required value="<?php echo $subject;?>" />
        <textarea name ="body" id="body" class="wymeditor">&lt;p&gt;Hello, World!&lt;/p&gt;</textarea>
        <input type="submit" class="wymupdate" value="Submit" />

    <script src="js/jquery.js"></script>
    <script src="wymeditor/wymeditor/jquery.wymeditor.js"></script>
    <script type="text/javascript">
$(document).ready(function() {

Open in new window

Except for the added Subject input, this is very similar to the example given.
What I need to do is assign the formatted textarea to the php variable $body.
It works, but only for the text, it doesn't contain the complete content, unlike the Preview button which is exactly what I want to send (including any images).

Russ CummingsIT ConsulantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Can you narrow down the question for us - it is not clear what you are asking. Reference to code and line numbers will help.

BTW I have added code tags to your post. Code tags make your code much easier to read and refer to - to add them highlight your code and click the CODE button in the toolbar.
Russ CummingsIT ConsulantAuthor Commented:
When using WYMEditor I can paste Images & formatted text. When using the "Preview" button everything looks as it should.
But when I look at the saved result, it doesn't include the pasted image.
What I need to do is take the preview page & send it as the $body of the email.
I'm trying to use the WYMEditor as you're able to paste & send images / text in Gmail.
Hope this helps,

Julian HansenCommented:
Ok, got it.
Two options

Option 1 (Recommended)
You need to make the src of the image an absolute URL - it can be to anywhere really - i.e. you can host the image anywhere - the absolute path means that wherever the email ends up it will be able to download the image and add it to the email

Option 2 (Not so much)
You can encode the image and embed it in the email using the base64 encoded format
<img src=" data:image/jpeg;base64...">

Open in new window

Sites like this one ( can do the encoding for you.

Why Option 1 over Option 2 - simple - bandwidth. Without the image the email is small and quick to send - the choice of downloading the image is in the hands of the recipient - who should be used to it as this is how the majority of email embedded images are sent.
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

Russ CummingsIT ConsulantAuthor Commented:
Those are not an easy possibility. Users will paste images & text into WYMEditor for the purpose of sending an email.
Specifically is the ANY way to capture the Preview page & send that as an email - because the Preview is exactly what is desired?
Julian HansenCommented:
I have given you the two options available.

Either you include a link to a browsable resource
Or you embed the image

That is it as far as embedding images in emails.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Russ CummingsIT ConsulantAuthor Commented:
Thank you Julian.
Julian HansenCommented:
You are welcome.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.