求助PHP发送邮件,如何通过代理服务器这道坎
我写了个发送邮件的功能,在家是可以使用。
但是由于公司是内网,上网都是需要设置代理服务器的,请问如何通过代理服务器发送呢?
最好能给出代码,谢谢。
一定结贴!
以下是我目前的代码。
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 = "我的邮箱";
$jmail->Password = "我的密码";
$jmail->FromName = "test";
$jmail->From = "我的邮箱名";
$jmail->Addrecipient = "地址";
$jmail->Title = "ttt";
$jmail->Content = "cccc";
$jmail->Smtp = "邮寄服务器地址";
if($jmail->Send()){
echo "成功哦!";
}else{
echo "失败哦!";
}
?>
回复讨论(解决方案)
用smtp发就可以了。用qq的邮箱就可以!
问题是内网IP怎么发给SMTP服务器呢?如果能调用到外网IP的话,我这个本就可以发的呀。
你的代理服务器开放了邮件代理了吗?
是这样的
我们这里的电脑都是内网IP,然后要通过外网IP去访问外网;然后邮件服务器是架在外网的。
所以我的理解是应该要连上外网IP才可以发送邮件成功吧。不知道我这样表达能不能让大家明白。
不知道我的理解有没有问题,请大家多多指教。。。我会努力学的。
发的时候会被屏蔽吗
是这样的
我们这里的电脑都是内网IP,然后要通过外网IP去访问外网;然后邮件服务器是架在外网的。
所以我的理解是应该要连上外网IP才可以发送邮件成功吧。不知道我这样表达能不能让大家明白。 如果内网是通过路由器上外网的,那么就可直接使用
如果是通过代理服务器上外网的,则需开通代理服务器的邮件代理功能(默认都是关闭的)
好的谢谢,我去检查一下

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.
