Skip to content

Commit

Permalink
add sendmail
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmi3yy committed Apr 3, 2018
1 parent ffe366c commit 6db347a
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 0 deletions.
28 changes: 28 additions & 0 deletions en/02_Develop/02_API/57_sendmail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
###$modx->sendmail()
Method used for send mails by API (available since 1.0.12). Works with settings, sending emails using `mail()` or SMTP according to the specified settings in the manager panel.
Usage:

####simple variant
```
$param = array();
$param['from'] = "{$site_name}<{$emailsender}>";
$param['subject'] = $emailsubject;
$param['body'] = $message;
$param['to'] = $email;
$rs = $modx->sendmail($param);
```
####variant with additional settings
```
$modx->loadExtension('MODxMailer');
$modx->mail->IsHTML($isHtml);
$modx->mail->From = $from;
$modx->mail->FromName = $fromname;
$modx->mail->Subject = $subject;
$modx->mail->Body = $report;
AddAddressToMailer($modx->mail,"replyto",$replyto);
AddAddressToMailer($modx->mail,"to",$to);
AddAddressToMailer($modx->mail,"cc",$cc);
AddAddressToMailer($modx->mail,"bcc",$bcc);
AttachFilesToMailer($modx->mail,$attachments);
if(!$modx->mail->send()) return 'Main mail: ' . $_lang['ef_mail_error'] . $modx->mail->ErrorInfo;
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions ru/02_Разработка/02_API/57_sendmail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
###$modx->sendmail()
Функция отправки почты через API(доступен с версии 1.0.12), удобен тем что работает в связке с настройками тоесть отправляет почту через mail() или SMTP в зависимости от указанных настроек в панели управления.
Пример использования:

####простой вариант
```
$param = array();
$param['from'] = "{$site_name}<{$emailsender}>";
$param['subject'] = $emailsubject;
$param['body'] = $message;
$param['to'] = $email;
$rs = $modx->sendmail($param);
```
####вариант с расширенными настройками
```
$modx->loadExtension('MODxMailer');
$modx->mail->IsHTML($isHtml);
$modx->mail->From = $from;
$modx->mail->FromName = $fromname;
$modx->mail->Subject = $subject;
$modx->mail->Body = $report;
AddAddressToMailer($modx->mail,"replyto",$replyto);
AddAddressToMailer($modx->mail,"to",$to);
AddAddressToMailer($modx->mail,"cc",$cc);
AddAddressToMailer($modx->mail,"bcc",$bcc);
AttachFilesToMailer($modx->mail,$attachments);
if(!$modx->mail->send()) return 'Main mail: ' . $_lang['ef_mail_error'] . $modx->mail->ErrorInfo;
```

0 comments on commit 6db347a

Please sign in to comment.