php订单发送邮件源码(php自动发送邮件)
本文目录一览:
我有一个PHP发邮件的源码,但是发邮件时候不填标题跟内容也可以发送成功,我想在源码里添加一个判断提示
if($mailtitle==""){
echo 'script language="JavaScript";alert("发送失败!请填写完整信息。");location.href="index.html";/script;';
echo "a href='index.html'点此返回/a";
exit();
}
这可以判断你邮箱有没有填写
PHP发送邮件的源码
mail()函数发送php订单发送邮件源码的邮件基本上都被当作垃圾邮件过滤掉php订单发送邮件源码了php订单发送邮件源码,很少会到达用户邮箱php订单发送邮件源码的。因为它不需要邮件帐户就可以发邮件。商业网站php中发送邮件都是用sendmail。
怎么实现php发送邮件附件?需要源代码!
服务器必须开启SMTP服务,代码function smail($smtp,$title,$username,$passwd,$mailfrom,$mailfrom1,$rcptto,$mail){
$message="";
$message .= "正在连接服务器...br";
$link = fsockopen($smtp,25);
if ($link){
set_socket_blocking($link,true);
$lastmessage=fgets($link,512);
if (!ereg("^220",$lastmessage)){
$message .= "与服务器连接失败" . $lastmessage . "br";
}
else{
$message .= "与服务器连接成功,服务器就绪:" . $lastmessage . "br";
fputs($link,"HELO phpsetmail"."\r\n");
$lastmessage=fgets($link,2000);
if (ereg("^250",$lastmessage)){
$message .= "与服务器HELO成功:" .$lastmessage. "br";
}
else{
$message .= "与服务器HELO失败:" .$lastmessage. "br";
}
fputs($link,"AUTH LOGIN"."\r\n");
$lastmessage=fgets($link,2000);
if (ereg("^334",$lastmessage)){
$message .= "请求与服务器进行用户验证成功:" .$lastmessage. "br";
}
else{
$message .= "请求与服务器进行用户验证失败:" .$lastmessage. "br";
}
fputs($link,base64_encode($username)."\r\n");
$lastmessage=fgets($link,2000);
if (ereg("^334",$lastmessage)){
$message .= "与服务器用户验证成功:" .$lastmessage. "br";
}
else{
$message .= "与服务器用户验证失败:" .$lastmessage. "br";
}
fputs($link,base64_encode($passwd)."\r\n");
$lastmessage=fgets($link,2000);
if (ereg("^235",$lastmessage)){
$message .= "与服务器密码验证成功:" .$lastmessage. "br";
}
else{
$message .= "与服务器密码验证失败:" .$lastmessage. "br";
}
fputs($link,"MAIL FROM:$mailfrom"."\r\n");
$lastmessage=fgets($link,2000);
if (ereg("^250",$lastmessage)){
$message .= "与服务器MAIL FROM成功:" .$lastmessage. "br";
}
else{
$message .= "与服务器MAIL FROM失败:" .$lastmessage. "br";
}
fputs($link,"RCPT TO:$rcptto"."\r\n");
$lastmessage=fgets($link,2000);
if (ereg("^250",$lastmessage)){
$message .= "与服务器RCPT TO成功:" .$lastmessage. "br";
}
else{
$message .= "与服务器RCPT TO失败:" .$lastmessage. "br";
}
fputs($link,"DATA"."\r\n");
$lastmessage=fgets($link,2000);
if (ereg("^354",$lastmessage)){
$message .= "请求与服务器发送邮件数据成功:" .$lastmessage. "br";
fputs($link,"Content-Type:text/html charset=gb2312 \r\n");
fputs($link,"From:$mailfrom" . "\r\n");
fputs($link,"Subject:$title" . "\r\n");
fputs($link,"To:$rcptto" . "\r\n");
fputs($link,"X-Mailer: autokeeper". "\r\n");
fputs($link,"\r\n");
fputs($link,$mail . "\r\n");
fputs($link,"." . "\r\n");
$lastmessage=fgets($link,2000);
if (ereg("^250",$lastmessage)){
$message .= "发送邮件数据成功:" .$lastmessage. "br";
}
else{
$message .= "发送邮件数据失败:" .$lastmessage. "br";
}
}
else{
echo "请求与服务器发送邮件数据成功:" .$lastmessage. "br";
}
fputs($link,"QUIT"."\r\n");
$lastmessage=fgets($link,2000);
if (ereg("^221",$lastmessage)){
$message .= "与服务器断开连接成功:" .$lastmessage. "br";
}
else{
$message .= "与服务器断开连接失败:" .$lastmessage. "br";
}
}
}
else{
echo "error";
}
fclose($link);
}