php发送邮件与pop3邮件登录代码
<?php
function send_msg($to, $subject, $body) {
$send_addr = 'admin@test.com'; //发送人地址
$header = "from: admin <" . $send_addr . ">rn"; //设置email头
ini_set('sendmail_from', $send_addr);
mail($to, $subject, $body, $header);
}
?>pop3邮箱登录
<?php
function pop3_login($host, $username, $password) {
global $debug;
if (emptyempty($host)) {
return false;
}
if ($debug) echo "open hostname: " . $host . ",port: " . $port . "n";
$conn = @fsockopen($host, 110, $err_no, $err_str, 5);
if (!$conn) {
return false;
}
$ret_info = fgets($conn, 1024);
if (substr($ret_info, 0, 3) == "+ok") {
if (login($conn, $username, $password)) {
return true;
}
}
return false;
}
?>smtp登录验证函数
function smtp_login($host, $username, $password) {
global $debug;
if (emptyempty($host)) {
return false;
}
if ($debug) echo "open hostname: " . $host . ",port: " . $port . "n";
$conn = @fsockopen($host, 25, $err_no, $err_str, 5);
if (!$conn) {
return false;
}
$ret_info = fgets($conn, 1024);
if (substr($ret_info, 0, 3) == "220") {
fputs($conn, "helo localhostrn");
if (substr(fgets($conn, 1024) , 0, 3) == "250") {
if (login($conn, $username, $password, 25)) {
return true;
}
}
}
return false;
}imap登录验证函数
function imap_login($host, $username, $password) {
global $debug;
if (emptyempty($host)) {
return false;
}
if ($debug) echo "open hostname: " . $host . ",port: " . $port . "n";
$conn = @fsockopen($host, 143, $err_no, $err_str, 5);
if (!$conn) {
return false;
}
$ret_info = fgets($conn, 1024);
if (strpos($ret_info, "ok")) {
fputs($conn, "a001 login $username $passwordrn");
$ret = fgets($conn, 1024);
if (strpos($ret, "login ok")) {
return true;
}
}
return false;
}
教程网址:
框架:struts2+spring2.5+hibernate3.2+jsp+jquery1.3+mysql5.0主要功能:网站新闻管理用户注册,登录商品信息管理系统设置管理员密码修改管理员登录退出游客以及用户的投诉和建议功能对网站新闻以及商品的评论功能,管理员对评论的管理功能网站友情链接自主申请功能,管理员审核以后再前台显示管理员后台给给定的Email地址发送邮件功能管理员对用户管理功能管理员后台
0
立即学习“PHP免费学习笔记(深入)”;
欢迎收藏∩_∩但请保留本文链接。
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
C++高性能并发应用_C++如何开发性能关键应用
Java AI集成Deep Java Library_Java怎么集成AI模型部署
Golang后端API开发_Golang如何高效开发后端和API
Python异步并发改进_Python异步编程有哪些新改进
C++系统编程内存管理_C++系统编程怎么与Rust竞争内存安全
Java GraalVM原生镜像构建_Java怎么用GraalVM构建高效原生镜像
Python FastAPI异步API开发_Python怎么用FastAPI构建异步API
C++现代C++20/23/26特性_现代C++有哪些新标准特性如modules和coroutines
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号