Answer the question
In order to leave comments, you need to log in
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");
?>
Answer the question
In order to leave comments, you need to log in
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.
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 questionAsk a Question
731 491 924 answers to any question