Last active
August 29, 2015 14:19
-
-
Save MikSDigital/9e2fe9faf67405612440 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$message=''; | |
$formFields=array(); | |
$uploaddir = '/data02**/virt4**5630/domeenid**/www.*****.ee/htdocs/assets/downloads/'; | |
$attachment = $uploaddir . $_FILES['attachment']['name']; | |
move_uploaded_file($_FILES['attachment']['tmp_name'], $attachment); | |
//return $attachment; | |
/* $attachment содержит полный путь, включая имя файла для аттача */ | |
/*$message = "Имя :".$_POST['name']." , <br>"."e-mail : ".$_POST['email']. " Телефон : ".$_POST['phone'] ;*/ | |
$formFields=array( | |
'name' => $modx->sanitizeString($_POST['name']), | |
'phone' => $_POST['phone'], | |
'email' => $_POST['email'], | |
'message' => $modx->sanitizeString($_POST['message']) | |
); | |
$message = $modx->getChunk('email', $formFields); | |
$modx->getService('mail', 'mail.modSwiftMailer'); | |
$modx->mail->body($message); | |
$modx->mail->address('to','*****[email protected]'); | |
$modx->mail->address('cc', '*****@mail.ru'); | |
$modx->mail->address('sender', $formFields['email']); | |
$modx->mail->address('from', $formFields['email'], $formFields['email']); | |
$modx->mail->bounce('****[email protected]'); | |
$modx->mail->subject('From ********'); | |
if (file_exists($attachment)) | |
{ | |
$modx->mail->attach($attachment); | |
} | |
if (!$modx->mail->send()) { | |
$modx->log(modX::LOG_LEVEL_ERROR,'An error occurred while trying to send the email: '.$modx->mail->mailer->ErrorInfo); | |
} | |
$modx->mail->reset(); | |
return true; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use modSwiftMailer to send mails