[BlueOnyx:17687] Re: phpmailer problem php 5.5

Wisja.net Computers info at wisja.net
Tue May 26 08:42:23 -05 2015


Hi Michael,

First of all, thank you for the great explaination.

These are the log entries in maillog and errorlog. I did not change anything in the
users script before this try. 
You probably need to know that suPHP is activated on all of our sites, and the adminuser
is set to own the WEB files. 

This happens to all php mailscripts, the simple ones (made by users themselfs), but also
scripts from wordpress for instance.

---

Error Log:

[Tue May 26 15:20:51 2015] [error] [client IP adres] malformed header from script. Bad
header=/home/.sites/147/site57/.users: index.php, referer: http://www.domainname.com/contact

---

Maillog:

May 26 15:20:49 srv01 root: sendmail-wrapper-php: site=www.domainname.com, client=SERVER
IP, script=/home/.sites/147/site57/web/index.php, uid=, user=s02077

May 26 15:20:49 srv01 sendmail[3636]: t4QDKne5003636: from=s02077, size=542, class=0,
nrcpts=1, msgid=<201505261320.t4QDKne5003636 at srv01.myservername.com>, relay=s02077 at localhost

May 26 15:20:50 srv01 sendmail[3636]: STARTTLS=client, relay=[127.0.0.1],
version=TLSv1/SSLv3, verify=FAIL, cipher=DHE-RSA-AES256-GCM-SHA384, bits=256/256

May 26 15:20:51 srv01 sendmail[3636]: t4QDKne5003636: to=info at domainname.com,
ctladdr=s02077 (660/559), delay=00:00:02, xdelay=00:00:02, mailer=relay, pri=30542,
relay=[127.0.0.1] [127.0.0.1], dsn=5.6.0, stat=Data format error 

---

If I read the logs correctly the user is set the right way. Could it be that
adding/setting a sender in the header from within the script would cause this?

Also I've tried to reinstall PHP 5.5.22-1 (with Newlinq). The software stops at 95%
"executing post-install scripts". This already happened 2 times on 2 different days
before the 3rd try this morning. Could the installer failing to complete be related?

When doing a phpinfo.php from the server it shows PHP 5.5.22-1 installed, but it never
shows up in the siteadmin under installed software. (and therefor can still be
reinstalled with newlinq).

If you need/want to take a closer look yourself, I'd be more then happy to send the
login details offlist. 

With kind regards,

Wisja

On Sun, 24 May 2015 13:08:45 -0500, Michael Stauber wrote 
> Hi Wisja, 
> 
> > After the update/installation some of my users started complaining that their 
> > mailscripts stopt working. 
> > 
> > We have had that kind of problems in the past with older php scripts and in 
> > those cases adding the -f emailadress to sendmail in php.ini would solve it. 
> > The error seen in de errorlog is: Malformed header from script, followed by the 
> > path to the websites script. 
> > It seems that the -f switch is no longer working with the sendmail directive in 
> > php.ini 
> 
> There are a lot of ways how mail can be sent from PHP scripts. The 
> mail() function is just one of them and it usually works pretty well. 
> 
> However: For security reasons and to make it easier to detect PHP 
> scripts that are used for sending SPAM we handle things a bit different 
> on BlueOnyx: 
> 
> The php.ini has this in it: 
> 
> auto_prepend_file = /usr/sausalito/configs/php/set_php_headers.php 
> sendmail_path = /usr/sausalito/sbin/phpsendmail 
> 
> So emails are not passed directly to Sendmail, but take a small round about. 
> 
> First of all the "auto_prepend_file" is pre-pended to all PHP scripts 
> and sets some environment variables that help us to identify the 
> location of the script and who owns it. 
> 
> If scripts then send emails, those emails don't get passed directly to 
> Sendmail. Instead they are passed to the Perl-script 
> /usr/sausalito/sbin/phpsendmail, which reads the environment variables 
> of the script in question and logs the mail activity from this script to 
> /var/log/maillog: 
> 
> # Log the activity into /var/log/maillog with all the info we have gathered: 
> system("/usr/bin/logger -p mail.info sendmail-wrapper-php: 
> site=$HTTP_HOST, client=$REMOTE_ADDR, script=$PWD$SCRIPT_NAME, uid=$UID, 
> user=$OWNER"); 
> 
> Lastly this Perl script passes the email to Sendmail to actually send it: 
> 
> # Actually send the email by passing it to Sendmail: 
> system("/usr/sbin/sendmail -t -i $*"); 
> 
> The $* at the end makes sure that a sender that was set via -f is 
> appended as well as the actual message to be sent. So you would need to 
> actually set the -f in the script in question. NOT in the php.ini. 
> 
> Or: If you cannot do that for whatever reasons, then enable suPHP and 
> set a "Web Owner" for the virtual site. Emails will then be sent as the 
> user who owns the Vsite. 
> 
> FWIW: The easiest way to send email from PHP is this: 
> 
> mail("$recipient", "$subject", $body, "From:" . $sender); 
> 
> -- 
> With best regards 
> 
> Michael Stauber 
> _______________________________________________ 
> Blueonyx mailing list 
> Blueonyx at mail.blueonyx.it 
> http://mail.blueonyx.it/mailman/listinfo/blueonyx




More information about the Blueonyx mailing list