Jump to content

escaping inside mail() to add html


theredking

Recommended Posts

I'm a little stuck. I am new to this, so it is undoubtedly down to something I clearly do not understand.

 

I'm using mail() and am trying to email the contents of a form. I can do this successfully until I try and make what is emailed from that form a little more complicated. Right now I have:

mail( "me@myemail.com", "This is a test",
		 "Message goes here", 
	 "From:$first_name $last_name <$email>\r\nContent-type: text/html; charset=us-ascii");

 

This works as it should. In my

"Message goes here",

section I have listed the vars and text, as you might expect, and I am formatting it very basically with simple tags for line break, and strong text etc. The problem I have comes when I am trying to have it send the results of a number of checkboxes. I had a similar problem the other day, and when this problem arose I was offered this code:

foreach ($_POST['checkboxname'] as $value) {
echo "$value " ;
}

 

This worked fine, but I cannot get it to work within my page that has mail() in it. I'm sure this is not right, but I put this entire code inline where I wanted the checkbox array to be displayed. Should I put

foreach ($_POST['checkboxname'] as $value)

somewhere else, and then just reference the array with $value inside the mail() code with the other variables? I did try this, but it didn't work for some reason.

 

My other thought was to escape out of

"Message goes here",

and just put html code in, but if I do this, I get no message content at all.

 

I know I'm in over my head here, is there a solution? I'm slowly learning this...

 

Thank you in anticipation...

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.