V
V
Vladimir2017-03-07 11:27:22
PHP
Vladimir, 2017-03-07 11:27:22

How to send an attached file from an infoblock in a letter in Bitrix?

Hello. Site on Bitrix.
I am sending email like this

<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
$to = $_POST['email'];
$subject = "отправка письма";
$from = "[email protected]";
$headers = "From: $from\r\nReply-To: $from\r\nContent-type: text/plain; charset=windows-1251\r\n";
$redir = $_SERVER[HTTP_REFERER];
header("Location: $redir");
$telo .= "\n\n—Cсылка: ".$redir;
$telo .= "\n\n—Cообщение: ".$_POST['textarea'];
mail($to, $subject, $telo, $headers);
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");
?>

Now I am sending a link to the page from which the form was submitted.
I made an additional property in the file type infoblock: FILEU.
And now I need this attached file to be sent when sending a letter.
Accordingly, the files on all pages are different. How can I get this file to be sent?
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Gritsuk, 2017-03-08
Portev @Vladimir Portev

Try to use the built-in functionality of Bitrix to send emails. If necessary, the letter template can be edited from the admin panel.
Here you create a type of mail template /bitrix/admin/type_admin.php?lang=ru
And here /bitrix/admin/message_admin.php?lang=ru mail template.
To send an email, use the CEvent::Send function here . With the help of it, files are attached to the letter (last parameter).
To see the status of sending a letter, you can go to "Tables" /bitrix/admin/perfmon_tables.php?lang=en and find the b_event table there.

A
Anton, 2017-03-07
@karminski

1. If you send a letter with the usual mail function, then why do you need to include the Bitrix header files?
2. Use ready-made libraries like github.com/PHPMailer/PHPMailer or swiftmailer.org
to send emails 3. Send emails with files
stackoverflow.com/a/12302354

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question