i have a page that has a textarea (id="elm1")
i post this value to the same page when a submit page is clicked to send the value of the textarea in a html mail

the textarea will contain html code

but when i use it only the text comes in the mail no link is there and for image no image is displayed

anyone please help

Member Avatar for diafol

Can you supply all your relevant code?

Can you supply all your relevant code?

<html>
<head>
    
<!-- Load jQuery -->
<script type="text/javascript" src="../../jsdata/tinymce/jsapi"></script>
<script type="text/javascript">
    google.load("jquery", "1");
</script>

<!-- Load TinyMCE -->
<script src="../../jsdata/tinymce/jscripts/tiny_mce/jquery.tinymce.js" type="text/javascript"></script>
<script type="text/javascript">
    $().ready(function () {
        $('textarea.tinymce').tinymce({
            // Location of TinyMCE script
            script_url: '../../jsdata/tinymce/jscripts/tiny_mce/tiny_mce.js',

            // General options
            mode: "textareas",
            theme: "advanced",
            plugins: "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",

            // Theme options
            theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
            theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
            theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl",
            theme_advanced_buttons4: "moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
            theme_advanced_toolbar_location: "top",
            theme_advanced_toolbar_align: "left",
            theme_advanced_statusbar_location: "bottom",
            theme_advanced_resizing: true,

            // Example content CSS (should be your site CSS)
            content_css: "css/content.css",

            // Drop lists for link/image/media/template dialogs
            template_external_list_url: "lists/template_list.js",
            external_link_list_url: "lists/link_list.js",
            external_image_list_url: "lists/image_list.js",
            media_external_list_url: "lists/media_list.js",

            // Replace values for the template plugin
            template_replace_values: {
                username: "Some User",
                staffid: "991234"
            }
        });
    });
</script>
<!-- /TinyMCE -->

<script type="text/javascript">
     if (document.location.protocol == 'file:') {
         alert("The examples might not work properly on the local file system due to security settings in your browser. Please use a real webserver.");
     }
</script>
<link rel="shortcut icon" href="../../favicon.ico" type="image/x-icon" />
<link href="nindex.css" rel="stylesheet" type="text/css" />
<link href="nnews.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .tabnav
        {
            margin-left: 0px;
        }
        body
        {
            margin:0 0 0 0;
            }
        
        </style>
</head>

<body>

<?php
include('../../../php/Mail.php');	
require("PHPMailer/class.phpmailer.php");				 
if('POST' == $_SERVER['REQUEST_METHOD']) 
{ 
$message ="<html><body>".$_POST['elm1']."</body></html>";
$from = "Site Admin <username@sitename.co.in>"; 
$to = "TargetName <someone@gmail.com>"; 
$subject = "TRY 001";
$host = "webmail.sitename.co.in"; 
$username = "username@sitename.co.in"; 
$password = "password"; 
$headers = array ('From' => $from, 
'To' => $to, 
'Subject' => $subject,
'Content-Type' => "text/html",
'MIME-Version' => "1.0"); 
$smtp = Mail::factory('smtp', 
array ('host' => $host, 
'auth' => true, 
'username' => $username, 
'password' => $password)); 

if($mail = $smtp->send($to, $headers, $message))
{
echo "succcessful";
}
 
}					 

?>
<form name="form1" id="form1" action="" method="post">
    <!--body start -->
    <div id="body">
        <table cellpadding="0" cellspacing="0" class="style1">
            <tr>
                <td style="text-align: center">
                    <div id="success">You have not add any news yet...</div>
                </td>
            </tr>
            <tr>
                <td>
                    <table id="news" cellpadding="0" cellspacing="7" class="style1">
                        <tr>
                            <td valign="top" 
                                style="border-right-style: solid; border-right-width: 1px; border-right-color: #CCCCCC; padding-right: 7px;">
                                <table cellpadding="0" cellspacing="0" class="style1">
                                    <tr>
                                        <td valign="top">
                                            <div id="box">
[B]<!-- Gets replaced with TinyMCE, remember HTML in a textarea should be encoded -->[/B]
		                                <div>
                     <textarea id="elm1" name="elm1" cols="82" rows="30" class="tinymce">
                     </textarea>
[B]<!-- value of this elm1 textarea goes into the email body -->[/B]
		                                </div>
	                                         </div>                                              
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td width="264px" valign="top">
		            <input name="submit1" id="Submit1" type="button" value="submit" />
		            <input type="reset" name="reset" value="Reset"  />
                                                    

                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <br class="spacer" />
    </div>
    <!--body end -->
</form>
</body>
</html>
<html>
<head>
    
<!-- Load jQuery -->
<script type="text/javascript" src="../../jsdata/tinymce/jsapi"></script>
<script type="text/javascript">
    google.load("jquery", "1");
</script>

<!-- Load TinyMCE -->
<script src="../../jsdata/tinymce/jscripts/tiny_mce/jquery.tinymce.js" type="text/javascript"></script>
<script type="text/javascript">
    $().ready(function () {
        $('textarea.tinymce').tinymce({
            // Location of TinyMCE script
            script_url: '../../jsdata/tinymce/jscripts/tiny_mce/tiny_mce.js',

            // General options
            mode: "textareas",
            theme: "advanced",
            plugins: "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",

            // Theme options
            theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
            theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
            theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl",
            theme_advanced_buttons4: "moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
            theme_advanced_toolbar_location: "top",
            theme_advanced_toolbar_align: "left",
            theme_advanced_statusbar_location: "bottom",
            theme_advanced_resizing: true,

            // Example content CSS (should be your site CSS)
            content_css: "css/content.css",

            // Drop lists for link/image/media/template dialogs
            template_external_list_url: "lists/template_list.js",
            external_link_list_url: "lists/link_list.js",
            external_image_list_url: "lists/image_list.js",
            media_external_list_url: "lists/media_list.js",

            // Replace values for the template plugin
            template_replace_values: {
                username: "Some User",
                staffid: "991234"
            }
        });
    });
</script>
<!-- /TinyMCE -->

<script type="text/javascript">
     if (document.location.protocol == 'file:') {
         alert("The examples might not work properly on the local file system due to security settings in your browser. Please use a real webserver.");
     }
</script>
<link rel="shortcut icon" href="../../favicon.ico" type="image/x-icon" />
<link href="nindex.css" rel="stylesheet" type="text/css" />
<link href="nnews.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .tabnav
        {
            margin-left: 0px;
        }
        body
        {
            margin:0 0 0 0;
            }
        
        </style>
</head>

<body>

<?php
include('../../../php/Mail.php');	
require("PHPMailer/class.phpmailer.php");				 
if('POST' == $_SERVER['REQUEST_METHOD']) 
{ 
$message ="<html><body>".$_POST['elm1']."</body></html>";
$from = "Site Admin <username@sitename.co.in>"; 
$to = "TargetName <someone@gmail.com>"; 
$subject = "TRY 001";
$host = "webmail.sitename.co.in"; 
$username = "username@sitename.co.in"; 
$password = "password"; 
$headers = array ('From' => $from, 
'To' => $to, 
'Subject' => $subject,
'Content-Type' => "text/html",
'MIME-Version' => "1.0"); 
$smtp = Mail::factory('smtp', 
array ('host' => $host, 
'auth' => true, 
'username' => $username, 
'password' => $password)); 

if($mail = $smtp->send($to, $headers, $message))
{
echo "succcessful";
}
 
}					 

?>
<form name="form1" id="form1" action="" method="post">
    <!--body start -->
    <div id="body">
        <table cellpadding="0" cellspacing="0" class="style1">
            <tr>
                <td style="text-align: center">
                    <div id="success">You have not add any news yet...</div>
                </td>
            </tr>
            <tr>
                <td>
                    <table id="news" cellpadding="0" cellspacing="7" class="style1">
                        <tr>
                            <td valign="top" 
                                style="border-right-style: solid; border-right-width: 1px; border-right-color: #CCCCCC; padding-right: 7px;">
                                <table cellpadding="0" cellspacing="0" class="style1">
                                    <tr>
                                        <td valign="top">
                                            <div id="box">
[B]<!-- Gets replaced with TinyMCE, remember HTML in a textarea should be encoded -->[/B]
		                                <div>
                     <textarea id="elm1" name="elm1" cols="82" rows="30" class="tinymce">
                     </textarea>
[B]<!-- value of this elm1 textarea goes into the email body -->[/B]
		                                </div>
	                                         </div>                                              
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td width="264px" valign="top">
		            <input name="submit1" id="Submit1" type="button" value="submit" />
		            <input type="reset" name="reset" value="Reset"  />
                                                    

                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <br class="spacer" />
    </div>
    <!--body end -->
</form>
</body>
</html>

i am using tinymce to make a richtext html email

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.