I am new to WordPress. I have created a custom template with a form. This form will get information like first name, last name, and message from visitors. I want to forward this visitor information to another email such as "firstname.lastname@example.org". This email address will be a dynamic one. How can I do this in WordPress? Thanks in advance.
The easy way would install this plugin - https://da.wordpress.org/plugins/contact-form-7/ - It's super easy to work with, and it will do what you want :)
If you don't want to use a plugin, then you would just code a contact form with html and php.
<?php $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $from = $_POST['email']; $message = $_POST['textarea']; $to = "email@example.com"; $subject = "My subject"; $message = "Hello world!"; $headers = "From: " . $email . "\r\n" . "CC: firstname.lastname@example.org"; mail($to,$subject,$message,$headers); ?>
<form action="" method="post"> First name:<br> <input type="text" name="firstname"> <br> Last name:<br> <input type="text" name="lastname"> <br> Email: <br> <input type="email" name="email"> <br> Subject:<br> <input type="text" name="subject"> <br> Message:<br> <textarea name="textarea" id="" cols="30" rows="10"></textarea> <br> <input type="submit" value="Submit"> </form>