PHP Mailer - 发送的电子邮件超过100 KB附件 [英] PHP Mailer - Email is not sent for more than 100 KB attachment
问题描述
我正在使用PHPMailer库发送电子邮件。我已将代码上传到不同的服务器,现在电子邮件不适用于大小超过100 KB的附件。它给出错误
I am using PHPMailer library for sending email. I have uploaded code to different server and now email is not working for attachments of size more than 100 KB. It is giving error
无法实例化邮件功能。。
"Cannot instantiate mail function.".
它适用于小于100 KB的附件。似乎服务器上可能存在一些大小限制。如果是这种情况,那么在哪里查看?
It works with attachments less than 100 KB. It seems that there might be some size limit on the server. If this is the case then where to check this ?
我使用的是Windows服务器,以下是php邮件程序中的设置
I am using windows server, following are the settings in php mailer
$mail = new PHPMailer();
$mail->isMail();
$mail->isHTML(true);
$mail->Host = 'localhost';
$mail->SMTPAuth = false;
$mail->AddAddress('whoto@otherdomain.com', 'John Doe');
$mail->SetFrom('donotreply@yourdomain.com', 'First Last');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
$mail->MsgHTML(file_get_contents('contents.html'));
$mail->AddAttachment('path/to/attachment'); // attachment
$mail->Send();
请任何人都可以解决这个问题。我已经在互联网上搜索了上述问题,但无法解决这个问题。
Please can anyone give a solution to this problem. I have searched internet for above problem, but couldn't get any proper solution to this issue.
推荐答案
有一些方法。请关注以下任何一项 -
There is some methods. Follow any of these for your help-
方法1:编辑.htaccess
Method 1: Edit .htaccess
php_value upload_max_filesize 10M
php_value post_max_size 20M
php_value memory_limit 32M
Method 2:编辑php.ini
Method 2: Edit php.ini
upload_max_filesize = 10M
post_max_size = 20M
memory_limit = 32M
方法3:Suhosin(可选)
Method 3: Suhosin (Optional)
这是在许多服务器上没有默认安装(最新版本的Debian,Ubuntu和FreeBSD默认安装Suhosin)。使用phpinfo()来查明是否启用了suhosin。
This is not installed by default on many servers (latest version of Debian, Ubuntu, and FreeBSD does install Suhosin by default). Use phpinfo() to find out if suhosin enabled or not.
<?php
phpinfo();
?>
如果启用则 -
suhosin.memory_limit=32M
您可以根据需要更改数值。但最好保持较小,以便您的服务器CPU不会得到太大的负载也是您的主机空间限制。
You can change the numeric values as your need. But better keep smaller so your server CPU not get much load also your hosting space limit.
您还可以检查 -
max_execution_time = 240
max_input_time = 240
这篇关于PHP Mailer - 发送的电子邮件超过100 KB附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!