简体   繁体   English

PHP Mailer-发送的电子邮件附件不超过100 KB

[英]PHP Mailer - Email is not sent for more than 100 KB attachment

I am using PHPMailer library for sending email. 我正在使用PHPMailer库发送电子邮件。 I have uploaded code to different server and now email is not working for attachments of size more than 100 KB. 我已将代码上传到其他服务器,现在电子邮件不适用于大小超过100 KB的附件。 It is giving error 它给出了错误

"Cannot instantiate mail function.". “无法实例化邮件功能。”。

It works with attachments less than 100 KB. 它适用于小于100 KB的附件。 It seems that there might be some size limit on the server. 似乎服务器上可能有一些大小限制。 If this is the case then where to check this ? 如果是这种情况,那么在哪里检查呢?

I am using windows server , following are the settings in php mailer 我正在使用Windows服务器 ,以下是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- 请遵循以下任何一项以寻求帮助-

Method 1: Edit .htaccess 方法1:编辑.htaccess

php_value upload_max_filesize 10M
php_value post_max_size 20M
php_value memory_limit 32M

Method 2: Edit php.ini 方法2:编辑php.ini

upload_max_filesize = 10M
post_max_size = 20M
memory_limit = 32M

Method 3: Suhosin (Optional) 方法3:Suhosin(可选)

This is not installed by default on many servers (latest version of Debian, Ubuntu, and FreeBSD does install Suhosin by default). 默认情况下,这不是在许多服务器上安装的(最新版本的Debian,Ubuntu和FreeBSD会默认安装Suhosin)。 Use phpinfo() to find out if suhosin enabled or not. 使用phpinfo()来确定是否启用了suhosin。

<?php
   phpinfo();
?>

If enabled then- 如果启用,则-

suhosin.memory_limit=32M

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. 但是最好保持较小,这样服务器CPU的负载和托管空间限制都不会太大。

You can also check- 您还可以检查-

max_execution_time = 240 
max_input_time = 240 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM