【问题标题】:PHP script to send contact form to inbox将联系表格发送到收件箱的 PHP 脚本
【发布时间】:2013-07-04 21:08:05
【问题描述】:

我创建了一个联系表单,我希望在单击提交按钮后将详细信息发送到我的收件箱。单击提交按钮会打开一个新的邮件页面(参见 getfreepack.org)。我被告知我需要一个 PHP 脚本。我从网上复制了一个,但不太清楚如何利用它来发挥我的优势。非常感谢您的帮助。

$Name= $_REQUEST["Name"]; 
$Email = $_REQUEST["Email"]; 
$Phone = $_REQUEST["Phone"]; 
$JobTitle = $_REQUEST["Jobtitle"]; 
$KeySkills = $_REQUEST["Keyskills"]; 
$Attachment = $_REQUEST["Attachment"]; 

$to = "my email address@mail.com"; 
$subject = "Contact Form"; 

$message = "Name: " . $Name $message .= "\Email: " . $Email: $message .= "\n Phone: " . $ Phone; 
$message .= "\nSubject: " . $Subject; $message .= "\nCover Letter: " . $CoverLetter; 
$message .= "\n Attachment: " . $Attachment; $message .= "\nIP Adress: " . $_SERVER['REMOTE_ADDR']; 
$message .= "\nBrowser: " . $_SERVER['HTTP_USER_AGENT']; 
$message .= "\n\nMessage: " . $theMessage; 

$headers = "From: $theEmail";
$headers .= "\nReply-To: $theEmail"; 

$sentOk = mail($to,$subject,$message,$headers); 
echo "sentOk=" . $sentOk;

【问题讨论】:

标签: php html


【解决方案1】:

一个非常基本的方法是:

<?php
 $to = "someone@example.com";
 $subject = "Test mail";
 $message = "Hello! This is a simple email message.";
 $from = "someonelse@example.com";
 $headers = "From:" . $from;
 mail($to,$subject,$message,$headers);
 echo "Mail Sent.";
?> 

如果您想更进一步,请查看手册:http://php.net/manual/en/function.mail.php

干杯

【讨论】:

  • 他说,因为 w3schools 包含很多不是最新的信息,可能会给学习者带来问题,他们只是想成为第一个出现在 google 搜索中的人。
  • removed...;)...刚刚看到了 w3fools..:)
  • 谢谢罗伊。假设我使用上面的代码,我的联系表 (getfreepack.org) 上的所有信息,即 Name= Email= Phone= Job title= Key Skills= Attachment= 会被捕获并发送给我吗??
【解决方案2】:

您不需要 php 来获取发送到您的电子邮件地址的表单,使表单标记如下:

>>action="mailto:yourremailaddress@whatever.com"> 输入 输入

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-10
    • 1970-01-01
    • 2015-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多