Mail Header and Postfix

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
kkonline
Forum Contributor
Posts: 251
Joined: Thu Aug 16, 2007 12:54 am

Mail Header and Postfix

Post by kkonline »

Hi,
Whenever I send mail it has the following header which takes the mail to spam

Code: Select all

 
 Delivered-To: amigovista@gmail.com
Received: by 10.141.129.17 with SMTP id g17cs376644rvn;
        Fri, 26 Dec 2008 11:05:47 -0800 (PST)
Received: by 10.210.142.10 with SMTP id p10mr177422ebd.95.1230318345065;
        Fri, 26 Dec 2008 11:05:45 -0800 (PST)
Return-Path: <mailer@mysite.com>
Received: from mail.mysite.org (mysite.org [203.54.237.227])
        by mx.google.com with ESMTP id p10si16333536gvf.20.2008.12.26.11.05.43;
        Fri, 26 Dec 2008 11:05:44 -0800 (PST)
Received-SPF: neutral (google.com: 203.54.237.227 is neither permitted nor denied by best guess record for domain of mailer@mysite.com) client-ip=203.54.237.227;
Authentication-Results: mx.google.com; spf=neutral (google.com: 203.54.237.227 is neither permitted nor denied by best guess record for domain of mailer@mysite.com) smtp.mail=mailer@mysite.com
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
    by mail.mysite.org (Postfix) with SMTP id 66C3B4D0100
    for <amigovista@gmail.com>; Fri, 26 Dec 2008 18:52:59 +0000 (UTC)
To: amigovista@gmail.com
From: mailer@mysite.com
Subject: Hey my first email
Message-Id: <20081226185300.66C3B4D0100@mail.mysite.org>
Date: Fri, 26 Dec 2008 18:52:59 +0000 (UTC)
 
This is my first email on debian postfix after installing configuring it.
It was easy. See you
Now I want Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) to be replaced by mysite.org and then check if mail reaches the inbox.

I have postfix running on debian etch. How do I do the required changes

Code: Select all

 
telnet mysite.org 25
Trying 203.54.237.227...
Connected to mysite.org.
Escape character is '^]'.
220 mail.mysite.org ESMTP Postfix (Debian/GNU)
mail from:<mailer@mysite.com>
250 2.1.0 Ok
rcpt to:<amigovista@gmail.com>
data
To: amigovista@gmail.com
From: mailer@mysite.com
Subject: Hey my first email
This is my first email on debian postfix after installing configuring it.
It was easy. See you
554 5.7.1 <amigovista@gmail.com>: Relay access denied
554 5.5.1 Error: no valid recipients
221 2.7.0 Error: I can break rules, too. Goodbye.
Connection closed by foreign host.
but
debian:~# telnet localhost 25 works fine (send mail atleast to spam!!!)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Mail Header and Postfix

Post by Chris Corbyn »

I think ti will be doing a hostname lookup of 127.0.0.1 and getting localhost.localdomain back.

Try editting /etc/hosts and placing mysite.com *before* the localhost name on the 127.0.0.1 line (and if you use ipv6, on the ::1 line).
kkonline
Forum Contributor
Posts: 251
Joined: Thu Aug 16, 2007 12:54 am

Re: Mail Header and Postfix

Post by kkonline »

Hi Chris,
I have updated the /etc/host file however writing hostname results debian.4.x86_64 even on changing the /etc/hostname file. What to do?

Below are the results
debian:~# hostname

Code: Select all

debian.4.x86_64
debian:~# hostname -f

Code: Select all

mysite.org
debian:~# postconf -d | grep localhost.localdomain
debian:~#
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Mail Header and Postfix

Post by Chris Corbyn »

Are you connecting to localhost? It sounds as though you're getting the expected behaviour.
kkonline
Forum Contributor
Posts: 251
Joined: Thu Aug 16, 2007 12:54 am

Re: Mail Header and Postfix

Post by kkonline »

Hi Chris,
the swiftmailer script I have written is on a path on my vps server eg /www/somedir/myscript.php

and from the browser i just run http://mysite.com/path/to/myscript.php
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Mail Header and Postfix

Post by Chris Corbyn »

What I mean is, in your code are you doing this?

Code: Select all

$conn = new Swift_Connection_SMTP('localhost', 25);
kkonline
Forum Contributor
Posts: 251
Joined: Thu Aug 16, 2007 12:54 am

Re: Mail Header and Postfix

Post by kkonline »

Dear Chris,
previously it was localhost,25 but then i had changed it to mysite.org. I believe mysite.org is more preferable as to what i read on your swiftmailer docs

Code: Select all

$swift =& new Swift(new Swift_Connection_SMTP("[mysite.org]"));
Is this ok?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Mail Header and Postfix

Post by Chris Corbyn »

The square brackets are meant for IP literals ;) I'm surprised it connects with those in there but otherwise yes that's fine.

The reason mysite.org is behaving the same as localhost is because it's in your /etc/hosts file so when you connect to mysite.org locally you're actually connecting to 127.0.0.1.

This really should not be a problem and if you're trying to fix a spam issue I think you're getting hung up on the wrong issue ;) The only time identifying ones-self as localhost becomes a problem is when your SMTP server tries to relay mail onto the next MX by identifying itself as "localhost":

HELO localhost

You'd be blocklisted for this though.
Post Reply