HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Installation/Configuration (http://www.howtoforge.com/forums/forumdisplay.php?f=16)
-   -   php email script www-data (http://www.howtoforge.com/forums/showthread.php?t=27049)

cat 23rd September 2008 08:36

php email script www-data
 
Thanks for a great product, ispconfig is making site management much easer.

I am writing a php script that sends an email to the user who fills in a form, and a copy of the email to the sales department of the site. When the out ward bound email arrives the Recipient/From looks like www-data@mail.myserver.mydomain.com when it should look like sales@mydomain.com and the email that should go to the sales department never arrives.

I have setup the site with two Co-Domains both with DNS: and DNS MX: ticked

ip_address www mydomain.com
ip_address mydomain.com

I have set up two users
user1 user1@mydomain.com
user2 sales@mydomain.com

when I view the mail source of the test email the arrives I see (ip addresses changed to protect the innocent).

From www-data@mail.myserver.mydomain.com Tue, 23 Sep 2008 00:00:51 -0400
Received: from kumquat.safe-mail.net ([0.0.0.])
by tamar.safe-mail.net with smlocal (smtas 1.2);
Tue, 23 Sep 2008 00:01:21 -0400
DomainKey-Status: not-signed (some+real)
X-SMTests: g00nmp0i0b0aR00u
Received: from 0.0.0.0.dynamic.rev.aanet.com.au ([0.0.0.0] helo=mail.myserver.mydomain.com)
by kumquat.safe-mail.net with esmtp (TLSv1/SSLv3:AES256-SHA:256) (smtpd 1.0)
id N1K-PWiIWDsmZX
for myaccount@safe-mail.net; Tue, 23 Sep 2008 00:00:51 -0400
Received-SPF: no-spf
Received: by mail.myserver.mydomain.com (Postfix, from userid 33)
id 15929186C0; Tue, 23 Sep 2008 12:01:02 +0800 (WST)
To: myaccount@Safe-mail.net
Subject: Your Quote Request
MIME-Version: 1.0

Content-type: text/html; charset=iso-8859-1

To: myaccount@Safe-mail.net

From: sales@mydomain.com

Cc:

Message-Id: <20080923040102.15929186C0@mail.myserver.mydomain. com>
Date: Tue, 23 Sep 2008 12:01:02 +0800 (WST)

Ben 23rd September 2008 09:27

It's more about how you send your e-mail via php. If you e.g. just use mail() with out any special parameters to set the From, the sender will look like the user sending the e-mail, which in this case is your apache, running as www-data.
To avoid this, either set the X-From or directly use the pear mail class and directly send it via smtp over the appropriate mailbox.

cat 28th September 2008 13:40

email address remapping?
 
Thanks for your reply Ben.
Your response solved the www-data problem.

However the problem with the internal emails (emails sent to other mail boxes on the same server) persists. Eg no email arrives. This happens whether you send a mail form squirrelmail or a php page, and the error messages are the same.

Having a look at the mail.log file the lost mail is trying to go to web1_username@mail.hostserver.hostdomain.com.

The host serverís fqdn is hostserver.hostdomain.com the site fqun is mydomain.com

Any ideas how to fix this problem.

###################################
#
# ISPConfig virtusertable Configuration File
# Version 1.0
#
###################################
username@www.otherdomain.com web1_username
web1_username@www.otherdomain.com web1_username
username@otherdomain.com web1_username
web1_username@otherdomain.com web1_username
franchising@www.mydomain.com web2_username
links@www.mydomain.com web2_username
username@www.mydomain.com web2_username
web2_username@www.mydomain.com web2_username
franchising@mydomain.com web2_username
links@mydomain.com web2_username
username@mydomain.com web2_username
web2_username@mydomain.com web2_username
sales@www.mydomain.com web2_sales
web2_sales@www.mydomain.com web2_sales
sales@mydomain.com web2_sales
web2_sales@mydomain.com web2_sales

mail.log

Sep 28 17:13:23 hostserver postfix/smtpd[9057]: connect from localhost[127.0.0.1]
Sep 28 17:13:23 hostserver postfix/smtpd[9057]: C592F183AB: client=localhost[127.0.0.1]
Sep 28 17:13:23 hostserver postfix/cleanup[9060]: C592F183AB: message-id=<3978.192.168.0.2.1222593203.squirrel@hostserve r.hostdomain.com>
Sep 28 17:13:23 hostserver postfix/qmgr[7164]: C592F183AB: from=<username@mydomain.com>, size=757, nrcpt=1 (queue active)
Sep 28 17:13:23 hostserver imapd: Connection, ip=[::ffff:127.0.0.1]
Sep 28 17:13:23 hostserver postfix/smtpd[9057]: disconnect from localhost[127.0.0.1]
Sep 28 17:13:23 hostserver postfix/smtp[9061]: C592F183AB: to=<web1_username@mail.hostserver.hostdomain.com>, orig_to=<username@otherdomain.com>, relay=none, delay=0.17, delays=0.08/0.09/0.01/0, dsn=5.4.4, status=bounced (Host or domain name not found. Name service error for name=mail.hostserver.hostdomain.com type=AAAA: Host not found)
Sep 28 17:13:23 hostserver postfix/cleanup[9060]: F10DE186C0: message-id=<20080928091323.F10DE186C0@hostserver.hostdomai n.com>
Sep 28 17:13:24 hostserver postfix/qmgr[7164]: F10DE186C0: from=<>, size=2943, nrcpt=1 (queue active)
Sep 28 17:13:24 hostserver postfix/bounce[9064]: C592F183AB: sender non-delivery notification: F10DE186C0
Sep 28 17:13:24 hostserver postfix/qmgr[7164]: C592F183AB: removed
Sep 28 17:13:24 hostserver postfix/smtp[9061]: F10DE186C0: to=<web2_username@mail.hostserver.hostdomain.com>, orig_to=<username@mydomain.com>, relay=none, delay=0.04, delays=0.03/0.01/0/0, dsn=5.4.4, status=bounced (Host or domain name not found. Name service error for name=mail.hostserver.hostdomain.com type=AAAA: Host not found)
Sep 28 17:13:24 hostserver postfix/qmgr[7164]: F10DE186C0: removed
Sep 28 17:13:24 hostserver imapd: LOGIN, user=web2_username, ip=[::ffff:127.0.0.1], port=[57396], protocol=IMAP
Sep 28 17:13:24 hostserver imapd: LOGOUT, user=web2_username, ip=[::ffff:127.0.0.1], headers=0, body=0, rcvd=647, sent=204, time=0
Sep 28 17:13:24 hostserver imapd: Connection, ip=[::ffff:127.0.0.1]
Sep 28 17:13:24 hostserver imapd: LOGIN, user=web2_username, ip=[::ffff:127.0.0.1], port=[57397], protocol=IMAP
Sep 28 17:13:24 hostserver imapd: LOGOUT, user=web2_username, ip=[::ffff:127.0.0.1], headers=524, body=0, rcvd=232, sent=2098, time=0

cat 29th September 2008 06:18

problrm solved
 
Hi guys,
After further investigation I descovered that I had entered a mistake during the setup.
I had put mail.hostserver.hostdomain.com insted of hostserver.hostdomain.com in etc/mailname , now all is working fine.

thanks for your help

PS can you please find a way to encourage users to report how they solved there problems so that we can all benefit.


All times are GMT +2. The time now is 03:24.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.