PHP-FORM-EMAIL
josephkan
Posted messages
2
Status
Member
-
jordane45 Posted messages 30426 Registration date Status Moderator Last intervention -
jordane45 Posted messages 30426 Registration date Status Moderator Last intervention -
Hello,
I downloaded a template and modified it, now the forms do not redirect to the emails. I'm being asked to include a php-form-email library and I don't know how to create that. Can you help me with some code please?
1 answer
Hello, php-form-email library ... unknown to me ...
Who is the "one" you are talking about?
Are you working locally on your computer or are your pages hosted on a web server?
If "locally", what do you use to emulate a web server?
Where did you find this code? Can you share it with us?
Note: To show us your code, please follow this: https://codes-sources.commentcamarche.net/faq/11288-poster-un-extrait-de-code
.
Best regards,
Jordane
<?php
/**
* Nécessite la bibliothèque "PHP Email Form"
* La bibliothèque "PHP Email Form" n'est disponible que dans la version pro du modèle
* La bibliothèque doit être téléchargée dans : vendor/php-email-form/php-email-form.php
* Pour plus d'infos et d'aide : https://bootstrapmade.com/php-email-form/
*/
// Remplacez ***@*** par votre véritable adresse email de réception
$receiving_email_address = '***@***';
if( file_exists($php_email_form = '../assets/vendor/php-email-form/php-email-form.php' )) {
include( $php_email_form );
} else {
die( 'Impossible de charger la bibliothèque "PHP Email Form"!');
}
$contact = new PHP_Email_Form;
$contact->ajax = true;
$contact->to = $receiving_email_address;
$contact->from_name = $_POST['name'];
$contact->from_email = $_POST['email'];
$contact->subject = $_POST['subject'];
// Décommentez le code ci-dessous si vous souhaitez utiliser SMTP pour envoyer des emails. Vous devez entrer vos bonnes informations d'identification SMTP
$contact->smtp = array(
'host' => 'mail53.lwspanel.com',
'username' => '***@***',
'password' => 'mB4!_UWmJMGtTB@',
'port' => '587'
);
$contact->add_message( $_POST['name'], 'De');
$contact->add_message( $_POST['email'], 'Email');
$contact->add_message( $_POST['message'], 'Message', 10);
echo $contact->send();
?>
Well... first of all... you didn't read the link I gave you that explains how to post code correctly on the forum...
Then..... the answer to your question is in the comments of the code you downloaded:
Now, nothing prevents you from modifying the code and using the phpmailer library instead.
You will easily find it on the internet along with many examples on how to use it.