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

我的梦境 提交于 2019-12-11 12:34:06

问题


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.".

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 ?

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.


回答1:


There is some methods. Follow any of these for your help-

Method 1: Edit .htaccess

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

Method 2: Edit php.ini

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

Method 3: Suhosin (Optional)

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();
?>

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.

You can also check-

max_execution_time = 240 
max_input_time = 240 


来源:https://stackoverflow.com/questions/22607790/php-mailer-email-is-not-sent-for-more-than-100-kb-attachment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!