Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

mail form problems

Featured Replies

Hi,

I've got a problem with mail form on my website. My website is on fasthosts.co.uk server. Looks like they've got some spam protection on server as if someone will put not real email address, I won't receive that email.

I would like to leave "email" address as optional, so if someone doesn't want to give me email details or won't fill "email" at all, I'll still receive email.

Please help. I checked many forms already...

I don't know php so I need solution not tip

 

thats my php file:

<?php

ini_set('sendmail_from', $email_from);

$email_to = "buy@tilesonlinestore.co.uk";

$name =$_POST['name'];

$email_from =$_POST['email'];

$email_subject = "e-mail from website";

$comments = $_POST['message'];

$headers =

"From: $email_from .\n";

"Reply-To: $email_from .\n";

 

/*Email checking*/

if (preg_match('/^[a-zA-Z0-9\._-]+@[a-zA-Z0-9\.-]+\.[a-zA-Z]{2,}$/', $email_from) == false)

{

echo 'Your email is not valid';

exit;

}

/*end of checking email*/

 

/*Now lets build the message of the email with the users name and comments.*/

 

$message= "Name: ". $name . "\nComments: " . $comments;

 

/*Finally, lets send the email. If the email is sent we will go to a thank you page, if there is an error we will display a brief message.*/

 

$sent = mail($email_to, $email_subject, $message, $headers, '-f' .$email_from);

if ($sent)

{

header( "Location: http://www.tilesonlinestore.co.uk/sent.htm" );

} else {

echo 'There has been an error sending your e-mail. Please try later.';

}

?>

Use a simple if statement to check whether the email was entered and, if it wasn't, change it to an email of your choice that you know exists:

 

if(empty($email_from))
{
$email_from = 'new email';
}

  • Author

can you point where I should copy that code?? can I leave all the rest like it is???

thank you

You could try just removing the code that checks for a valid email.

 

<?php
ini_set('sendmail_from', $email_from);
$email_to = "buy@tilesonlinestore.co.uk";
$name =$_POST['name'];
$email_from =$_POST['email'];
$email_subject = "e-mail from website";
$comments = $_POST['message'];
$headers =
"From: $email_from .\n";
"Reply-To: $email_from .\n";



/*Now lets build the message of the email with the users name and comments.*/

$message= "Name: ". $name . "\nComments: " . $comments;

/*Finally, lets send the email. If the email is sent we will go to a thank you page, if there is an error we will display a brief message.*/

$sent = mail($email_to, $email_subject, $message, $headers, '-f' .$email_from);
if ($sent)
{
header( "Location: http://www.tilesonlinestore.co.uk/sent.htm" );
} else {
echo 'There has been an error sending your e-mail. Please try later.';
}
?>

 

Pat

  • Author

Pat, I've tried that before. The problem is that if email doesn't really exist, I won't receive any email. That's some spam protection on my stupid server.

Also customer won't get any message that email wasn't send.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.