Page 1 of 1

Swiftmailer sends mail as www-data

Posted: Wed Apr 14, 2010 6:41 am
by henno
Hello!

This code:

$message = Swift_Message::newInstance($data['title'])
->setFrom($data['from'])
->setTo($recipient['email'])
->setBody(stripslashes($data['content']).$unlist.$decoration)
->setContentType("text/html")
->setReturnPath('bounces@mycompany.com');

Produces this:

T <myserver>:39145 -> <dest_server>:25 [AP]
EHLO dev.mycompany.com..
#
T <dest_server>:25 -> <myserver>:39145 [A]
#
T <dest_server>:25 -> <myserver>:39145 [AP]
250-mx.google.com at your service, [<myserver>]..250-SIZE 35651584..250-8BITMIME..250-ENHANCEDSTATUSCODES..250 P
IPELINING..
#
T <myserver>:39145 -> <dest_server>:25 [AP]
MAIL FROM:<www-data@mycompany.com> SIZE=632 BODY=8BITMIME..RCPT TO:<henno@mycompany.com>..DATA..
#
T <dest_server>:25 -> <myserver>:39145 [A]
#
T <dest_server>:25 -> <myserver>:39145 [AP]
250 2.1.0 OK 22si253653ewy.36..
#
T <myserver>:39145 -> <dest_server>:25 [A]
#
T <dest_server>:25 -> <myserver>:39145 [AP]
250 2.1.5 OK 22si253653ewy.36..354 Go ahead 22si253653ewy.36..
#
T <myserver>:39145 -> <dest_server>:25 [A]
#
T <myserver>:39145 -> <dest_server>:25 [AP]
Received: by dev.mycompany.com (Postfix, from userid 33)...
id B385143C1; Wed, 14 Apr 2010 14:29:00 +0300 (EEST)..
To: henno@mycompany.com..
Subject: henno3..
X-PHP-Originating-Script: 33:MailSend.php..
From: henno@mycompany.com..
Reply-To: henno@mycompany.com..
Date: Wed, 14 Apr 2010 14:29:00 +0300..
X-LibVersion: 3.3.2..
MIME-Version: 1.0..
Content-Type: text/html; charset=utf-8; format=flowed..
Content-Transfer-Encoding: 8bit..
Message-ID: <20100414112900.14396.1364101199.swift@dev.mycompany.com>....
QUIT..
#
T <dest_server>:25 -> <myserver>:39145 [A]
#
T <dest_server>:25 -> <myserver>:39145 [AP]
250 2.0.0 OK 1271244559 22si253653ewy.36..221 2.0.0 closing connection 22si253653ewy.36..

I need MAIL FROM:<www-data@mycompany.com> to be MAIL FROM:<bounces@otherdomain.com>

SMTP is local Postfix.

Re: Swiftmailer sends mail as www-data

Posted: Wed Apr 14, 2010 9:09 am
by mikosiko
Did you check what information contain
->setFrom($data['from'])

I normally use this way (extract):

Code: Select all

$message = Swift_Message::newInstance()
  //Give the message a subject
  ->setSubject($vSubject)
  //Set the From address with an associative array
  ->setFrom(array('myuser@mydomain.com' => 'UserAlias'))