0

What I am trying to do is give my customers an option to e-mail me the items in their shopping cart without actually submitting an order.

Below is the closest I have been able to find

It will send an e-mail from a persons default mail client and it will send just the link to they page they are on. I need to send the e-mail without using their client much like submitting a form, and it needs to be the actual page not a link to it. Lastly I need to be able to place the link on a page other than the shopping cart.

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>My Page</title>
    <script language="javascript">
      function emailCurrentPage() {
        window.location.href = "mailto:?subject=" + document.title + "&body=" + escape(window.location.href);
      }
    </script>
  </head>
  <body>
    <a href="javascript:emailCurrentPage()">Mail this page!</a>
  </body>
</html>
buzzsawddog
  • 662
  • 11
  • 32
  • Could you compose the email on the server based on the data in the user's shopping cart? This lets you send the email from the server without the users inbox coming into play. Also, what are you trying to accomplish when your customer emails you the cart contents? – Surreal Dreams Oct 17 '13 at 20:40
  • Please don't use `javascript:` urls. Also, `mailto:` links are usually a bad idea - many people use webmail clients nowadays where they don't work. – ThiefMaster Oct 17 '13 at 20:46
  • @ThiefMaster I think that's a matter of opinion and depends on the scope of the project. Nearly 95% of our software is written internal and we use mailto: to open the mail client with a preloaded email... – buzzsawddog Oct 17 '13 at 20:50
  • What kind of backed server/application are you using? I would send the selections from the view back to your server and have it send your the email. Or perhaps just throw the orders in a Database and build a backed queue. Getting emails over and over is a pain, especially when some bot gets a hold of your script :-) – buzzsawddog Oct 17 '13 at 20:53
  • @ Surreal Dreams I should be able to compose the e-mail on the server but I do not know how. The idea is so I can calculate shipping on large orders which the shopping cart is very bad at doing. @ Buzzsawddog it is an apache server. I would be rather send the e-mail due to the fact that I need to be able to let other people see it easily – user2892138 Oct 17 '13 at 20:58
  • Are you using just plain coded HTML/PHP/JAVA/something else for server. – buzzsawddog Oct 17 '13 at 21:44
  • If you have PHP available check out http://php.net/manual/en/function.mail.php then use ajax to send the data to the mail application on your server. – buzzsawddog Oct 17 '13 at 21:46
  • Check out this SO question http://stackoverflow.com/questions/15300470/jquery-ajax-form-using-mail-php-script-sends-email-but-post-data-from-html-fo – buzzsawddog Oct 17 '13 at 21:47

1 Answers1

0

I would recommend you send an ajax request to a file on your site that can handle the mailing for you. Then from your server you can send all the mail you want.

For instance:

$.ajax({
    url : '/mail/inventory',
    dataType: 'json',
    type: 'POST',
    data : { title : 'your_title', message : 'your_message' }
});
Sawbones
  • 13
  • 5