我從HTML表單發送PHP電子郵件時遇到了一些問題。你們能幫我嗎?我在$發送變量中的'else'中遇到錯誤。爲什麼這個PHP電子郵件腳本不工作?
的目錄中進行這樣的:
Site
--> HTML
--> webpage.html
--> PHP
--> emailform.php
,它的發現PHP文件的事實似乎是這部分的確定。我不確定是什麼導致它不發送電子郵件。我正在使用免費的網絡主機。也許這是問題?
HTML:
<form method="post" action="../PHP/emailform.php" style="width:300px; float:left; margin-top: 50px;">
<div><div>
Navn: <input type="text" name="navn" style="float:right;"/>
</div><br /><div>
Telefonnummer: <input type="text" name="telefon" style="float:right;"/>
</div><br /><div>
Email: <input type="text" name="email" style="float:right;"/>
</div><br /><div>
Bosted: <input type="text" name="bosted" style="float:right;"/>
</div><br /><div>
iPhone-modell: <select name="iphonetype" style="float: right;">
<option value="iphone2G">iPhone 2G</option>
</select>
</div></div><br />
Reparasjoner:<div style="float:right; clear: both;">Bytte LCD/skjerm (1200,-)
<input type="checkbox" name="lcdglass" />
</div><div style="float:left; padding-top:12px;">
Andre kommentarer: <textarea name="kommentarer" cols="34" rows="3"></textarea>
</div><br /><div style="float: left; margin-top: 12px;">
<input type="submit" name="send" value="Send henvendelse" />
</div>
</form>
PHP:
<?php
$to = "[email protected]";
$subject = $_REQUEST['iphonetype'] . " reparasjon fra mysite.no";
$email = $_REQUEST['email'];
$message = "Navn: " . $_REQUEST['navn'] . "\nTelefonnummber: " . $_REQUEST['telefon'] . "\nBosted: " . $_REQUEST['bosted'] . "\nLCD/Glass " . $_REQUEST['lcdglass'] . "\nKommentarer: " . $_REQUEST['kommentarer'] . "\n\nMvh,\n" . $_REQUEST['navn'] . "\n" . $_REQUEST['telefon'];
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers) ; if($sent) {print "Takk. Din henvendelse er mottatt. Du kan fovente å få svar innen 24 timer."; } else {print "Dessverre oppstod det en feil. Kontakt [email protected] direkte for reparasjon."; }
?>
我真的希望你們能幫助我找到錯誤。謝謝!
您是從本地主機還是從遠程主機/服務器發送它? – metaforce 2011-06-10 11:07:53
什麼是錯誤?您有權訪問通過其發送郵件的SMTP服務嗎? – David 2011-06-10 11:09:11
那麼,我只是使用免費的虛擬主機awardspace.com發送它.. – DarkLightA 2011-06-10 11:28:48