E
E
Evgeny2018-04-08 19:43:18
PHP
Evgeny, 2018-04-08 19:43:18

How to set up sending via PHPMailer?

Hello!
I'm setting up sending emails with attachments via PHPMailer. There are 3 letters. The text is the same everywhere, attachments are different. In two small xlsx, in the third - PDF for 34 megabytes. I send via smtp.mail.ru. What is the problem - when the site is on a local server (I use open server), then everything is OK, all 3 letters go without problems.
When I upload to hosting (I tried timeweb and ihor, dedicated servers are everywhere), only letters with xlsx leave, a letter with PDF returns a 500 error. What am I doing wrong?
The code is the following:

require_once('../PHPMailer/PHPMailerAutoload.php');
$mail = new PHPMailer;
$mail->CharSet = 'utf-8';

$mail->isSMTP();
$mail->Host = 'smtp.mail.ru';
$mail->SMTPAuth = true;
$mail->Username = '***@mail.ru';
$mail->Password = '************';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;

$mail->setFrom('***@mail.ru');
$mail->addAddress($email);
$mail->addAttachment('../../files/blank_altayeko.xlsx', 'blank_altayeko.xlsx');
$mail->isHTML(true);

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Shved, 2018-04-08
@shvedan1

to find the cause of the error, you should first look at the error logs. On timeweb hosting, logging for the site can be enabled https://hosting.timeweb.ru/logmanager . Files with logs will appear in the project folder next to the public_html folder (in which the site files are located)
Already from the analysis of the logs, it should become clear what is the cause of the error.

A
Anton, 2018-04-09
@Eridani

memory_limit, max_upload_filesize or something else.
In general, you to the hoster, no directives will correct it for you

A
Alex-1917, 2018-04-12
@alex-1917

tried timeweb and ihor, dedicated servers everywhere
Please explain to the ignorant, what is the need to obtain a PDF ???)))
The pdf size of 34Mb is already at the limit, given the standard limit of 64Mb, just don’t vote that 34 is 2 times less than 64))) PDF is a complicated thing and process it several times more memory is spent than banal xls
I'm not talking about:
hostings that were not included in my top 20... but no, not even in the top 100... nothing personal, my personal list...
Write a processor, there are normal libraries, rather than regular ones from yours
tried timeweb and ihor, dedicated servers everywhere

It's stupid to upload a file to the server, get a link, send you a link. FUCK with an attachment to send, it still doesn’t reach me)))
In a similar situation, a couple of years ago, they stupidly closed the PDF sending - only small clients squeaked, walked through the forest and began to send adequate formats - xls / txt.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question