-1

Currently I have a project I am working on. The page I am trying to develop is a custom user driven page.

basically the content goes like this

general user info(eg name, date, email etc)

blank div space to generate content with(this is used as a basis so i can set an incremental id

(product 1 with info(set size, set price, etc)

add a product button(then a 2nd,3rd or however many product will apear)

My question is. How would 1 go about using this info to send it via a php email. Would you use a for loop would you turn it into an array i have no idea where to start my current code is below.

         <div class="addsection">this will be left blank </div>
            <button id="addbutton" class="btn btn-default">Add a product</button>
            <script>$('#addbutton').on('click', function () {

                    var count = $('div.addsection div').length, id = count + 1;

                    $('div.addsection').append('<div id="' + id + '">this is where my sourced content will go</div>');
                    event.preventDefault();
                });</script>

Any help would be extremely appreciated. Thanks :)

mattyp
  • 32
  • 6

1 Answers1

0

First off, your JavaScript won't run in an HTML e-mail. There's nothing you can do about this.

Use a server-side template engine (either in PHP or JavaScript on Node.js or equivalent) to generate your HTML. Then, use a well-known library for sending your HTML e-mail. This is important... crafting your own multipart MIME messages is a nightmare nobody should have to deal with. In PHP, that's PHPMailer or SwiftMailer. (There are others as well.)

Also note that HTML e-mail compatibility is also a nightmare. If you're doing anything at all beyond basic text formatting, consider a service such as Litmus which allows you to preview your e-mails in a variety of popular e-mail clients.

Brad
  • 159,648
  • 54
  • 349
  • 530
  • oh i forgot to mention this is on a php page that section is only used to generate the html code for the page not to create the email like you are suggesting. i know emails are finiky. and i cant use litmus as they are only a plugin and the content for the email is customised and litmus like others only recognise certain variables at a time. this page is for a user form. – mattyp Apr 27 '17 at 01:34
  • @slyk_style You can absolutely use Litmus... they have an option for pasting in the HTML that you would send. Generate a few of your custom e-mails, paste the HTML, and let it test. – Brad Apr 27 '17 at 01:39
  • ill give it a go but im going to see php http://stackoverflow.com/questions/5335273/how-to-send-an-email-using-php the only issue i have at the moment is to generate the html because the content on the page is custom generated like i showed in my sample code. – mattyp Apr 27 '17 at 01:49