6

I just wanna ask, when I'm using PHPMailer to send information from a form with many attachments, it's sending everything ok unless the files are more than 7 MB in total.

Everyhing on the server is set up right as you can see:

memory_limit = 40M
post_max_size = 40M
upload_max_filesize = 40M
file_uploads = On

I have read something about PHP mail server limits. I have set the PHPMailer to send messages using PHP mail() function.

What else could there be needed to setup? Where can be the problem? The code itself is really without any limits, so it has to be somewhere else.

When the mail isn't sent, PHP doesn't seem to report any errors, I just get the message from

if(!$mail->Send()) { } else

I have read that on some email server there is a 7 MB limit, could this be limited by the hosting somehow? Thank you for any help, I'm getting desperate.

I also tried on our testing VPS server, it sends the mail everytime and when the files are bigger than 7 MB in total, it sends only some of the files with size < 7 MB.

TeeJay
  • 1,593
  • 3
  • 21
  • 33
  • Unfortunately I haven't found any. It didn't matter much, though, as it was only for images. – TeeJay Nov 08 '13 at 21:00
  • Well, for me it is big matter, I have to create PDF of the selected orders, and attach them in the email. User can select supporting documents along with orders. And average email is more than 10MB each. Any ways I am still looking for the solution – Aamir Mahmood Nov 09 '13 at 05:33
  • Please, inform your hosting provider then. Emails are sent via their mail server and for sure, it's them who can change (or tell you how to) change the limit of attachment size for emails to be sent. – TeeJay Nov 09 '13 at 09:51

3 Answers3

2

what I do with large attachments (for example pdf) is base encode the files myself:

$file = "/home/path/to/file.pdf";
$fp = @fopen($file, "rb");
$pdf_data = @fread($fp, filesize($file));
@fclose($fp);
$pdf_data = chunk_split(base64_encode($pdf_data));
$mail->AddStringAttachment($pdf_data, "filename.pdf", "base64", "application/pdf");

got no problems sending large files

Bokw
  • 789
  • 1
  • 9
  • 21
  • If you don't encode the files yourself, are you getting in problems sending them? And how could I edit this for images generally, not just one format? – TeeJay Jun 15 '13 at 20:43
2

I have read that on some email server there is a 7 MB limit, could this be limited by the hosting somehow?

Very likely this is your problem. PHPMailer uses the web server's sendmail function or whatever mail server is installed. Normally there is a (default) limit to the message size. For Postfix this would be:

message_size_limit (default: 10240000)
The maximal size in bytes of a message, including envelope information.
http://www.postfix.org/postconf.5.html

You will have to contact your hosting provider to change that.

Simon
  • 324
  • 1
  • 13
0

I found this post while researching a problem I was having myself and just found out that Gmail has a character limit of 10'000, so if you are doing your tests using a Gmail address that might be your issue... I now use $mail->MsgHTML(substr($body,0,9000).' [...]'); to make sure I stay way below the Gmail limit...

marcnyc
  • 585
  • 1
  • 4
  • 17