Attach mailto-html files

-1

I need to send emails in my PHP application but they should not be sent automatically but the default web client should be opened in order to see the content of the message and be able to modify it if necessary. I've been using the html mailto function.

The reason why I open the mail client instead of sending the email directly with PHP is because the client to whom I am developing the application has asked me so and as they say, " the client always It's right ". Given that there is no other way to open the mail client than mailto, my question is:

How can I attach one or more files with mailto?

I explain what my application does a little: it is a task manager where when creating a task, an email must be sent to the users to whom this task has been assigned. To the task you can attach files that are the ones that should be sent by email. Those files are saved in a folder in C :, the directory that I have put in mailto (C: \ hello.txt) is a test but the file hello.txt if it is in the.

Using

mailto:'.$emails_invitados.'?subject='.$nombreTa‌rea.'&body='.$observacionesT‌​area.'&attachment="C:\hola.txt" '

I have managed to open the mail client but the file is not attached correctly.

    
asked by Felipe Ruiz 18.08.2016 в 08:40
source

1 answer

0
  

mailto allows you to specify subject and body, as well as cc fields.

For example:

mailto:[email protected]?subject=Subject&body=message%20goes%20here

The user does not need to click on a link if he forces it to open with JavaScript.

 window.location.href = "mailto:[email protected]?subject=Subject&body=message%20goes%20here";
  

Please note that there is only one way, standard in which browsers / email clients handle mail links (for example, subject and body fields can be discarded without a warning).

     

There is also a risk that emerging and ad blocking, anti-virus software, etc. You can block the opening of forced mailto links.

Example 2.

JQuery

 $(function () {
      $('.SendEmail').click(function (event) {
        var email = '[email protected]';
         var subject = 'Test';
         var emailBody = 'Hi Sample,';
         var attach = 'path';
         document.location = "mailto:"+email+"?subject="+subject+"&body="+emailBody+"?attach="+attach;
         });
     });

HTML:

   <button class="SendEmail">Send Email</button>
    
answered by 19.08.2016 в 11:34