-1

I want to know how to attach HTML,CSS and JavaScript content to an email using the mail:to function? can it be done is JavaScript or does it need to be done in PHP? thanks in advance!

  • 2
    You cannot run Javascript in emails. – SLaks May 06 '14 at 14:25
  • JavaScript in emails is impossible, however you can write HTML and CSS in your email. Your 'message' part will be where your content is, thus you can add there html code and (either inline or just a style tag) CSS. It's logic. Email programs allow you to write a signature in HTML, so why cant your email be in HTML. Also most newsletters are HTML you receive over the email. – Dorvalla May 06 '14 at 14:27
  • Not possible, check http://stackoverflow.com/questions/5620324/mailto-with-html-body – Pranay Bhardwaj May 06 '14 at 14:51

1 Answers1

0

it does need to be done in php liike this hope it helps

<?php
 $to = "PUT_RECIPIENT_EMAIL_ADDRESS_HERE";
 $subject = "PUT_SUBJECT_HERE";
 $mail_body = '<html>
 <body bgcolor="#573A28" topmargin="25">
 Put HTML content here with variables from PHP if you like
  Variable display Example: ' . $subject . ' 
 </body>
  </html>';
 $headers  = "From:youremail@yoursite.comrn";
  $headers .= "Content-type: text/htmlrn";
mail($to, $subject, $mail_body, $headers);
 ?>
john uk1
  • 16
  • 5
  • definitely point me in the right direction, so where in the source code do i add this code? (sorry im a php noob) – Angel Garcia May 06 '14 at 15:13
  • anywhere really as long as the – john uk1 May 06 '14 at 15:15
  • i appreciate all the help but i seem to be doing something wrong, i wanted to post the code so maybe someone could point me in the right direction but code is too long to post, i have a button styled to send thje email but it doesn't do anything – Angel Garcia May 06 '14 at 15:25
  • i have a send button on the page how do i get it to interact with the php code? – Angel Garcia May 06 '14 at 18:21