<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PHP Log &#187; SMTP</title>
	<atom:link href="http://www.php-log.de/tags/smtp/feed" rel="self" type="application/rss+xml" />
	<link>http://www.php-log.de</link>
	<description>Eine feine Sammlung nützlicher PHP Notizen</description>
	<lastBuildDate>Mon, 20 Sep 2010 00:22:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>554 Helo command rejected: Sorry, localhost is local, not remote</title>
		<link>http://www.php-log.de/404/php/554-helo-command-rejected-sorry-localhost-is-local-not-remote</link>
		<comments>http://www.php-log.de/404/php/554-helo-command-rejected-sorry-localhost-is-local-not-remote#comments</comments>
		<pubDate>Fri, 31 Jul 2009 16:13:57 +0000</pubDate>
		<dc:creator>ralle</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Mail]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[SMTP]]></category>

		<guid isPermaLink="false">http://www.php-log.de/?p=404</guid>
		<description><![CDATA[Vollkommen unerwartet bekomme ich nun diese Fehlermeldung beim Versenden einer E-Mail via SMTP mit der CakePHP Mail Komponente. 554 Helo command rejected: Sorry, localhost is local, not remote. Bei einer anderen Anwendung, die identischen Code verwendet und ebenfalls auf meinen lokalen Rechner läuft klappt der E-Mail-Versand. WTF&#8230; Weder Google noch Bing finden etwas relevantes für [...]]]></description>
			<content:encoded><![CDATA[<p>Vollkommen unerwartet bekomme ich nun diese Fehlermeldung beim Versenden einer E-Mail via SMTP mit der CakePHP Mail Komponente. 554 Helo command rejected: Sorry, localhost is local, not remote. Bei einer anderen Anwendung, die identischen Code verwendet und ebenfalls auf meinen lokalen Rechner läuft klappt der E-Mail-Versand. WTF&#8230;<span id="more-404"></span></p>
<p>Weder Google noch Bing finden etwas relevantes für diese Fehlermeldung. Ich habe noch ein leise Erinnerung an die Probleme die, je nach Provider, mit dem <a title="SMTP Problem" href="http://www.php-log.de/343/php/smpt-450-sender-address-rejected-domain-not-found" target="_blank">SMTP Versand</a> auftreten können. Glücklicherweise stoplterte ich aber im Cake Handbuch über die <a href="http://book.cakephp.org/de/view/481/Sending-A-Message-Using-SMTP" target="_blank">Dokumentation zur Mail Komponente </a>und die weisen Jungs bei CakePHP haben eine Lösung. Es ist der Sendeparameter &#8216;client&#8217;, den ich zuvor nie benötigte und der laut Doku nur bei nicht RFC 821 konformen SMTP Servern benötigt wird. Sobald ich für &#8216;client&#8217; den Host des SMTP Server (oder irgendeinen anderen) eingetragen habe funktioniert der Mailversand.</p>
<p>Warum es vom gleichen Host mit den gleichen SMTP Daten einmal funktioniert und ein anderes mal nicht will sich mir aber trotzdem nicht erschliessen. Naja, es mir aber auch niemals jemand versprochen, dass man als PHP Programmierer ausschliesslich auf einer Blümchenwiese lebt <img src='http://www.php-log.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Achso, hier auch noch das entsprechende Codesample:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> prepareSmtpSending<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Email</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">smtpOptions</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	    <span style="color: #0000ff;">'port'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">25</span><span style="color: #339933;">,</span> 
	    <span style="color: #0000ff;">'timeout'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">30</span><span style="color: #339933;">,</span>
	    <span style="color: #0000ff;">'host'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'mail.irgendwo.de'</span><span style="color: #339933;">,</span>
	    <span style="color: #0000ff;">'username'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'hans'</span><span style="color: #339933;">,</span>
	    <span style="color: #0000ff;">'password'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'wurst'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'client'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'irgendwo.de'</span> <span style="color: #666666; font-style: italic;">// &lt;-- Die Rettung</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Email</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">delivery</span> 	<span style="color: #339933;">=</span> <span style="color: #0000ff;">'smtp'</span><span style="color: #339933;">;</span>		
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.php-log.de/404/php/554-helo-command-rejected-sorry-localhost-is-local-not-remote/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SMPT 450 : Sender address rejected: Domain not found</title>
		<link>http://www.php-log.de/343/php/smpt-450-sender-address-rejected-domain-not-found</link>
		<comments>http://www.php-log.de/343/php/smpt-450-sender-address-rejected-domain-not-found#comments</comments>
		<pubDate>Fri, 05 Jun 2009 03:49:03 +0000</pubDate>
		<dc:creator>ralle</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Mail]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[SMTP]]></category>

		<guid isPermaLink="false">http://www.php-log.de/?p=343</guid>
		<description><![CDATA[Diese kleine böse Falle hat mich gerade locker eine Stunde gekostet. Plötzlich sendet meine SMTP Klasse keine Mails mehr. Bekomme nur diese Fehlermeldung. Okay, wer lesen kann kommt sicher drauf was passiert ist, aber manchmal liest man einfach nicht sondern befragt die einschlägigen Suchmaschienen. Vergebens! Dabei ist der Fehler so offensichtlich. Ich habe versucht mit [...]]]></description>
			<content:encoded><![CDATA[<p>Diese kleine böse Falle hat mich gerade locker eine Stunde gekostet. Plötzlich sendet meine SMTP Klasse keine Mails mehr. Bekomme nur diese Fehlermeldung. Okay, wer lesen kann kommt sicher drauf was passiert ist, aber manchmal liest man einfach nicht sondern befragt die einschlägigen Suchmaschienen. Vergebens!<span id="more-343"></span></p>
<p>Dabei ist der Fehler so offensichtlich. Ich habe versucht mit einem From Header zu senden der dem SMTP Server nicht bekannt war. Konkret am Bespiel der Email Komponente von CakePHP sieht das so aus:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Email</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">smtpOptions</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'port'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">25</span><span style="color: #339933;">,</span> 
    <span style="color: #0000ff;">'timeout'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'host'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'smtp.deinedomain.de'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'username'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'hokus@deinedomain.de'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'password'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'sachichnich'</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Email</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">delivery</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'smtp'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Email</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">to</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;sample@address.com&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Email</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">subject</span> <span style="color: #339933;">=</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Dein Passwort '</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> env<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HTTP_HOST'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Email</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">template</span> 	<span style="color: #339933;">=</span> <span style="color: #0000ff;">'lost_password'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Email</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sendAs</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'both'</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">// Hier passt die Domain home.com nicht zum SMTP Host...</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Email</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">replyTo</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Ich &lt;hans@home.com&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Email</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">from</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Ich &lt;hans@home.com&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Email</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">send</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// ...deswegen dieser nette Fehler</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Email</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">smtpError</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;"># 450 : Sender address rejected: Domain not found
</span>
<span style="color: #666666; font-style: italic;">// So ist's richtig und die Mail wird verschickt</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Email</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">replyTo</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Ich &lt;hans@deinedomain.de&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Email</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">from</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Ich &lt;hans@deinedomain.de&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Email</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">send</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.php-log.de/343/php/smpt-450-sender-address-rejected-domain-not-found/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

