0

trying to make a href link that will open a premade email with subject and body prefilled. the parameters are taken using php

the code below works in taking user email and writing the subject, but the body is also written in the subject line instead of the email body

how would i separate them?

<a href="mailto:<?php echo $v['email']; ?> ?subject=<?php echo "subject 
here"; ?> ?body=<?php echo "your email is approved"; ?>"><i class="icon- 
envelope"></i></a>
myo
  • 19
  • 4
  • 2
    try `&body=` instead of `?` – Jeff Jan 15 '19 at 16:47
  • You only need a single `?` to separate out the list of arguments from the "url" (or recipient, in this case). Actual arguments need to be separated by `&`. – aynber Jan 15 '19 at 16:47
  • Why would you do this with a `mailto:` link instead of just sending the mail from the server? – Barmar Jan 15 '19 at 16:50
  • @Barmar i cant figure out how to do that otherwise i would – myo Jan 15 '19 at 16:53
  • [how-to-send-an-email-using-php](https://stackoverflow.com/questions/5335273/how-to-send-an-email-using-php) – Jeff Jan 15 '19 at 16:54
  • @Jeff thank you that worked. is there a way the receiver would get a "fake" email sender like from admin@store.com instead of the actual person's gmail/outlook address? – myo Jan 15 '19 at 16:55
  • Use `&from=admin@store.com`. But this might not work depending on the sender's ISP. – Barmar Jan 15 '19 at 16:56
  • @Jeff thank you,i looked that up yesterday but this needs to be a button that someone click before the function executes – myo Jan 15 '19 at 16:56
  • @myo Why does that prevent doing it from PHP? Use AJAX to send a request to the server, then it sends the email. – Barmar Jan 15 '19 at 16:57
  • @Barmar i havent learned that ajax stuff yet – myo Jan 15 '19 at 16:58

1 Answers1

1

You have to use & rather than ? after the first usage. Like this:

<a href="mailto:<?php echo $v['email']; ?>?subject=<?php echo 'subject here'; ?>&body=<?php echo 'your email is approved'; ?>"><i class="icon-envelope"></i></a>
  • 1
    This isn't really worth an answer, it should just be closed as a typo after the comments that say this. – Barmar Jan 15 '19 at 17:02