/**
	 * Sends email.
	 * @param  NMail
	 * @return void
	 */
	public function send(NMail $mail)
	{
		$tmp = clone $mail;
		$tmp->setHeader('Subject', NULL);
		$tmp->setHeader('To', NULL);

		$parts = explode(NMail::EOL . NMail::EOL, $tmp->generateMessage(), 2);

		NDebugger::tryError();
		$args = array(
			str_replace(NMail::EOL, PHP_EOL, $mail->getEncodedHeader('To')),
			str_replace(NMail::EOL, PHP_EOL, $mail->getEncodedHeader('Subject')),
			str_replace(NMail::EOL, PHP_EOL, $parts[1]),
			str_replace(NMail::EOL, PHP_EOL, $parts[0]),
		);
		if ($this->commandArgs) {
			$args[] = (string) $this->commandArgs;
		}
		$res = call_user_func_array('mail', $args);

		if (NDebugger::catchError($e)) {
			throw new InvalidStateException('mail(): ' . $e->getMessage(), 0, $e);

		} elseif (!$res) {
			throw new InvalidStateException('Unable to send email.');
		}
	}
Beispiel #2
0
 public function send()
 {
     $conf = NEnvironment::getContext()->parameters['common.mailer'];
     $this->setFrom($conf['from']);
     //nastavení nSMTPMaileru (z config.ini)
     $mailer = new SmtpMailer($conf['host'], $conf['port'], $conf['transport'], $conf['username'], $conf['password'], NULL, NULL, NULL);
     $this->setMailer($mailer);
     //důležité!!!
     //        $undelivered = array();
     //        foreach ($recipients as $email) {
     //            try {
     //        //tady můžeme prohnat zadané adresy nějakým úžasným regexem
     //                if (!preg_match('/^\s*$/', $email)) {
     //            //můžeme použít i addCC a addBcc
     //                    $mail->addTo($email);
     //        } else {
     //            $undelivered[] = $email;
     //        }
     //            } catch (InvalidArgumentException $e) {
     //                $undelivered[] = $email;
     //            }
     //        }
     if (isset($this->template)) {
         $this->setHtmlBody((string) $this->template);
     }
     try {
         parent::send();
     } catch (InvalidStateException $e) {
         $this->result = FALSE;
     }
 }
Beispiel #3
0
 public function send()
 {
     if ($this->debugMode) {
         $subject = $this->getSubject();
         $subject .= ' (development mode) - adresy: ' . join(',', $this->prijemci);
         $this->setSubject($subject);
         parent::addTo($this->komu_test);
     }
     $this->addReplyTo($this->reply_to);
     $this->mailer->commandArgs = '-f ' . $this->from;
     return parent::send();
 }
Beispiel #4
0
	/**
	 * Sends email.
	 * @param  NMail
	 * @return void
	 */
	public function send(NMail $mail)
	{
		$data = $mail->generateMessage();

		$this->connect();

		$from = $mail->getHeader('From');
		if ($from) {
			$from = array_keys($from);
			$this->write("MAIL FROM:<$from[0]>", 250);
		}

		foreach (array_merge(
			(array) $mail->getHeader('To'),
			(array) $mail->getHeader('Cc'),
			(array) $mail->getHeader('Bcc')
		) as $email => $name) {
			$this->write("RCPT TO:<$email>", array(250, 251));
		}

		$this->write('DATA', 354);
		$data = preg_replace('#^\.#m', '..', $data);
		$this->write($data);
		$this->write('.', 250);

		$this->write('QUIT', 221);

		$this->disconnect();
	}
Beispiel #5
0
	/**
	 * Sends email.
	 * @return void
	 */
	public function send(NMail $mail)
	{
		$tmp = clone $mail;
		$tmp->setHeader('Subject', NULL);
		$tmp->setHeader('To', NULL);

		$parts = explode(NMail::EOL . NMail::EOL, $tmp->generateMessage(), 2);

		$args = array(
			str_replace(NMail::EOL, PHP_EOL, $mail->getEncodedHeader('To')),
			str_replace(NMail::EOL, PHP_EOL, $mail->getEncodedHeader('Subject')),
			str_replace(NMail::EOL, PHP_EOL, $parts[1]),
			str_replace(NMail::EOL, PHP_EOL, $parts[0]),
		);
		if ($this->commandArgs) {
			$args[] = (string) $this->commandArgs;
		}
		if (call_user_func_array('mail', $args) === FALSE) {
			$error = error_get_last();
			throw new InvalidStateException("Unable to send email: $error[message].");
		}
	}
Beispiel #6
0
 /**
  * Send contact form
  * @return void
  */
 public function popFormSubmited(NAppForm $form)
 {
     if ($form['popsend']->isSubmittedBy()) {
         $values = $form->getValues();
         $this->invalidateControl('popup');
         $this->template->poptavka = $this->thankYou();
         $body = $values['body'] . "\n\nKontakt: " . $values['contact'];
         $addTo = $this->getPerson($values['id']);
         $addTo = $addTo['email'];
         $mail = new NMail();
         $mail->setFrom('Firemni web <*****@*****.**>');
         $mail->addTo($addTo);
         //$mail->addTo('*****@*****.**');
         $mail->setSubject('Zprava z firemniho webu');
         $mail->setBody($body);
         $mail->send();
     }
 }
	/**
	 * @return NMail
	 */
	public function createNette__mail()
	{
		$service = new NMail;
		$service->setMailer($this->getService('nette.mailer'));
		return $service;
	}
Beispiel #8
0
<?php

if ($_GET["a"] == 'chci-prodat') {
    $tmplPoptavka = new GlassTemplate("templates/{$CONF['vzhled']}/chci-prodat.html");
    if ($_POST["odeslat"]) {
        if ($_POST["jmeno"] and ($_POST["telefon"] or $_POST["email"])) {
            $mail = new NMail();
            $mail->setSubject("Vyplněn formulář Chci prodat");
            $mail->setFrom($CONF["mailer"]);
            $mail->addTo(zjisti_z("{$CONF['sqlPrefix']}nastaveni", "emailAdmin", "id=1"));
            /*if( preg_match(",", zjisti_z("$CONF[sqlPrefix]nastaveni", "emailAdmin", "id=1")) ){ 
                  $to_address = explode(",", zjisti_z("$CONF[sqlPrefix]nastaveni", "emailAdmin", "id=1"));
                  foreach($to_address as $to){
                          $mail->addTo($to);
                  }
              }
              else $mail->addTo(zjisti_z("$CONF[sqlPrefix]nastaveni", "emailAdmin", "id=1"));*/
            $mail->setHtmlBody("<table>\n                                <tr><td>* Jméno a příjmení:</td><td>{$_POST['jmeno']}</td></tr>\n                                <tr><td>Adresa:</td><td>{$_POST['adresa']}</td></tr>\n                                <tr><td>** Telefon:</td><td>{$_POST['telefon']}</td></tr>\n                                <tr><td>** E-mail:</td><td>{$_POST['email']}</td></tr>\n                                <tr><td colspan=\"2\">Vzkaz pro realitního makléře:</td></tr>\n                                <tr><td colspan=\"2\">{$_POST['vzkaz']}</td></tr>\n                                </table>");
            try {
                /*if( $_FILES['priloha']['name'] ){
                  move_uploaded_file($_FILES['priloha']['tmp_name'], 'userfiles/'.$_FILES['priloha']['name']);
                  $mail->addAttachment('userfiles/'.$_FILES['priloha']['name']);}*/
                $mail->send();
                /*if( $_FILES['priloha']['name'] ) unlink('userfiles/'.$_FILES['priloha']['name']);*/
                $tmplPoptavka->newBlok("zprava1");
            } catch (InvalidStateException $e) {
                $tmplPoptavka->newBlok("zprava2");
            }
        } else {
            $tmplPoptavka->newBlok("zprava3");
        }
Beispiel #9
0
 /**
  * Sends e-mail.
  *
  * Implementation of IMailer
  * @param  Mail The mail to send (instance of Nette\Mail)
  * @return void
  *
  * @throws InvalidStateException if something went wrong
  */
 function send(NMail $mail)
 {
     $from = $mail->getHeader('From');
     //intentionally !=
     $from = $from != NULL && !empty($from) ? array_keys($from) : NULL;
     if ($from !== NULL) {
         $this->client->setFrom($from[0]);
     }
     $to = $mail->getHeader('To');
     $cc = $mail->getHeader('Cc');
     $bcc = $mail->getHeader('Bcc');
     $recipients = array();
     //intentionally !=
     $to != NULL && !empty($to) ? $recipients = array_merge($recipients, array_keys($to)) : NULL;
     $cc != NULL && !empty($cc) ? $recipients = array_merge($recipients, array_keys($cc)) : NULL;
     $bcc != NULL && !empty($bcc) ? $recipients = array_merge($recipients, array_keys($bcc)) : NULL;
     $this->client->setRecipients($recipients);
     $this->client->setBody($mail->generateMessage());
     //throws InvalidStateException
     $this->client->send();
 }
Beispiel #10
0
<?php

if ($_GET["a"] == 'poptavky') {
    $tmplPoptavka = new GlassTemplate("templates/{$CONF['vzhled']}/poptavka.html");
    if ($_POST["odeslat"]) {
        if ($_POST["predmet"] != '' and $_POST["specifikace"] != '' and $_POST["psc"] != '' and $_POST["email"] != '' and $_POST["telefon"] != '' and $_POST["kraj"] != '') {
            $od_koho = "*****@*****.**";
            $komu = "*****@*****.**";
            $predmet = "Poptávka";
            $zprava = "<table>\n        <tr><td>Předmět poptávky</td><td>{$_POST['predmet']}</td></tr>\n        <tr><td>Bližší specifikace poptávky</td><td>{$_POST['specifikace']}</td></tr>\n        <tr><td>Hodnota poptávky</td><td>{$_POST['hodnota']}</td></tr>\n        <tr><td>Finanční služby</td><td>{$_POST['sluzby']}</td></tr>\n        <tr><td></td><td>{$_POST['typ']}</td></tr>\n        <tr><td>&nbsp;</td><td></td></tr>\n        <tr><td>Kontaktní údaje:</td><td></td></tr>\n        <tr><td>Jméno, příjmení</td><td>{$_POST['jmeno']}</td></tr>\n        <tr><td>Ulice , číslo popisné</td><td>{$_POST['ulice']}</td></tr>\n        <tr><td>PSČ, město</td><td>{$_POST['psc']}</td></tr>\n        <tr><td>Telefon</td><td>{$_POST['telefon']}</td></tr>\n        <tr><td>E-mail</td><td>{$_POST['email']}</td></tr>\n        <tr><td>Kraj</td><td>{$_POST['kraj']}</td></tr>\n        <tr><td>Bližší specifikace, město, obec &nbsp;</td><td>{$_POST['blizsi']}</td></tr>\n        </table>";
            $mail = new NMail();
            $mail->setSubject($predmet);
            $mail->setFrom($od_koho);
            $mail->addTo($komu);
            $mail->setHtmlBody($zprava);
            try {
                if ($_FILES['priloha']['name']) {
                    move_uploaded_file($_FILES['priloha']['tmp_name'], 'userfiles/' . $_FILES['priloha']['name']);
                    $mail->addAttachment('userfiles/' . $_FILES['priloha']['name']);
                }
                $mail->send();
                if ($_FILES['priloha']['name']) {
                    unlink('userfiles/' . $_FILES['priloha']['name']);
                }
                $tmplPoptavka->newBlok("zprava1");
            } catch (InvalidStateException $e) {
                $tmplPoptavka->newBlok("zprava2");
            }
            /*if(easyMail("$od_koho","$komu","$predmet","$zprava")){   //pokud server e-mail odešle...
              $tmplPoptavka->newBlok("zprava1");
              }else{                               //...a pokud ne
Beispiel #11
0
 function send(NMail $mail)
 {
     $tmp = clone $mail;
     $tmp->setHeader('Subject', NULL);
     $tmp->setHeader('To', NULL);
     $parts = explode(NMail::EOL . NMail::EOL, $tmp->generateMessage(), 2);
     NTools::tryError();
     $res = mail(str_replace(NMail::EOL, PHP_EOL, $mail->getEncodedHeader('To')), str_replace(NMail::EOL, PHP_EOL, $mail->getEncodedHeader('Subject')), str_replace(NMail::EOL, PHP_EOL, $parts[1]), str_replace(NMail::EOL, PHP_EOL, $parts[0]));
     if (NTools::catchError($msg)) {
         throw new InvalidStateException($msg);
     } elseif (!$res) {
         throw new InvalidStateException('Unable to send email.');
     }
 }