Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is this php script not mailing me?
    text
    copied!<p>I'm running the example from chapter 1 in Head First's PHP and MySQL. I placed the files on Head Fist's site on apache's /var/www folder and the thing runs. Yet, why isn't php's mailto working?</p> <p>edit: btw, I'm working on Ubuntu 10.04 </p> <p>I added two debugging lines to the script:</p> <pre><code>$testmail = mail($to, $subject, $msg); echo 'WAS IT MAILED? &lt;br /&gt;'.$testmail; </code></pre> <p><strong>Why isn't printing <code>WAS IT MAILED? TRUE</code>? Why isn't it mailing?</strong></p> <p><strong>Edit: Is the fact that I'm mailing to my gmail address relevant?</strong></p> <p>Here's the script:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Aliens Abducted Me - Report an Abduction&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h2&gt;Aliens Abducted Me - Report an Abduction&lt;/h2&gt; &lt;?php $name = $_POST['firstname'] . ' ' . $_POST['lastname']; $when_it_happened = $_POST['whenithappened']; $how_long = $_POST['howlong']; $how_many = $_POST['howmany']; $alien_description = $_POST['aliendescription']; $what_they_did = $_POST['whattheydid']; $fang_spotted = $_POST['fangspotted']; $email = $_POST['email']; $other = $_POST['other']; $to = 'antoniorueda18@gmail.com'; $subject = 'Aliens Abducted Me - Abduction Report'; $msg = "$name was abducted $when_it_happened and was gone for $how_long.\n" . "Number of aliens: $how_many\n" . "Alien description: $alien_description\n" . "What they did: $what_they_did\n" . "Fang spotted: $fang_spotted\n" . "Other comments: $other"; $testmail = mail($to, $subject, $msg); echo 'WAS IT MAILED? &lt;br /&gt;'.$testmail; echo 'Thanks for submitting the form.&lt;br /&gt;'; echo 'You were abducted ' . $when_it_happened; echo ' and were gone for ' . $how_long . '&lt;br /&gt;'; echo 'Number of aliens: ' . $how_many . '&lt;br /&gt;'; echo 'Describe them: ' . $alien_description . '&lt;br /&gt;'; echo 'The aliens did this: ' . $what_they_did . '&lt;br /&gt;'; echo 'Was Fang there? ' . $fang_spotted . '&lt;br /&gt;'; echo 'Other comments: ' . $other . '&lt;br /&gt;'; echo 'Your email address is ' . $email; ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And here's the html form:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Aliens Abducted Me - Report an Abduction&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="style.css" /&gt; &lt;/head&gt; &lt;body&gt; &lt;h2&gt;Aliens Abducted Me - Report an Abduction&lt;/h2&gt; &lt;p&gt;Share your story of alien abduction:&lt;/p&gt; &lt;form method="post" action="report.php"&gt; &lt;label for="firstname"&gt;First name:&lt;/label&gt; &lt;input type="text" id="firstname" name="firstname" /&gt;&lt;br /&gt; &lt;label for="lastname"&gt;Last name:&lt;/label&gt; &lt;input type="text" id="lastname" name="lastname" /&gt;&lt;br /&gt; &lt;label for="email"&gt;What is your email address?&lt;/label&gt; &lt;input type="text" id="email" name="email" /&gt;&lt;br /&gt; &lt;label for="whenithappened"&gt;When did it happen?&lt;/label&gt; &lt;input type="text" id="whenithappened" name="whenithappened" /&gt;&lt;br /&gt; &lt;label for="howlong"&gt;How long were you gone?&lt;/label&gt; &lt;input type="text" id="howlong" name="howlong" /&gt;&lt;br /&gt; &lt;label for="howmany"&gt;How many did you see?&lt;/label&gt; &lt;input type="text" id="howmany" name="howmany" /&gt;&lt;br /&gt; &lt;label for="aliendescription"&gt;Describe them:&lt;/label&gt; &lt;input type="text" id="aliendescription" name="aliendescription" size="32" /&gt;&lt;br /&gt; &lt;label for="whattheydid"&gt;What did they do to you?&lt;/label&gt; &lt;input type="text" id="whattheydid" name="whattheydid" size="32" /&gt;&lt;br /&gt; &lt;label for="fangspotted"&gt;Have you seen my dog Fang?&lt;/label&gt; Yes &lt;input id="fangspotted" name="fangspotted" type="radio" value="yes" /&gt; No &lt;input id="fangspotted" name="fangspotted" type="radio" value="no" /&gt;&lt;br /&gt; &lt;img src="fang.jpg" width="100" height="175" alt="My abducted dog Fang." /&gt;&lt;br /&gt; &lt;label for="other"&gt;Anything else you want to add?&lt;/label&gt; &lt;textarea id="other" name="other"&gt;&lt;/textarea&gt;&lt;br /&gt; &lt;input type="submit" value="Report Abduction" name="submit" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload