利用php mail()进行邮件发送实现方法,mail() 函数允许您从脚本中直接发送电子邮件。
如果邮件的投递被成功地接收,则返回 true,否则返回 false。
语法:mail(to,subject,message,headers,parameters)
参数描述
to必需。规定邮件的接收者。
subject必需。规定邮件的主题。该参数不能包含任何换行字符。
message必需。规定要发送的消息。
headers必需。规定额外的报头,比如 From, Cc 以及 Bcc。
parameters必需。规定 sendmail 程序的额外参数。
简单的发送html内容:Simple Send Mail Form
Mail FormTo
Subject
Message
SimpleEmail.php
带上抄送与密送功能Send email with CC and BCCTo
Name
CC
BCC
Priority
Highest
High
Normal
Low
Lowest
Subject
Message
sendemailWithCC_BCC.phpMail Sent
" ;
}
if ( emptyempty ( $mailsubject) ) {
$mailsubject=" ";
}
if (($mailpriority>0) && ($mailpriority<6)) {
$mailheader = "X-Priority: ". $mailpriority ."n";
}
$mailheader.= "From: " . "Sales Team n";
$mailheader.= "X-Sender: " . "support@yourdomain.comn";
$mailheader.= "Return-Path: " . "support@yourdomain.comn";
if (!emptyempty($mailcc)) {
$mailheader.= "Cc: " . $mailcc ."n";
}
if (!emptyempty($mailbcc)) {
$mailheader.= "Bcc: " . $mailbcc ."n";
}
if (emptyempty($mailbody)) {
$mailbody=" ";
}
$result = mail ($to, $mailsubject, $mailbody, $mailheader);
echo "Mail sent to ". "$to". "
";
echo $mailsubject. "
";
echo $mailbody. "
";
echo $mailheader. "
";
if ($result) {
echo "
Email sent successfully!";
}else{
echo "
Email could not be sent.";
}
?>
To
CC
BCC
Priority
Subject
Message
在 message 参数规定的消息中,行之间必须以一个 LF(n)分隔,每行不能超过 70 个字符,Windows 下,当 PHP 直接连接到 SMTP 服务器时,如果在一行开头发现一个句号,则会被删掉,要避免此问题,将单个句号替换成两个句号.
教程网址:
欢迎收藏∩_∩但请保留本文链接。