php 如何实现将表单直接发送到制定邮箱??
展开全部
首先你的php必须有email组建
一般常用的是 jmail
<?
class Jmail
{
public $Username; //邮局用户名
public $Password; //密码
public $FormName ; //发件人姓名
public $From ; //发件人地址
public $Addrecipient ; //收件人地址
public $Ttile ; //邮件标题
public $Content; //邮件内容
public $Smtp; //邮件服务器
function Send(){
$Jmail = new com("Jmail.Message"); //实例化一个Jmail对象
$Jmail->SiLent=true; //设置成True的话Jmail不会提示错误只会返回True和False
$Jmail->LogGing = false; //是否开启日志
$Jmail->CharSet = "GB2312"; //设定字符串编码
$Jmail->ContentType = "Text/html"; //邮件的格式为HTML格式
$Jmail->MailServerUsername = $this->Username; //发信箱用户名
$Jmail->MailServerPassword = $this->Password; //发信箱密码
$Jmail->FromName = $this->FromName; //发件人姓名
$Jmail->From = $this->From; //发件人地址
$Jmail->AddRecipient($this->Addrecipient); //收件人地址
$Jmail->Subject = $this->Title;//Email标题
$Jmail->Body = $this->Content; //Email正文
$JmailError = $Jmail->Send($this->Smtp); //Smtp服务器
if($JmailError){ //判断邮件是否发送成功
return true;
}else{
return false;
}
}
}
//这里是调用代码
$jmail = new Jmail();
$jmail->Username = ""; //这里是smtp的帐号
$jmail->Password = "";//这里是smtp的密码
$jmail->FromName = "";//这里是邮件显示的名字
$jmail->From = "";//这里填写你发送的邮件地址
$jmail->Addrecipient = ""; //这里填写你目标的邮件地址
$jmail->Title = "这是标题";
$jmail->Content = "";//这里就是你表单里面面的悲痛
$jmail->Smtp = "";//这里是你邮件的smtp地址
if($jmail->Send()){
echo "成功哦!";
}else{
echo "失败哦!";
}
?>
一般常用的是 jmail
<?
class Jmail
{
public $Username; //邮局用户名
public $Password; //密码
public $FormName ; //发件人姓名
public $From ; //发件人地址
public $Addrecipient ; //收件人地址
public $Ttile ; //邮件标题
public $Content; //邮件内容
public $Smtp; //邮件服务器
function Send(){
$Jmail = new com("Jmail.Message"); //实例化一个Jmail对象
$Jmail->SiLent=true; //设置成True的话Jmail不会提示错误只会返回True和False
$Jmail->LogGing = false; //是否开启日志
$Jmail->CharSet = "GB2312"; //设定字符串编码
$Jmail->ContentType = "Text/html"; //邮件的格式为HTML格式
$Jmail->MailServerUsername = $this->Username; //发信箱用户名
$Jmail->MailServerPassword = $this->Password; //发信箱密码
$Jmail->FromName = $this->FromName; //发件人姓名
$Jmail->From = $this->From; //发件人地址
$Jmail->AddRecipient($this->Addrecipient); //收件人地址
$Jmail->Subject = $this->Title;//Email标题
$Jmail->Body = $this->Content; //Email正文
$JmailError = $Jmail->Send($this->Smtp); //Smtp服务器
if($JmailError){ //判断邮件是否发送成功
return true;
}else{
return false;
}
}
}
//这里是调用代码
$jmail = new Jmail();
$jmail->Username = ""; //这里是smtp的帐号
$jmail->Password = "";//这里是smtp的密码
$jmail->FromName = "";//这里是邮件显示的名字
$jmail->From = "";//这里填写你发送的邮件地址
$jmail->Addrecipient = ""; //这里填写你目标的邮件地址
$jmail->Title = "这是标题";
$jmail->Content = "";//这里就是你表单里面面的悲痛
$jmail->Smtp = "";//这里是你邮件的smtp地址
if($jmail->Send()){
echo "成功哦!";
}else{
echo "失败哦!";
}
?>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询