getTitle() . ' in ' . $languages[$languageCode]; $srtFileName = str_replace(' ', '-', $subtitles->getTitle() . '-' . $languages[$languageCode] . '.srt'); $attachment = $subtitles->constructSubtitles(AppPostData::returnSubtitleItems()); $mail = new PHPMailer(true); $mail->IsSMTP(); try { //$mail->SMTPDebug = 2; $mail->SMTPAuth = true; $mail->SMTPSecure = 'ssl'; $mail->Host = $smtpHost; $mail->Port = $port; $mail->Username = $smtpUser; $mail->Password = $smtpPassword; $mail->CharSet = 'UTF-8'; $mail->Subject = $subject; $mail->Body = 'New translation was posted'; foreach ($toAddress as $adr) { $mail->AddAddress($adr); } $mail->SetFrom($fromAddress); $mail->AddStringAttachment($attachment, $srtFileName); $mail->Send(); if ($mail->ValidateAddress($mailAdr)) { $content = $greetingMessage . "\n\n"; foreach (AppPostData::returnSubtitleItems() as $item) { $content .= $item . "\n\n"; } $mail->ClearAddresses(); $mail->ClearAttachments(); $mail->Subject = $subject; $mail->Body = $content; $mail->AddAddress($mailAdr); $mail->Send(); } echo 'Thank you. We\'ve recorded translation'; } catch (phpmailerException $e) { echo 'Some problems occured during processing. ' . $e->errorMessage(); } } } else { require 'view/index.php'; } } else { echo 'No video!'; } } else { include 'view/empty-index.php'; }