Jump to content

Including the address and message field in email


Jaxal

Recommended Posts

Hi

I 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?
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 message
message line 2
message line 3

This is my address
address line 2
address line 3
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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.