Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

PHP Contact Form Question?

I'm trying to make a contact form that emails. This code used to work and nothing about my server has changed but not so much anymore. If you guys could help I'd greatly appreciate it.

Code:

<?php

$name = $_POST['name'];

$email = $_POST['email'];

$subject = $_POST['subject'];

$message = $_POST['message'];

$to = "shadow_slayer15@yahoo.com";

$body =

<<<EOD

<br/><hr/><br/>

Name: $name<br/>

Email Address: $email<br/>

Subject: $subject<br/>

Message: $message<br/>

EOD;

$headers = "From: $email\r\n";

$headers .= "Content-Type: text/html\r\n";

$success = mail($to, $subject, $body, $headers);

$win = <<<EOD

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<link href="style.css" rel="stylesheet" type="text/css" media="screen" />

<title>Thank You for Your Email</title>

</head>

<body>

<div id="header">

<h2>Craig Spector</h2>

<nav>

<ul>

<li><a href="index.html">Home</a></li>

<li><a href="read.html">Read</a></li>

<li><a href="books.html">Books</a></li>

<li><a href="pov.html">POV</a></li>

<li><a href="av.html">A/V</a></li>

<li class="selected"><a href="contact">Contact</a></li>

</ul>

</nav>

<div id="head-gal">

<a href="http://www.facebook.com/craigspector%22%3E%3Cimg src="images/social-icons/facebook.png" width="100" height="100" alt="Facebook" /></a>

<a href="http://www.linkedin.com/in/craigspector%22%3E%3Cim... class="mid" src="images/social-icons/linkedin.png" width="100" height="100" alt="Linked In" /></a>

<a href="http://www.myspace.com/craigspector%22%3E%3Cimg class="left" src="images/social-icons/myspace.png" width="100" height="100" alt="Myspace" /></a>

</div><!-- end head-gal -->

</div><!-- end header -->

<div id="content">

<div id="inner-content">

<h2>Thank You for Contacting Me</h2>

<div class="padding"></div><!-- end padding -->

</div><!-- end inner content -->

</div><!-- end content -->

</body>

</html>

EOD;

echo $win;

?>

1 Answer

Relevance
  • 1 decade ago
    Favorite Answer

    1. don't think it's the problem; just a comment: i've not used <<EOD for multi-line strings, and never had trouble. just ' .. ' or " .. " works, no matter how many lines i have..

    i think your problem my be your mail server.

    - if it's a home server with a dynamic dns, you may have recently obtained an ip that has been used by a spammer

    - if it's a shared hosting server, one of the people you are sharing it with may be a spammer (shared hosting is usually cheap)

    - if you're using a shared hosting company with your own private ip, the server's mail server may still be shared

    - probably not your problem, but i have a home-based server & my isp blocks port 25 (used to send mail).

    i solved my problem by configuring sendmail to use a gmail account to send emails

    depending on your hosting, this may not be an option; to resolve this issue, you'd be best to contact your website host (if you're not doing it yourself)

Still have questions? Get your answers by asking now.