Search code examples
phpemailmailto

mailto in PHP without a button click


Is there a way to cause an action similar to clicking a mailto link from withing PHP?

I would like it to use the local email client (e.g., outlook) to build and send several emails within a PHP controller. Then manually send each one thorough the client (that is, hit the send button on each window).

Is there a way to do that?


Solution

  • No, you cannot do this with PHP, because its a server side language and you want to perform an action on the client machine.

    You can do it with javascript however and generate the email content via PHP. You can create a regular <a> tag with a mailto: location and add the subject and body as params. Then you use the jquery click method to trigger the element and start e-mail client.

    (WARNING: Email Pop-up) A simple jsfiddle example