Jaxal Posted December 10, 2006 Share Posted December 10, 2006 HiI downloaded a script to send emails. It works fine with just the message field. But i have added another field for address. This is where i am having a problem:function sendMail($name,$email,$message,[color=red]$message1[/color]){ $subject = "Message from website"; $from = "From: $name <$email>\r\nReply-To: $email\r\n"; $header = "MIME-Version: 1.0\r\n"."Content-type: text/html; charset=iso-8859-1\r\n"; $content = htmlspecialchars($message); $content = wordwrap($content,70); mail(MAIL_TARGET,$subject,$content,$from.$header);}message1 is what i added. But im not sure how to add it in the email. If i use the script as is, it just sends the message bit and not the address. If i do this:function sendMail($name,$email,$message,[color=red]$message1[/color]){ $subject = "Message from website"; $from = "From: $name <$email>\r\nReply-To: $email\r\n"; $header = "MIME-Version: 1.0\r\n"."Content-type: text/html; charset=iso-8859-1\r\n"; $content = htmlspecialchars($message); [color=red] $content = htmlspecialchars($message1); [/color] $content = wordwrap($content,70); mail(MAIL_TARGET,$subject,$content,$from.$header);}Then it just sends the address and not the message. How should i fix this? Link to comment https://forums.phpfreaks.com/topic/30156-including-the-address-and-message-field-in-email/ Share on other sites More sharing options...
drifter Posted December 10, 2006 Share Posted December 10, 2006 $content .= htmlspecialchars($message1); Link to comment https://forums.phpfreaks.com/topic/30156-including-the-address-and-message-field-in-email/#findComment-138608 Share on other sites More sharing options...
Jaxal Posted December 10, 2006 Author Share Posted December 10, 2006 Thanks for that drifter. For future reference, should i always do that to consolidate the content together? for example if i decide to add another field and call it message2, do i simply add the following?$content = htmlspecialchars($message);$content .= htmlspecialchars($message1);$content .= htmlspecialchars($message1);Also, now that its working, the email i recieve is like this:[b]This is my message message line 2 message line 3This is my address address line 2 address line 3[/b]This is the code that sends the email:sendMail($name,$email,$message,$message1);What should i add in there to make it come out in the proper way:This is my messagemessage line 2message line 3This is my addressaddress line 2address line 3 Link to comment https://forums.phpfreaks.com/topic/30156-including-the-address-and-message-field-in-email/#findComment-138622 Share on other sites More sharing options...
Jaxal Posted December 11, 2006 Author Share Posted December 11, 2006 Guys any help on this please? Link to comment https://forums.phpfreaks.com/topic/30156-including-the-address-and-message-field-in-email/#findComment-138899 Share on other sites More sharing options...
chiprivers Posted December 11, 2006 Share Posted December 11, 2006 I would imagine you just need to use some html formatting in your $content string (ie <br>) to add a new line where you want one? Link to comment https://forums.phpfreaks.com/topic/30156-including-the-address-and-message-field-in-email/#findComment-138901 Share on other sites More sharing options...
Jaxal Posted December 11, 2006 Author Share Posted December 11, 2006 Im getting $message and $message1 from a textbox. I thought that it would just add the text as the user inputs it but for some reason its not doing that. This is the code for the textbox:<tr><td>Message:</td><td class="error"><?php echo $error3; ?></td></tr><tr><td colspan="2"><textarea cols="40" rows="6" name="message"><?php echo $message; ?></textarea></td></tr><tr><td>Message1:</td><td class="error"><?php echo $error4; ?></td></tr><tr><td colspan="2"><textarea cols="40" rows="6" name="message1"><?php echo $message1; ?></textarea></td></tr>Is there something wrong with that code? Link to comment https://forums.phpfreaks.com/topic/30156-including-the-address-and-message-field-in-email/#findComment-138904 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.