Click here to Skip to main content
14,773,218 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to forward an email based on the origin of a page, lets say I have 3 contact forms and I fill contact form 1 in. It'll send it to info@contactform1.com automaticly. If I fill in contact form 2, it sends automatically an email to info@contactform2.com. Is this possible in the email settings or do I need a javascript?

Thanks, Sam

What I have tried:

Only google but can't find the solution.
Posted
Updated 2-Jul-20 2:02am
Comments
Richard MacCutchan 2-Jul-20 5:07am
   
You need some code to do the actual sending of the message. It will not happen by magic.
Andre Oosthuizen 2-Jul-20 5:43am
   
Using google search, which is what you need to do this popped up as the first answer - https://pepipost.com/tutorials/how-to-send-emails-with-javascript/
F-ES Sitecore 2-Jul-20 7:00am
   
Javascript to send email that only needs you to put your username and password in the script. What could possibly go wrong :)
Sam Vorst 2-Jul-20 7:19am
   
Is it also possible with PHP? On each page mailto the right mailadress??
Andre Oosthuizen 2-Jul-20 7:27am
   
@F-ES, I was merely showing the ease of trying to do a search first before asking for help :)

You haven't given enough information for a proper answer, but assuming you have multiple forms all submitting to the same server-side page then add a "hidden" field to the form to indicate the source. Read the value of the hidden field in your page to know what form submitted it and change the destination address based on that.

<input type="hidden" value="form1" />
   
@Sam,

have a look at PHPMailer available on github.

It covers all grounds for sending mails, read through the documentation first to understand what it does, there are also plenty samples available.
   
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900