Jump to content

DeclineoftheWest

New Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by DeclineoftheWest

  1. Okay, I will learn phpmailer instead of using mail() and attempt to rewrite my previous code to replace phpmailer with the mail function and go over the previous thread before asking further. Thank-you.
  2. Interesting. Tried to send an email to outlook from the roundcube Webmail, and it says message failed, although sending to Outlook from Gmail works. Seems that if other clients used non major email clients, they would also fail. Hope this might add some insight, as-well.
  3. Okay, then, before we go further. I'm using the mail() function. I'm still learning php, but I'm doing the best I can. Sounds like, from my research, I'll have to use phpmailer, and somehow modify my form to work with phpmailer instead of using the mail() function. Not sure, but my client wants to use it, and it seems it's the only way he can transfer his old emails. I tried customer support, but after two hours, they just said that everything is working on their end, they can't help me with Outlook since it's not 'their end' and that I'd have to contact Outlook customer service, even though there's no such thing. Here's the code, by the way: <?php // define variables and set to empty values $name = $email = $phone = $city = $subject = ""; $nameErr = ""; $emailErr = ""; $phoneErr = ""; $subjectErr = ""; $sent = ""; $to = 'example@example.com'; $message= ''; $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $city = $_POST['city']; $subject = $_POST['subject']; foreach ($_POST as $key => $value) { $message .= '<strong>' . ucfirst($key) ."\r\n" . '</strong>' . ': ' . $value . '<br>' . PHP_EOL; } if ($_SERVER["REQUEST_METHOD"] == "POST") { $name = test_input($_POST["name"]); $email = test_input($_POST["email"]); $phone = test_input($_POST["phone"]); $city = test_input($_POST["city"]); $subject = test_input($_POST["subject"]); } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n" . "From:" .$name ."<" .$email ."\r\n"; $headers = 'Content-type: text/html; charset=iso-8859-1' . "From: example@example.com\r\n"; if ($_SERVER["REQUEST_METHOD"] == "POST" AND empty($_POST["name"])) { $nameErr = "Name is required"; } if ($_SERVER["REQUEST_METHOD"] == "POST" AND empty($_POST["email"])) { $emailErr = "Email is required"; } if ($_SERVER["REQUEST_METHOD"] == "POST" AND empty($_POST["subject"])) { $subjectErr = "Subject is required"; } if ($_SERVER["REQUEST_METHOD"] == "POST" AND !(preg_match("/^[a-zA-Z-' ]*$/",$name))) { $nameErr = "Name cannot contain any special characters"; } if ($_SERVER["REQUEST_METHOD"] == "POST" AND !filter_var($email, FILTER_VALIDATE_EMAIL)) { $emailErr = "Invalid email format"; } if ($_SERVER["REQUEST_METHOD"] == "POST" AND !empty($_POST["name"]) AND !empty($_POST["email"]) AND !empty($_POST["subject"]) AND (preg_match("/^[a-zA-Z-' ]*$/",$name)) AND (filter_var($email, FILTER_VALIDATE_EMAIL))) { mail($to, $subject, $message, $headers); $sent = '<div class="sent-message">'. "Thankyou for contacting us!". '</div>'; } ?> I didn't include the actual html form below the php, since it's for my client and has his website info, but I can include it if it helps.
  4. Hi there. I'm working on my first web contract for a client. We switched to Godaddy, and he wants to use the linked Outlook account that comes with it. Unfortunately, the php contact form I created, doesn't seem to be going through to Outlook. The contact form successfully sends emails to the roundcube webmail, and to gmail. I've also tried email forwarding using roundcube to Outlook, but I still can't receive any emails. Some research about this seems to indicate I need to modify SPF or DNS settings. Is this true, or any advice on how I can get this working? Thanks for reading.
  5. I implemented most of the points you suggested, although I am still working on the last three, but my employer seems happy with this first contract, and this is the final step. My only problem now is that I can't get the php contact form to send to the linked Outlook account provided by Godaddy. I can get it to send to the roundcube webmail provided by Godaddy and Gmail accounts, but Outlook is not receiving any emails. From what I've researched, this might have something to do with modifying the DNS or SPF.. although I can't say for certain. Any ideas here on how I can get Outlook to accept the emails from the contact form, if every other client has no problem? Also, I appreciate your long and detailed response. Is there any way to donate to you for your help? Thanks.
  6. Cool. I got everything to work. One last question, since this is for a client. Do I have to sanitize the php, or add some sort of captcha to prevent people from hacking or malicious code? Thank-you for your help.
  7. Not sure what you mean by from address that exists at the web hosting? I changed my code to this. Is this not correct? I'm not very good at coding, by the way: <?php $to = 'example@example.com'; $message= ''; $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $city = $_POST['city']; $subject = $_POST['subject']; foreach ($_POST as $key => $value) { $message .= '<strong>' . ucfirst($key) ."\r\n" . '</strong>' . ': ' . $value . '<br>' . PHP_EOL; } $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n" . "From:" .$name ."<" .$email ."\r\n"; $headers = "From: example@example.com\r\n"; mail($to, $subject, $message, $headers); header('../index.html'); echo' <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Contact form</title> <link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600&family=Poppins&display=swap" rel="stylesheet"> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <h1>Thank you for contacting us. We will get back to you as soon as possible!</h1> <p class="back">Go back to the <a href="../index.html">homepage</a>.</p> </div> </body> </html> '; ?>
  8. Hi there. I'm working on my first project for a client for html / css, and I've had to learn PHP to finish a contact form for the website. So, I spent some time and finally got a php form to work that sends an email (although in GMAIL it does go to spam). It seems to work on all other web hosts, but with Godaddy it doesn't send any emails. I've tried other php contact forms and they don't work either. Any ideas on what is going on? My forms uses the mail function, and from research a lot of people seem to have this problem, but customer service is useless. Here is the code for my contact form, although, I doubt it will matter since no php form seems to work: <?php $to = 'example@example.com'; $message= ''; $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $city = $_POST['city']; $subject = $_POST['subject']; foreach ($_POST as $key => $value) { $message .= '<strong>' . ucfirst($key) ."\r\n" . '</strong>' . ': ' . $value . '<br>' . PHP_EOL; } $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n" . "From:" .$name ."<" .$email ."\r\n"; mail($to, $subject, $message, $headers); header('../index.html'); echo' <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Contact form</title> <link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600&family=Poppins&display=swap" rel="stylesheet"> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <h1>Thank you for contacting us. We will get back to you as soon as possible!</h1> <p class="back">Go back to the <a href="../index.html">homepage</a>.</p> </div> </body> </html> '; ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.