Author Topic: php mail  (Read 3178 times)

Offline mdemaree99

  • Posts: 102
php mail
« on: January 03, 2012, 01:09:46 AM »
Anybody have some info on $message in the mail script?
Code: [Select]
mail($to, $subject, $message, $headers);
I have tried mass mail programs out there already and they work great except I have 3 classes of users that I need to email individually or multiple at times and pulling email addresses off of an access database.   Everything works except when I go to send an email in HTML. 


I can pass HTML if I use

Code: [Select]
$message = '<html>  <body bgcolor="#DCEEFC"><center><b>Looool!!! I am reciving HTML email......</b> <br>        <font color="red">Thanks Mohammed!</font> <br>     <a href="http://www.maaking.com/">* maaking.com</a>    </center>      <br><br>*** Now you Can send HTML Email <br> Regards<br>MOhammed Ahmed - Palestine<br><p>this is my email</p><p><strong>Bold<br /></strong></p><p><span style="color: rgb(255, 0, 0);">Change color</span></p><p><strong><span style="color: rgb(0, 255, 0);">Image</span></strong><span style="color: rgb(255, 102, 0);"><br /></span></p><p>&nbsp;</p><p>&nbsp;</p></body></html>';
But when I try and $message from a form I get bold, but no color or links for files.

Code: [Select]
$message = $_POST['message'] ;  

<textarea name='message' type='text' rows='20' cols='60'></textarea>


full code below

Code: [Select]


    $to = $_POST['toemail'];
    $from = 'me@yahoo.com' ;
    $subject = $_POST['subject'];

//Message is taken from form here.  Does not work
    $message =   $_POST['message'] ;
     
    $headers  = "From: $from\r\n";
    $headers .= "Content-type: text/html\r\n";
 
 //options to send to cc
   $ccemail = $_POST['ccemail'] ;
    if ($ccemail<>'')
       { $headers .= "Cc: $ccemail\r\n"; }
   
 //options to send bcc
  $bccemail = $_POST['bccemail'] ;
  $headers .= "Bcc: $bccemail\r\n";

if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form


// FORM to input data for email
//Predefines fields for the form
 $toemail = 'mdemaree99@yahoo.com';
 $ccemail = '';
// $bccemail = $bccquery;


echo ("  <table>  ");
echo (" <form method='post' action=$PHP_SELF>  ");

echo (" <tr><td valign='top'>   TO:      </td>   ");
echo (" <td> <textarea name='toemail' type='text' rows='1' cols='60'  />$toemail</textarea></td></tr>  ");

echo (" <tr><td valign='top'>   CC:     </td> ");
echo ("<td> <textarea name='ccemail' type='text' rows='1' cols='60' />$ccemail</textarea></td></tr>  ");

echo (" <tr><td valign='top'>   BCC:     </td> ");
echo ("<td> <textarea name='bccemail' type='text' rows='4' cols='60' />$bccemail</textarea></td></tr>  ");

echo (" <tr><td valign='top'>   SUBJECT: </td> ");
echo ("<td> <textarea name='subject' type='text' rows='1' cols='60' /></textarea></td></tr>  ");


echo (" <tr><td valign='top'>   BODY:    </td> ");
echo ("<td> <textarea name='message' type='text' rows='20' cols='60'></textarea>");

 
echo (" <tr><td colspan='2' style='text-align: center;'> <input type='submit' value='Send Email' name='submit'></td></tr> ");
echo ("  </table>  ");   
 


//Send email once email is complete and Send Email clicked

} else {   
       
       //change this to your email.
    $to = "mdemaree99@yahoo.com";
    $from = "mdemaree99@yahoo.com";
    $subject = "Hello! This is HTML email";

//IF previous $message is removed and comments taken out this will dislay email in HTML

//$message = '<html>  <body bgcolor="#DCEEFC"><center><b>Looool!!! I am reciving HTML email......</b> <br>        <font color="red">Thanks Mohammed!</font> <br>     <a href="http://www.maaking.com/">* maaking.com</a>    </center>      <br><br>*** Now you Can send HTML Email <br> Regards<br>MOhammed Ahmed - Palestine<br><p>this is my email</p><p><strong>Bold<br /></strong></p><p><span style="color: rgb(255, 0, 0);">Change color</span></p><p><strong><span style="color: rgb(0, 255, 0);">Image</span></strong><span style="color: rgb(255, 102, 0);"><br /></span></p><p>&nbsp;</p><p>&nbsp;</p></body></html>';
 $message = $_POST['message'] ;
 
   //end of message
    $headers  = "From: $from\r\n";
    $headers .= "Content-type: text/html\r\n";

   
    // now lets send the email.
    mail($to, $subject, $message, $headers);
    echo "Message has been sent....!";     
             
         }

Offline mdemaree99

  • Posts: 102
Re: php mail
« Reply #1 on: January 04, 2012, 03:21:20 PM »
Solution Found..
It seems that when put to post there is a backslash added to each "

Next step.. get fckeditor working for the text box. 

Code: [Select]
$message = $_POST['message'] ;
$message = stripslashes($message);

 

postern-length