<?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>Thijs Lensselink&#039;s Blog &#187; Postfix</title>
	<atom:link href="http://lenss.nl/tag/postfix/feed/" rel="self" type="application/rss+xml" />
	<link>http://lenss.nl</link>
	<description>Webdevelopment and stuff...</description>
	<lastBuildDate>Thu, 26 Apr 2012 21:48:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Postfix with Dovecot results in MySQL Access denied</title>
		<link>http://lenss.nl/2009/06/postfix_dovecot_mysql_access_denied/</link>
		<comments>http://lenss.nl/2009/06/postfix_dovecot_mysql_access_denied/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 16:57:52 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Dovecot]]></category>
		<category><![CDATA[MySql]]></category>
		<category><![CDATA[Postfix]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=465</guid>
		<description><![CDATA[While installing a new mail server i ran into a problem with SMTP authentication. The mail server in question is postfix installed on a Debian lenny box. The backend for postfix is MySQL. And because SASL is always a pain to configure i used dovecot to do the SMTP authentication with the MySQL backend. This [...]]]></description>
			<content:encoded><![CDATA[<p>While installing a new mail server i ran into a problem with SMTP authentication. The mail server in question is postfix installed on a Debian lenny box. The backend for postfix is MySQL. And because <a href="http://asg.web.cmu.edu/sasl/">SASL</a> is always a pain to configure i used <a href="http://www.dovecot.org/">dovecot</a> to do the SMTP authentication with the MySQL backend. This however resulted in the following error </p>
<blockquote><p>Jun 21 17:43:02 ims1 dovecot: auth-worker(default): mysql: Connect failed to localhost (mail): Access denied for user &#8216;mail_admin&#8217;@'localhost&#8217; (using password: YES) &#8211; waiting for 1 seconds before retry</p></blockquote>
<p>It took me a while to figure this out. The settings in &#8216;dovecot-sql.conf&#8217; were correct. Logging in with the same data from a shell went without a problem. I remembered i had this problem some years ago. With a <a href="http://www.inter7.com/index.php?page=vpopmail">vpopmail</a> setup. The problem then was the encryption algorithm used by MySQL. So i tried to use the older encryption algorithm.</p>
<blockquote><p>SET PASSWORD FOR &#8216;user&#8217;@'localhost&#8217; = OLD_PASSWORD(&#8216;password&#8217;);</p></blockquote>
<p>After a restart everything was fine. </p>
<blockquote><p>Jun 21 18:41:03 ims1 dovecot: auth-worker(default): mysql: Connected to localhost (mail)</p></blockquote>
<p>Like i said it took me a while to figure out. So maybe i can safe somebody some time.</p>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2009/06/postfix_dovecot_mysql_access_denied/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Making PHP mail work on Ubuntu through Postfix</title>
		<link>http://lenss.nl/2009/01/making-php-mail-work-on-ubuntu-through-postfix/</link>
		<comments>http://lenss.nl/2009/01/making-php-mail-work-on-ubuntu-through-postfix/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 11:43:24 +0000</pubDate>
		<dc:creator>Thijs Lensselink</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Mail]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Postfix]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://lenss.nl/?p=232</guid>
		<description><![CDATA[While writing a small mail application in PHP i noticed i couldn&#8217;t send mail from my local machine. Even with telnet i couldn&#8217;t send out emails. I quickly found out that postfix and sendmail on the same system is not a good idea. Seems it was a left over from some testing i did. So [...]]]></description>
			<content:encoded><![CDATA[<p>While writing a small mail application in PHP i noticed i couldn&#8217;t send mail from my local machine. Even with telnet i couldn&#8217;t send out emails. I quickly found out that postfix and sendmail on the same system is not a good idea. Seems it was a left over from some testing i did. So after wiping sendmail and postfix from the system. And reinstalling only postfix i got an error when starting Postfix</p>
<blockquote><p>postfix: fatal: /etc/postfix/postfix-script: No such file or directory</p></blockquote>
<p>So let&#8217;s try and completely remove the postfix package and purge all files.</p>
<blockquote><p>
$ sudo dpkg &#8211;remove postfix<br />
$ sudo dpkg &#8211;purge postfix
</p></blockquote>
<p>And a clean install of postfix:</p>
<blockquote><p>$ sudo apt-get -V install postfix</p></blockquote>
<p>Now i can telnet in and try to send some mail. And this seemed to work. The mail got delivered.</p>
<blockquote><p>
$ telnet localhost 25</p>
<p>Trying 127.0.0.1&#8230;<br />
Connected to localhost.<br />
Escape character is &#8216;^]&#8217;.<br />
220 0&#215;0 ESMTP Postfix (Ubuntu)</p>
<p>helo test.nl<br />
250 0&#215;0<br />
mail from: test@test.nl<br />
250 2.1.0 Ok<br />
rcpt to: some@working.address<br />
250 2.1.5 Ok<br />
data<br />
354 End data with <CR><LF><CR><LF><br />
testing<br />
.<br />
250 2.0.0 Ok: queued as ED97311C412F</p></blockquote>
<p>So now let&#8217;s make sure it also works from PHP. I tested it through a CLI script and through apache2. With the most basic mail script you can imagine. </p>
<pre name="code" class="php">
    mail('some@working.address', 'test', 'test message');
</pre>
<p>The mail however gets bounced.</p>
<blockquote><p>
Jan  7 22:31:48 0&#215;0 postfix/pickup[10249]: 035BF11C4133: uid=1 from=<daemon><br />
Jan  7 22:31:48 0&#215;0 postfix/cleanup[11726]: 035BF11C4133: message-id=<20090107213148.035BF11C4133@0x0><br />
Jan  7 22:31:48 0&#215;0 postfix/qmgr[10250]: 035BF11C4133: from=<daemon@internal.name>, size=303, nrcpt=1 (queue active)<br />
Jan  7 22:31:48 0&#215;0 postfix/smtp[11728]: 035BF11C4133: to=<some@working.address>, relay=working.mail.server[xx.xxx.xx.xx]:25, delay=0.68, delays=0.02/0/0.48/0.18, dsn=5.0.0, status=bounced (host working.mail.server[xx.xxx.xx.xx] said: 553 sorry, your envelope sender domain must exist (#5.7.1) (in reply to MAIL FROM command))<br />
Jan  7 22:31:48 0&#215;0 postfix/cleanup[11726]: C5C2911C4134: message-id=<20090107213148.C5C2911C4134@0x0><br />
Jan  7 22:31:48 0&#215;0 postfix/qmgr[10250]: C5C2911C4134: from=<>, size=2064, nrcpt=1 (queue active)<br />
Jan  7 22:31:48 0&#215;0 postfix/bounce[11729]: 035BF11C4133: sender non-delivery notification: C5C2911C4134<br />
Jan  7 22:31:48 0&#215;0 postfix/qmgr[10250]: 035BF11C4133: removed<br />
Jan  7 22:31:49 0&#215;0 postfix/smtp[11728]: C5C2911C4134: to=<daemon@internal.name>, relay=working.mail.server[xx.xxx.xx.xx]:25, delay=0.75, delays=0.01/0/0.41/0.34, dsn=2.0.0, status=sent (250 ok 1231363909 qp 10204)<br />
Jan  7 22:31:49 0&#215;0 postfix/qmgr[10250]: C5C2911C4134: removed
</p></blockquote>
<p>From looking at the log files i can tell it bounced because the from address is set to <strong>daemon@internal.name</strong>. And internal.name is not known by my mail server. Let&#8217;s try that again. But this time specifically set the FROM header.</p>
<pre name="code" class="php">
    $headers .= 'To: Name <some@working.addressl>' . "\n";
    $headers .= 'From: test <some@working.address>' . "\n";
    mail('some@working.address', 'test', 'test message', $headers);
</pre>
<p>The result is the same. The FROM header didn&#8217;t change at all. So although it&#8217;s possible to set the from header. The message is always send by a system user.. So after doing some research on Google about this problem it seems possible to pass an extra parameter to the mail() function. This parameter can contain a string which will be passed to the postfix binary as an extra parameter. So adding <strong>-fsome@orking.address</strong> makes the problem go away.</p>
<blockquote><p>
Jan  7 22:36:58 0&#215;0 postfix/pickup[10249]: 687CA11C4133: uid=1 from=<some@working.address><br />
Jan  7 22:36:58 0&#215;0 postfix/cleanup[11847]: 687CA11C4133: message-id=<20090107213658.687CA11C4133@0x0><br />
Jan  7 22:36:58 0&#215;0 postfix/qmgr[10250]: 687CA11C4133: from=<some@working.address>, size=276, nrcpt=1 (queue active)<br />
Jan  7 22:36:59 0&#215;0 postfix/smtp[11849]: 687CA11C4133: to=<some@working.address>, relay=working.mail.server[xx.xxx.xx.xx]:25, delay=1.4, delays=0.02/0/0.59/0.76, dsn=2.0.0, status=sent (250 ok 1231364219 qp 10582)<br />
Jan  7 22:36:59 0&#215;0 postfix/qmgr[10250]: 687CA11C4133: removed</p></blockquote>
<p>But this would mean that i always have to pass the extra parameter. And if i use a third party class or function. i may not be able to do so without hacking the code. So although it solves the problem it&#8217;s not the final solution. After i bit of browsing i found out that changing the <strong>myorigin</strong> parameter in <strong>/etc/postfix/main.cf</strong> to a known mail server. I could start the send out mail. So i changed it to the domain my mail server runs under.</p>
<blockquote><p>
myorigin = mail.server
</p></blockquote>
<p>And now sending mail from PHP works. </p>
]]></content:encoded>
			<wfw:commentRss>http://lenss.nl/2009/01/making-php-mail-work-on-ubuntu-through-postfix/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
