Afternoon from 11° about to rain York Uk
OK here goes … On this page http://cluster7.website-staging.uk/english-teacher-david.co.uk/ there is a contact submission form at the bottom of the page. The problem is it just hangs despite using a range of php files. I fear Ive done something wrong in terms of the form connecting to the right PHP script. Ive attached all the relevant files for anyone whos got the patience to figure this one out!
Thanks in advance,
David
index.html (17.5 KB)
Can you post the codes using the </>
icon? No one wants to download random files off the internet. It’ll also help us determine your problem without any lag time trying to download something we didn’t want to.
1 Like
The obvious observation is that you have PHPMailer, but your test mail script is using PHP mail()
. The likelihood is that your server is not sending the mail for that reason.
3 Likes
Thank you for taking time to look at this, I’m desperate to know how to fix it, you can see something but i need a clue of what to do next, shall i post the script options to attach to the form would that help?
The best place to find out how to use PHPMailer is in the GitHub repo .
Using PHPMailer takes quite a bit more code than using PHP’s mail()
function, but it has several advantages which I won’t elaborate on here.
Hi there Nightwing,
as a matter of interest this…
http://cluster7.website-staging.uk/english-teacher-david.co.uk/bat/rd-mailform.php
…gives a 404 Not Found
coothead
2 Likes
Thank you everyone for helping so far but I just need to clarify / illustrate some things that I hope will help solve the issue.
1 - Below are my script options to attach to the form. Could it be a case I have to pick one but the correct one that fits my hosting
2 - Once Ive got the right script i need to make sure the HTML points to that file (right now its pointing at "bat/mailtest.php )
3 - I’m a noob with php and I’m simply trying to put together a paid for template.
Here is my progress so far:
http://cluster7.website-staging.uk/english-teacher-david.co.uk/
Thanks in advance,
David
Hi there Nightwing,
PHP is not my forté so all I can do is point out that this…
http://cluster7.website-staging.uk/english-teacher-david.co.uk/bat/class.phpmailer.php
…shows this in Firefox’s Web developer Inspector…
<html class=" ide314 idc314">
<head></head>
<body></body>
</html>
Other than that I can tell you that it is at present…
17 ° and sunny in Chertsey, Surrey!
coothead
Thanks @coothead well ive since updated all the files (some were missing) the good news is ive got a message sent once the form is filled but my test emails haven’t landed yet but its progress
Ah 5° warmer nice, its grim up north
HI Guys,
Is the reason I’m not receiving any emails because all emails are ending up at $recipients = ‘test@demolink.com’;
Thanks in advance
<?php
$recipients = 'test@demolink.com';
try {
require './phpmailer/PHPMailerAutoload.php';
preg_match_all("/([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)/", $recipients, $addresses, PREG_OFFSET_CAPTURE);
if (!count($addresses[0])) {
die('MF001');
}
if (preg_match('/^(127\.|192\.168\.)/', $_SERVER['REMOTE_ADDR'])) {
die('MF002');
}
$template = file_get_contents('rd-mailform.tpl');
if (isset($_POST['form-type'])) {
switch ($_POST['form-type']){
case 'contact':
$subject = 'A message from your site visitor';
break;
case 'subscribe':
$subject = 'Subscribe request';
break;
case 'order':
$subject = 'Order request';
break;
default:
$subject = 'A message from your site visitor';
break;
}
}else{
die('MF004');
}
if (isset($_POST['email'])) {
$template = str_replace(
array("<!-- #{FromState} -->", "<!-- #{FromEmail} -->"),
array("Email:", $_POST['email']),
$template);
}else{
die('MF003');
}
if (isset($_POST['message'])) {
$template = str_replace(
array("<!-- #{MessageState} -->", "<!-- #{MessageDescription} -->"),
array("Message:", $_POST['message']),
$template);
}
preg_match("/(<!-- #{BeginInfo} -->)(.|\n)+(<!-- #{EndInfo} -->)/", $template, $tmp, PREG_OFFSET_CAPTURE);
foreach ($_POST as $key => $value) {
if ($key != "email" && $key != "message" && $key != "form-type" && !empty($value)){
$info = str_replace(
array("<!-- #{BeginInfo} -->", "<!-- #{InfoState} -->", "<!-- #{InfoDescription} -->"),
array("", ucfirst($key) . ':', $value),
$tmp[0][0]);
$template = str_replace("<!-- #{EndInfo} -->", $info, $template);
}
}
$template = str_replace(
array("<!-- #{Subject} -->", "<!-- #{SiteName} -->"),
array($subject, $_SERVER['SERVER_NAME']),
$template);
$mail = new PHPMailer();
$mail->From = $_POST['email'];
if (isset($_POST['name'])){
$mail->FromName = $_POST['name'];
}else{
$mail->FromName = "Site Visitor";
}
foreach ($addresses[0] as $key => $value) {
$mail->addAddress($value[0]);
}
$mail->CharSet = 'utf-8';
$mail->Subject = $subject;
$mail->MsgHTML($template);
$mail->send();
die('MF000');
} catch (phpmailerException $e) {
die('MF254');
} catch (Exception $e) {
die('MF255');
}```
I’m not sure what you’re asking. You’ve presumably tried changing that statement to your email address?
Looking at the above code, if i change $recipients = ‘test@demolink.com’; to my own email address i should receive the messages in my inbox?
(not sure how to say this any other way)
Success it all works now Thank you everyone for your help
2 Likes
system
Closed
August 3, 2020, 10:43pm
15
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.