当前位置:首页 » 编程语言 » emailphp

emailphp

发布时间: 2022-09-24 14:08:39

⑴ 我发一封email,php程序实现监测email有没有被查看可以做到吗 以及思路

插入一个js或图片,或是其它什么这个要得自己想,然后要访问的就是你的网站,然后来判断是否有访问,可以记录用户的cookies等信息,但要注意不要做非法的活动。

⑵ php如何在email中罗列产品

在php中地址验证写法各种各样的,下面我来总结几种常用的email地址验证实例,最简单的是直接使用正则表达式preg_match(\"/^([a-z0-9\\+_\\-]+)(\\.[a-z0-9\\+_\\-]+)*@([a-z0-9\\-]+\\.)+[a-z]{2,6}$/ix来验证了。

PHP入门教程请戳这里:http://www.tiecou.com/1832.html

⑶ 怎么利用php发送邮件求详细教程

PHP虽然提供了mail()函数,但并不好用,而PHPMailer是一个不错的邮件发送工具,接下来将详细介绍,需要了解的朋友可以参考下:

本人使用wamp集成开发环境,Apache2.4.4, Mysql5.6.12 , php5.4.12.开始的时候使用mail()发送邮件,更改配置始终无法成功,了解到mail()函数使用需要sendmail程序。又下载了sendmail程序扩展包。按照网上的说法也改好了php.ini和sendmail.ini。使用foxmail 7.1创建了自己的qq邮箱账户,开启了POP3/SMTP服务,更改发件服务器为POP3,使用和收件服务器相同的身份验证,结果还是报错:Warning: mail(): SMTP server response: 503 Error: need EHLO and AUTH first ! in F:\PHP\wamp\www\mail.php on line 8。以下是使用mail()函数发送邮件的php代码:

[php] view plain
<span style="font-size:14px"><?php

$to = "[email protected]";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$headers = "From: $from";
$send=mail($to,$subject,$message,$headers);
if($send)
echo "Mail Sent";
else
echo "Sorry,mail sent failed!"

?></span>
在CSDN论坛上发现phpmailer可以方便快捷的发送邮件,以下写出详细使用教程:
1.需要下载PHPMailer文件包,(点击打开链接)

2.确认你的服务器已经系统支持socket,通过phpinfo()查看是否支持socket;

3.把文件解压到你的WEB服务器目录下,就可以使用PHPMailer发送邮件了。

以下为前台表单php代码:

[php] view plain
<span style="font-size:14px"><html>
<body>
<h3>phpmailer Unit Test</h3>
请你输入<font color="#FF6666">收信</font>的邮箱地址:
<form name="phpmailer" action="testemail.php" method="post">
<input type="hidden" name="submitted" value="1"/>
邮箱地址: <input type="text" size="50" name="to" />
<br/>
<input type="submit" value="发送"/>
</form>
</body>
</html> </span>
以下为后台程序:

[php] view plain
<?php
/**
* Simple example script using PHPMailer with exceptions enabled
* @package phpmailer
* @version $Id$
*/

header("content-type:text/html;charset=utf-8");

ini_set("magic_quotes_runtime",0);

require('class.phpmailer.php');

try {
$mail = new PHPMailer(true); //New instance, with exceptions enabled

//$body = file_get_contents('contents.html');
//$body = preg_replace('/\\\\/','', $body); //Strip backslashes
$to = $_POST['to'];
$mail->CharSet="GB2312";//设置邮件字符编码否则邮件会乱码
$mail->Encoding="base64";
$mail->IsSMTP(); // tell the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = 25; // set the SMTP server port
$mail->Host = "smtp.qq.com"; // SMTP server
$mail->Username = "[email protected]"; // SMTP server username
$mail->Password = "000000000000"; // SMTP server password

//$mail->IsSendmail(); // tell the class to use Sendmail

$mail->AddReplyTo("[email protected]","han qing");

$mail->From = "[email protected]";
$mail->FromName = "han qing";

//$to = "[email protected]";

$mail->AddAddress($to);

$mail->Subject =$mail->Subject = "=?utf-8?B?" . base64_encode("First PHPMailer Message") . "?=";

$mail->Body = "<h1>phpmailer演示</h1> 这是用PHPMAILER发的第一份邮件,从QQ邮箱发到Google邮箱.";

$mail->AddAttachment("F:/myloe.jpg");

$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->WordWrap = 80; // set word wrap

//$mail->MsgHTML($body);

$mail->IsHTML(true); // send as HTML

$mail->Send();
echo 'Message has been sent.';
} catch (phpmailerException $e) {
echo $e->errorMessage();
}
?>

⑷ 使用php 怎么发送邮件

你这个是连接的邮件服务器出错了。
估计你本地应该没有装邮件服务器吧,一般都会用第三方的邮件服务器,如smtp.163.com,
去下载个phpmailer,从里面把class.phpmailer.php提取出来,用很好用的。

⑸ PHP 能用自带的email函数发两封邮件么

可以在php上配置一个PEAR,里面有Mail.php这个库,通过这个库文件就可以发送邮件了。

⑹ php编程---email功能

*/
set_time_limit(120);
class smtp_mail
{
var $host; //主机
var $port; //端口 一般为25
var $user; //SMTP认证的帐号
var $pass; //认证密码
var $debug = false; //是否显示和服务器会话信息?
var $conn;
var $result_str; //结果
var $in; //客户机发送的命令
var $from; //源信箱
var $to; //目标信箱
var $subject; //主题
var $body; //内容
function smtp_mail($host,$port,$user,$pass,$debug=false)
{
$this->host = $host;
$this->port = $port;
$this->user = base64_encode($user);
$this->pass = base64_encode($pass);
$this->debug = $debug;
$this->socket = socket_create (AF_INET, SOCK_STREAM, SOL_TCP); //具体用法请参考手册
if($this->socket)
{
$this->result_str = "创建SOCKET:".socket_strerror(socket_last_error());
$this->debug_show($this->result_str);
}
else
{
exit("初始化失败,请检查您的网络连接和参数");
}
$this->conn = socket_connect($this->socket,$this->host,$this->port);
if($this->conn)
{
$this->result_str = "创建SOCKET连接:".socket_strerror(socket_last_error());
$this->debug_show($this->result_str);
}
else
{
exit("初始化失败,请检查您的网络连接和参数");
}
$this->result_str = "服务器应答:<font color=#cc0000>".socket_read ($this->socket, 1024)."</font>";
$this->debug_show($this->result_str);

}
function debug_show($str)
{
if($this->debug)
{
echo $str."<p>\r\n";
}
}
function send($from,$to,$subject,$body)
{
if($from == "" ¦ ¦ $to == "")
{
exit("请输入信箱地址");
}
if($subject == "") $sebject = "无标题";
if($body == "") $body = "无内容";
$this->from = $from;
$this->to = $to;
$this->subject = $subject;
$this->body = $body;

$All = "From:".$this->from."\n";
$All .= "To:".$this->to."\n";
$All .= "Subject:".$this->subject."\n";
$All .= $this->body;
/*
如过把$All的内容再加处理,就可以实现发送MIME邮件了
不过还需要加很多程序
*/

//以下是和服务器会话
$this->in = "EHLO HELO\r\n";
$this->docommand();

$this->in = "AUTH LOGIN\r\n";
$this->docommand();

$this->in = $this->user."\r\n";
$this->docommand();

$this->in = $this->pass."\r\n";
$this->docommand();

$this->in = "MAIL FROM:".$this->from."\r\n";
$this->docommand();

$this->in = "RCPT TO:".$this->to."\r\n";
$this->docommand();

$this->in = "DATA\r\n";
$this->docommand();

$this->in = $All."\r\n.\r\n";
$this->docommand();

$this->in = "QUIT\r\n";
$this->docommand();

//结束,关闭连接

}
function docommand()
{
socket_write ($this->socket, $this->in, strlen ($this->in));
$this->debug_show("客户机命令:".$this->in);
$this->result_str = "服务器应答:<font color=#cc0000>".socket_read ($this->socket, 1024)."</font>";
$this->debug_show($this->result_str);
}
}
//这个是我做的测试,我用的是smtp.163.com,那你的信箱也必须是163.com的,要不人家不让你发!!
//你用这个类的时候你修改成你自己的信箱就可以了
$smtp = new smtp_mail("smtp.163.com","25","你的163.com的帐号","你的密码");
//如果你需要显示会话信息,请将上面的修改成
//$smtp = new smtp_mail("smtp.163.com","25","你的163.com的帐号","你的密码",true);
$smtp->send("你的163.com的帐号@163.com","目标地址","你好","你好");

⑺ php email(); 关于这个函数的问题

需要配置php.ini文件,根据服务器是Unix还是Windows的不同,配置方法不一样,你打开php.ini文件就知道了,原本的模板如下:

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
;sendmail_from = [email protected]

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =

如果是WINDOWS服务器就配置前面一段,如果是UNIX就配置最后的sendmail_path既可

⑻ 如何通过php发送邮件php的mail函数不能用!

支持mail的服务器 一般都是linux的 国内的好像不多
自己的电脑安装mail服务器不能往外发的 呵呵 可以自己测试用
现在很多管理系统都是用fsocketopen方式连接邮件服务器并发送邮件的 可以使用163 126的邮箱 网上有一些模型的 就像是好多管理系统后台让填入用户名和密码 就能群发一样 如果你不介意的话 给你转发一个以前我自己改过的可以利用fsocketopen方式群发或者单发email的一共三个文件
MailClass.php 》》》》》》
<?php
class Smtp
{
var $host; //主机
var $port; //端口 一般为25
var $user; //SMTP认证的帐号
var $pass; //认证密码
var $debug = false; //是否显示和服务器会话信息?
var $conn;
var $result_str; //结果
var $in; //客户机发送的命令
var $from; //收件人收到邮件显示的源信箱
var $email; //真实的地址
var $to; //目标信箱
var $subject; //主题
var $body; //内容
var $error;
var $All;
function Smtp($array)
{
$this->host = $array['host'];
$this->port = $array['port'];
$this->email= $array['trueemail'];
$this->from = $array['from'];
$this->user = base64_encode($array['username']);
$this->pass = base64_encode($array['password']);
$this->debug = $array['debug'];
$this->socket = socket_create (AF_INET, SOCK_STREAM, SOL_TCP);

if($this->socket){
$this->result_str = "创建SOCKET:".socket_strerror(socket_last_error());
$this->debug_show($this->result_str);
}
else
die("初始化失败,请检查您的网络连接和参数");

$this->conn = socket_connect($this->socket,$this->host,$this->port);
if($this->conn){
$this->result_str = "创建SOCKET连接:".socket_strerror(socket_last_error());
$this->debug_show($this->result_str);
}
else
die("初始化失败,请检查您的网络连接和参数");

$this->result_str = "服务器应答:<font color=#cc0000>".socket_read ($this->socket, 1024)."</font>";
$this->debug_show($this->result_str);

}

function debug_show($str)
{
if($this->debug)
{
echo $str."<p>\r\n";
}
}

function setmail($to,$subject,$body){
$this->to = $to;
$this->subject = $subject;
$this->body = $body;

$All ="Content-type:text/html;charset=gb2312\r\n"; //邮件的编码方式可以根据自己的需要改
$All .= "From:".$this->from."\r\n";
$All .= "To:".$this->to."\r\n";
$All .= "Subject:".$this->subject."\r\n\r\n";
$All .= $this->body;
$this->All = $All;
}
/**
* 发送邮件部分
* 接收邮箱数组
*/
function send($toarray,$subject,$body)
{
//以下是和服务器会话
$this->in = "EHLO HELO\r\n";
$this->docommand();

$this->in = "AUTH LOGIN\r\n";
$this->docommand();

$this->in = $this->user."\r\n";
$this->docommand();

$this->in = $this->pass."\r\n";
$this->docommand();

foreach( $toarray as $to ) {
$this -> setmail($to,$subject,$body);

$this->in = "RSET\r\n";
$this->docommand();

$this->in = "MAIL FROM:<".$this->email.">\r\n";
$this->docommand();

$this->in = "RCPT TO:<".$this->to.">\r\n";
$this->docommand();

$this->in = "DATA\r\n";
$this->docommand();

$this->in = $this->All."\r\n.\r\n";
$this->docommand();
}

$this->in = "QUIT\r\n";
$this->docommand();

//结束,关闭连接
}
function docommand()
{
socket_write ($this->socket, $this->in, strlen ($this->in));
$this->debug_show("Client Action:".$this->in);
$this->result_str = "Server:<font color=#cc0000>".socket_read ($this->socket, 1024)."</font>";
$this->debug_show($this->result_str);
}
}
?>

MailConfig.inc.php 》》》》》》

<?php
$mailconfig['host'] = "smtp.126.com"; //主机
$mailconfig['port'] = "25"; //端口 一般为25
$mailconfig['trueemail'] = "[email protected]"; //真实的地址
$mailconfig['username'] = "mhz1600"; //SMTP认证的帐号
$mailconfig['password'] = "*****"; //改成自己的
$mailconfig['debug'] = false; //是否显示和服务器会话信息?
$mailconfig['from'] = "[email protected]"; //显示给用户的发件人

include_once "MailClass.php";
set_time_limit(180);
?>

SendDemo.php 》》》》》》
<?php
include_once "MailConfig.inc.php";

//简单的临时码验证 当前时间(到小时)的验证码
//if( empty($_GET['s']) || $_GET['s'] != md5(date('Y-m-d-H',time())) ) {header("http/1.1 404"); die('');}

//发送email
if( isset($_POST['sendmail']) ) {
if( isset($_POST['from']) ) $mailconfig['from'] = $_POST['from'];
$smtp = new Smtp($mailconfig);
$title = $_POST['title'];
//获取post的email正文
if( get_magic_quotes_gpc() ) $message = $_POST['message'];
else $message = addslashes($_POST['message']);

//从email列表/文档中分离出所有的email地址
$pregstr = "@[a-zA-Z0-9\_][0-9a-zA-Z\.\-\_]+\@[0-aA-Za-z\-\_]+\.[0-9a-zA-Z\.\-\_]+@is";
$temp = array();
preg_match_all($pregstr,$_POST['emails'],$temp);
$toarray = $temp[0];
//var_mp($toarray);

$smtp->send($toarray,$title,$message);

die("操作完成!<A href=".$_SERVER['PHP_SELF']."?s=".md5(date('Y-m-d-H',time())).">继续发送其他</a> <a href=# onclick=window.close()>关闭</a>");
}
else {
if( isset($_POST['emails']) ) {
if( is_array($_POST['emails']) )
$emails = implode("\t",$_POST['emails']);
else
$emails = $_POST['emails'];
}
else $emails = "";
?>
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><style type="text/css">
<!--
body,td,th {
font-size: 12px;
}
-->
</style></head>

<body>
<form id="form1" name="form1" method="post" action="">
<table width="600" border="1" align="center" cellpadding="3" cellspacing="0" bordercolordark="#FFFFFF" bordercolorlight="#eeeeee">
<tr>
<td width="66">发件人:</td>
<td width="516"><input name="from" type="text" value="<?php echo $mailconfig['from']; ?>"> 可以直接修改mailconfig文件中的email</td>
</tr>
<tr>
<td>邮件标题:</td>
<td><input name="title" type="text" value="邮件群发测试标题!" size="60"></td>
</tr>
<tr>
<td>收件人:<br></td>
<td><textarea name="emails" cols="60" rows="5"><?php echo $emails; ?></textarea></td>
</tr>
<tr>
<td>邮件正文:<br>
【html】</td>
<td><textarea name="message" cols="60" rows="10">邮件群发测试!谢谢~!</textarea></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="sendmail" value=" 发送邮件 "> </td>
</tr>
</table>
</form>
<?
}
?>
</body>
</html>

使用方式 运行senddemo.php就行 确定本地或者服务器开启了fsocketopen支持 在输入框可以多种格式的的输入很多email 程序用正则表达式匹配出所有的email地址 通过服务器循环对话的方式不断的发送邮件 看看那个demo的流程就明白了
【郑重声明:mailclass修改自网上的模型 其他本人原创,版权不究 欢迎分享】

+---------------------广告-------------------------+
那一天:回忆,让生活更美好
独享人生中那个特别的日子,记录从那一天开始的幸福
http://www.nayitian.net
期待您的加入,欢迎提供宝贵的意见建议
+--------------------------------------------------+

+--------------------补充--------------------+
发送邮件的服务器(smtp)并不是网址 126发送邮件的服务器是 smtp.126.com 网易163的发送邮件服务器是 smtp.163.com 所有邮箱对于这个都有说明的 还有一个就是能够使用这个功能的好象新注册的邮箱不太好用 因为网易在2006年10对邮箱进行过调整 在此之前注册的都没问题 在这之后注册的好像开通一些其他的功能并且使用了一段时间才行的
smtp服务器的链接可以在命令提示行下测试 就是使用上面的命令:
首先 telnet smtp.126.com 25
因为smtp使用的25端口提供服务的 然后就会看到
220 126.com Anti-spam GT for Coremail System (126com[071018])
输入 EHLO HELO
服务器返回
250-mail
250-PIPELINING
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250 8BITMIME

输入 AUTH LOGIN
服务器返回
334 dXNlcm5hbWU6
然后再输入通过base64加密的用户名和密码 就能通过命令来和服务器对话 包括发送邮件等功能

具体的如果有兴趣更多命令自己查一下
这个php的程序就是模拟这个功能来实现的

如果你用telnet直接连不上的话 说明服务器是错误的 。。

⑼ php如何接收发件箱邮件

php接收邮件举例:
<?php
$server = "{bjmail.*.com/pop3}"; //邮件服务器
$mailbox = "inbox"; //收件箱
$mailaccount="zhao**";//用户名
$mailpasswd=" "; //密码
$stream = @imap_open($server.$mailbox,$mailaccount,$mailpasswd);//打开IMAP 连结
$mail_number = imap_num_msg($stream);//信件的个数
if($mail_number < 1) { echo "No Message for $email"; }//如果信件数为0,显示信息

for($i=$mail_number;$i>=$mail_number;$i--)
{
$headers = @imap_header($stream, $i);
$mail_header= imap_headerinfo($stream, $i);//邮件头部
//var_mp ($mail_header);
$subject = $mail_header->subject;//邮件标题
$subject=decode_mime($subject);
echo $subject;

//编码为简体中文的标题的处理方法
// if(stristr($subject, "=?gb2312"))
// { //编码为简体中文的标题
// $subject=substr($subject,11);
// $subject=substr($subject,0,-2);
// $subject = base64_decode($subject);
// }
echo $from = $mail_header->fromaddress;//发件人
echo $date = $mail_header->date;//日期

$body = imap_fetchbody($stream, $i, 1);
$body = imap_base64($body);
$body = nl2br($body);
echo $body;

// $body = imap_qprint($body);
// echo $body;
// $body = imap_binary($body);
// $body = imap_base64($body);
//echo $body;

}
//对mime解码
function decode_mime($string)
{
$pos = strpos($string,'=?');
if (!is_int($pos)) {
return $string;
}
$preceding = substr($string, 0, $pos); // save any preceding text
$search = substr($string, $pos+2); /* the mime header spec says this is the longest a single encoded Word can be */
$d1 = strpos($search, '?');
if (!is_int($d1)) {
return $string;
}
$charset = substr($string, $pos+2, $d1); //取出字符集的定义部分
$search = substr($search, $d1+1); //字符集定义以后的部分=>$search;
$d2 = strpos($search, '?');
if (!is_int($d2)) {
return $string;
}
$encoding = substr($search, 0, $d2); ////两个?之间的部分编码方式:q或b
$search = substr($search, $d2+1);
$end = strpos($search, '?='); //$d2+1 与 $end 之间是编码了的内容:=> $endcoded_text;
if (!is_int($end)) {
return $string;
}
$encoded_text = substr($search, 0, $end);
$rest = substr($string, (strlen($preceding . $charset . $encoding . $encoded_text)+6)); //+6 是前面去掉的=????=六个字符
switch ($encoding) {
case 'Q':
case 'q':
//$encoded_text = str_replace('_', '%20', $encoded_text);
//$encoded_text = str_replace('=', '%', $encoded_text);
//$decoded = urldecode($encoded_text);
$decoded=quoted_printable_decode($encoded_text);
if (strtolower($charset) == 'windows-1251') {
$decoded = convert_cyr_string($decoded, 'w', 'k');
}
break;
case 'B':
case 'b':
$decoded = base64_decode($encoded_text);
if (strtolower($charset) == 'windows-1251') {
$decoded = convert_cyr_string($decoded, 'w', 'k');
}
break;
default:
$decoded = '=?' . $charset . '?' . $encoding . '?' . $encoded_text . '?=';
break;
}
return $preceding . $decoded .decode_mime($rest);
//return $preceding . $decoded . $this->decode_mime($rest);

}

热点内容
存储设备报价 发布:2024-05-08 02:22:01 浏览:553
定步长的算法 发布:2024-05-08 02:16:18 浏览:109
怎么使用pe口袋服务器 发布:2024-05-08 02:02:18 浏览:471
xml数据库c 发布:2024-05-08 02:01:46 浏览:456
仿知乎android 发布:2024-05-08 01:56:00 浏览:904
mysql编译参数 发布:2024-05-08 01:53:46 浏览:194
怎么看台式电脑配置生产日期 发布:2024-05-08 01:32:26 浏览:460
java基础培训学校 发布:2024-05-08 01:30:44 浏览:468
简单辅助火眼打码如何配置 发布:2024-05-08 01:30:44 浏览:903
我的世界网易版服务器游戏 发布:2024-05-08 01:10:33 浏览:42