<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Forum CakePHP.org.pl - Cannot modify header information]]></title>
		<link>http://forum.cakephp.org.pl/topic/96/cannot-modify-header-information/</link>
		<description><![CDATA[Najświeższe odpowiedzi w Cannot modify header information.]]></description>
		<lastBuildDate>Fri, 11 Dec 2009 13:46:49 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Odp: Cannot modify header information]]></title>
			<link>http://forum.cakephp.org.pl/post/538/#p538</link>
			<description><![CDATA[<p>Witam,</p><p>dzięki <strong>gaw</strong> za naprowadzenie, ten sam problem mnie również zmarnował sporo czasu. Gdyby nie ten temat pewnie siedziałbym dłużej nad taką pierdołą w kodzie <img src="http://forum.cakephp.org.pl/img/smilies/cool.png" width="15" height="15" alt="cool" />.</p><p>Pozdrawiam</p>]]></description>
			<author><![CDATA[dummy@example.com (marek.rodkiewicz)]]></author>
			<pubDate>Fri, 11 Dec 2009 13:46:49 +0000</pubDate>
			<guid>http://forum.cakephp.org.pl/post/538/#p538</guid>
		</item>
		<item>
			<title><![CDATA[Odp: Cannot modify header information]]></title>
			<link>http://forum.cakephp.org.pl/post/470/#p470</link>
			<description><![CDATA[<p>ok, mam rozwiązanie.<br />Otworzyłem komponent swiftmailer w Notepad++</p><p>Następnie wykonałem polecenia:<br />Koduj w UTF-8 (bez BOM)</p><p>Rozwiązanie znalazłem w komentarzach tutaj:<br /><a href="http://www.justkez.com/cakephp-cannot-modify-header-information">http://www.justkez.com/cakephp-cannot-m &#133; nformation</a></p><p>straciłem na taką drobnostkę 2 godziny - może komuś się przyda i zaoszczędzi komuś nerwów:)</p>]]></description>
			<author><![CDATA[dummy@example.com (gaw)]]></author>
			<pubDate>Fri, 07 Aug 2009 10:58:34 +0000</pubDate>
			<guid>http://forum.cakephp.org.pl/post/470/#p470</guid>
		</item>
		<item>
			<title><![CDATA[Odp: Cannot modify header information]]></title>
			<link>http://forum.cakephp.org.pl/post/467/#p467</link>
			<description><![CDATA[<p>a czemu nie korzystasz z wbudowanego EmailComponent ?</p>]]></description>
			<author><![CDATA[dummy@example.com (tomay7)]]></author>
			<pubDate>Fri, 07 Aug 2009 10:21:09 +0000</pubDate>
			<guid>http://forum.cakephp.org.pl/post/467/#p467</guid>
		</item>
		<item>
			<title><![CDATA[Cannot modify header information]]></title>
			<link>http://forum.cakephp.org.pl/post/466/#p466</link>
			<description><![CDATA[<p>witam,</p><p>mam problem ze sławnym komunikatem: Cannot modify header information.</p><p>Problem pojawia się w momencie gdy chcę wysłać maila za pomocą SwiftMailer - problem o tyle ciekawy, że w jednym projekcie działa, a w drugim nie <img src="http://forum.cakephp.org.pl/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><div class="codebox"><pre><code>Warning (2): Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\aplikacja\app\controllers\components\swift_mailer.php:1) [CORE\cake\libs\controller\controller.php, line 640]

Code | Context

$status    =    &quot;Location: http://localhost/fagp/pages/form_ok&quot;

header - [internal], line ??
Controller::header() - CORE\cake\libs\controller\controller.php, line 640
Controller::redirect() - CORE\cake\libs\controller\controller.php, line 621
ContactsController::add() - APP\controllers\contacts_controller.php, line 35
Object::dispatchMethod() - CORE\cake\libs\object.php, line 115
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 227
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 194
[main] - APP\webroot\index.php, line 88</code></pre></div><p>pierwsze linie kodu swiftmailer komponent to <br /></p><div class="codebox"><pre><code>&lt;?php 
// File -&gt; app/controllers/components/swift_mailer.php
//http://bakery.cakephp.org/articles/view/updated-swiftmailer-4-xx-component-with-attachments-and-plugins

/** 
 * SwiftMailer 4.03 Component
 * 
 * @author Matt Huggins
 * @version 2.21
 * @license MIT
 * @category Components
 * @modifiedby d3f_l3pp4rd
 */</code></pre></div><p>wiec nie ma nic co moze powodowac blad.</p><p>Korzystam z SwiftMailer w nastepujacy sposob<br /></p><div class="codebox"><pre><code>function add() {
        if (!empty($this-&gt;data)) {
            $this-&gt;Contact-&gt;create();
            if ($this-&gt;Contact-&gt;save($this-&gt;data)) {
                $this-&gt;Session-&gt;setFlash(__(&#039;The Contact has been saved&#039;, true));
                $this-&gt;contact($this-&gt;data); 
                $this-&gt;redirect(array(&#039;controller&#039;=&gt;&#039;pages&#039;,&#039;action&#039;=&gt;&#039;form_ok&#039;));
                
                }
                
             else {
                $this-&gt;Session-&gt;setFlash(__(&#039;The Contact could not be saved. Please, try again.&#039;, true));
            }
        }
    }</code></pre></div><p>funkcja $this-&gt;contact();</p><div class="codebox"><pre><code> 
        $this-&gt;SwiftMailer-&gt;smtpHost = &#039;tutaj jest host;
       // $this-&gt;SwiftMailer-&gt;smtpPort = 465;
        $this-&gt;SwiftMailer-&gt;smtpUsername = &#039;login&#039;;
        $this-&gt;SwiftMailer-&gt;smtpPassword = &#039;haslo&#039;;

        $this-&gt;SwiftMailer-&gt;sendAs = &#039;html&#039;;
        $this-&gt;SwiftMailer-&gt;from = &#039;adres_email_smtpl&#039;;
        $this-&gt;SwiftMailer-&gt;fromName = &#039;Automat&#039;;
        $this-&gt;SwiftMailer-&gt;to = &#039;tutaj to wysylaml&#039;;
         
        
     
       $this-&gt;set(&#039;message&#039;, $data);
        
        try {
            if(!$this-&gt;SwiftMailer-&gt;send(&#039;kontakt&#039;, &#039;Kontakt ze strony xxx&#039;)) {
                foreach($this-&gt;SwiftMailer-&gt;postErrors as $failed_send_to) {
                    $this-&gt;log(&quot;Failed to send email to: $failed_send_to&quot;);
                }
            }
        }
        catch(Exception $e) {
              $this-&gt;log(&quot;Failed to send email: &quot;.$e-&gt;getMessage());
        }
        $this-&gt;autoRender = false;
    } </code></pre></div><p>szablon wiadomości kontakt.ctp wyglada tak<br /></p><div class="codebox"><pre><code>&lt;p&gt;&lt;?php __(&#039;Name&#039;); ?&gt;: &lt;?php echo $message[&#039;Contact&#039;][&#039;name&#039;] ?&gt;&lt;/p&gt;
&lt;p&gt;&lt;?php __(&#039;Email&#039;); ?&gt;: &lt;?php echo $html-&gt;link($message[&#039;Contact&#039;][&#039;email&#039;],&#039;mailto:&#039;.$message[&#039;Contact&#039;][&#039;email&#039;]) ?&gt;&lt;/p&gt;
&lt;p&gt;&lt;?php __(&#039;Subject&#039;); ?&gt;: &lt;?php echo $message[&#039;Contact&#039;][&#039;subject&#039;] ?&gt;&lt;/p&gt;
&lt;p&gt;&lt;?php __(&#039;Message&#039;); ?&gt;: &lt;?php echo $message[&#039;Contact&#039;][&#039;message&#039;] ?&gt;&lt;/p&gt;</code></pre></div><p>oczywiście sprawdziłem i nigdzie nie ma zadnych znaków po &quot;?&gt;&quot;</p><p>ma ktoś może pomysł gdzie leży przyczyna?</p>]]></description>
			<author><![CDATA[dummy@example.com (gaw)]]></author>
			<pubDate>Fri, 07 Aug 2009 10:08:59 +0000</pubDate>
			<guid>http://forum.cakephp.org.pl/post/466/#p466</guid>
		</item>
	</channel>
</rss>
