<select size="1" id="template" name="template"> <option selected> Содержание письма </option> <option value="1" > Приветствие </option> <option value="2" > Оповещание </option> <option value="3" > Предупреждение </option> </select> <br> <label for="var1"> opt1: </label><input id="var1" type="text"> <br> <label for="var2"> opt2: </label><input id="var2" type="text"> <br> <label for="var3"> opt3: </label><input id="var3" type="text"> <br> <input id="preveiw" type="submit" name="preview" value="Предпросмотр"> <input type="submit" name="send" value="Отправить"> </form> <?php require_once 'config.php'; require DIR_CLASSES . 'MailgunLetter.php'; require DIR_CLASSES . 'MailgunMailer.php'; $mailer = new MailgunMailer('url', 'key'); if (isset($_POST)) { $obj = $mailer->create()->to('me <*****@*****.**>')->subject('test')->setIsHtml()->setTemplate('test1')->setLayout('test2')->addInlineImages([DIR_ROOT . 'img/someotherimg.png', DIR_ROOT . 'unnamed.png', DIR_ROOT . 'img/img.png'])->addAttachments([])->setVariables(['arr' => 'first', 'arr2' => 'second']); if (isset($_POST['preview'])) { $obj->is_preview(); } elseif (isset($_POST['send'])) { $obj->send(); } }
public function send() { $this->mailer->sendRequest($this->draw(), $this->is_preview); }