views:

76

answers:

1

I'm trying to change the User-Agent and X-Mailer headers sent out by CodeIgniter's email class, so that there's no way that anyone can find out that the website is running on the CI framework.

As per the manual, I've made an application/config/email.php file containing the following:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$config['mailtype'] = 'html';
$config['useragent'] = 'MyUseragentHere';

When I look at the headers in the incoming emails, they look like this:

User-Agent: CodeIgniter
X-Mailer: MyUseragentHere

Note that one of the headers has been changed by CI but the other hasn't?! Any suggestions on how to fix without editing the CI system files (want to keep things nice and clean in case of future upgrades etc.) much appreciated.

+1  A: 

Very strange, try calling $this->email->clear() you shouldn't have to but this is where it sets the user agent in the code.

If it's still not changing, change var $useragent in the system file temporarily to see if that works.

fire
@fire - The `$this->email->clear()` fixed the problem, many thanks. Although I'd much rather I didn't have to call this every time I want to send an email! Do you have any idea of a more permanent fix, which still doesn't involve editing the system files?
chigley
You could also try running email->initialize() when you first call the class as this will invoke the same method (even though you shouldn't have to according to CI documentation) just looks a bit cleaner.
fire