Commit 7d2a1547b870e928d3cdc3c8cd42983a780f399a
1 parent
7ca31787
controller
Showing
2 changed files
with
55 additions
and
1 deletions
Show diff stats
src/app/frontend/controllers/MenuController.php
| ... | ... | @@ -1263,7 +1263,7 @@ class MenuController extends \controllers\ControllerBase |
| 1263 | 1263 | $check = $this->models->getSubscribe()->getOneDataByEmail($data['email']); |
| 1264 | 1264 | |
| 1265 | 1265 | if( empty($check) && $this->models->getSubscribe()->addData($data) ) { |
| 1266 | - $this->sendmail->addCustomer( 10, $data ); | |
| 1266 | + $this->sendmail->sendSubscribe( $data ); | |
| 1267 | 1267 | |
| 1268 | 1268 | setcookie("popup", '1', time()+3600, '/'); |
| 1269 | 1269 | ... | ... |
src/lib/sendmail.php
| ... | ... | @@ -224,6 +224,60 @@ namespace |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | ///////////////////////////////////////////////////////////////////////////// |
| 227 | + | |
| 228 | + public function sendSubscribe($data) { | |
| 229 | + $view = new \Phalcon\Mvc\View(); | |
| 230 | + $view->setViewsDir( ROOT_PATH.config::get( 'dirs/viewsDir' ) ); | |
| 231 | + | |
| 232 | + $view->start(); | |
| 233 | + | |
| 234 | + $view->setVar( 'data', $data ); | |
| 235 | + $view->render( 'sendmail', 'message_10' ); | |
| 236 | + | |
| 237 | + $view->finish(); | |
| 238 | + $message_body = $view->getContent(); | |
| 239 | + | |
| 240 | + $mail = new PHPMailer; | |
| 241 | + //Tell PHPMailer to use SMTP | |
| 242 | + $mail->isSMTP(); | |
| 243 | + //Enable SMTP debugging | |
| 244 | + // 0 = off (for production use) | |
| 245 | + // 1 = client messages | |
| 246 | + // 2 = client and server messages | |
| 247 | + $mail->SMTPDebug = 0; | |
| 248 | + //Ask for HTML-friendly debug output | |
| 249 | + $mail->Debugoutput = 'html'; | |
| 250 | + //Set the hostname of the mail server | |
| 251 | + $mail->Host = 'smtp.gmail.com'; | |
| 252 | + $mail->CharSet = 'UTF-8'; | |
| 253 | + // use | |
| 254 | + // $mail->Host = gethostbyname('smtp.gmail.com'); | |
| 255 | + // if your network does not support SMTP over IPv6 | |
| 256 | + //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission | |
| 257 | + $mail->Port = 587; | |
| 258 | + //Set the encryption system to use - ssl (deprecated) or tls | |
| 259 | + $mail->SMTPSecure = 'tls'; | |
| 260 | + //Whether to use SMTP authentication | |
| 261 | + $mail->SMTPAuth = true; | |
| 262 | + //Username to use for SMTP authentication - use full email address for gmail | |
| 263 | + $mail->Username = "arctic.semenainua@gmail.com"; | |
| 264 | + //Password to use for SMTP authentication | |
| 265 | + $mail->Password = "arctic0411"; | |
| 266 | + | |
| 267 | + //Set who the message is to be sent from | |
| 268 | + $mail->setFrom('semena@hs.kiev.ua', 'semena.in.ua'); | |
| 269 | + //Set who the message is to be sent to | |
| 270 | + $mail->addAddress($data['email'], $data['name']); | |
| 271 | + //Set the subject line | |
| 272 | + $mail->Subject = 'Промокод на сайт semena.in.ua'; | |
| 273 | + //Read an HTML message body from an external file, convert referenced images to embedded, | |
| 274 | + //convert HTML into a basic plain-text alternative body | |
| 275 | + | |
| 276 | + $mail->msgHTML($message_body); | |
| 277 | + $mail->send(); | |
| 278 | + } | |
| 279 | + | |
| 280 | + ///////////////////////////////////////////////////////////////////////////// | |
| 227 | 281 | } |
| 228 | 282 | } |
| 229 | 283 | ... | ... |