No version string in SwiftMailer 4.0.0?

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
HHahn
Forum Commoner
Posts: 43
Joined: Mon Mar 02, 2009 9:16 am
Location: Veldhoven, Netherlands

No version string in SwiftMailer 4.0.0?

Post by HHahn »

When I have a website generate e-mails (so far, I always used PHP mail()), I want to include an "X-mailer" header line with a value like "SwiftMailer (version 4.0.0) at http://www.mysite.tld". Obviously, I do not want to edit the version number into this line. I want it to be supplied by the software. For PHP mail, I used

Code: Select all

sprintf ("X-Mailer: PHP mail() function (PHP %s) at http://www.mysite.tld\n", phpversion ());
which works fine.
For SwiftMailer 3.3.3 I did something similar, using $Swift::VERSION to obtain the current version number.
First of all, to my amazement, SwiftMailer 3.3.3 returned a version value of "3.3.2" instead of the expected "3.3.3".
But SwiftMailer 4.0.0 did not know any constant VERSION at all.

May I suggest that in a next release some method ::getVersion() be added on the main class, so that the software can always be asked to present its current version number?
Also for debugging purposes this me be helpful. (Consider a developer who made several websites, using different version of SwiftMailer over time. When a customer complains, he must be able to report what version that particular website is using.)

This is very simple and it does not affect normal operation of the software, so it may be included in the next sub-release or whatever.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: No version string in SwiftMailer 4.0.0?

Post by Chris Corbyn »

I'll throw a ticket in for this. I'm not sure I'll out anything in the message headers that identifies Swift Mailer, but I'll add a getVersion() method, or possibly a global constant SWIFT_VERSION or something?

The reason I've left it out of the message headers is because people keep asking me to and people tell me it triggers spam blockers. I know this isn't true since it's just an X-* header and it's not compliant to discriminate based on such headers, but if it keeps people quiet then so be it :)

Would a SWIFT_VERSION constant do the trick for you? Otherwise I'm not sure which class it would belong inside.

The reason 3.3.3 had the wrong version number was because I forgot to update it before I released... easily done... I'll have to integrate it into the build process (I use Ant) so that it reads from the VERSION file and creates the version number from that. I can't forget to update the VERSION file anymore, since it's used by my build script in order to generate the filename of the .tar.gz file.

EDIT | With regards to adding the version number, if I create a SWIFT_VERSION constant and you want your end users to reveal this info to you, it's possible to add like this:

Code: Select all

$message->getHeaders()->addTextHeader('X-LibVersion', SWIFT_VERSION);
HHahn
Forum Commoner
Posts: 43
Joined: Mon Mar 02, 2009 9:16 am
Location: Veldhoven, Netherlands

Re: No version string in SwiftMailer 4.0.0?

Post by HHahn »

Would a SWIFT_VERSION constant do the trick for you?
Basically it would. But a class-enclosed definition would be safer (one of the basic principles of OO programming). So a getVersion() would be preferable.
Otherwise I'm not sure which class it would belong inside.
I suggest within the "main" class, i.e. the one used first. That is probably Swift_Message. I agree that the version does not refer to the message, but to the software used. But the class here only acts as a vehicle to provide the version value. It is up to the website developer to correctly use this value.
The reason I've left it out of the message headers is because people keep asking me to
You don't need to put it into any header. If you just make it available, it is up to the website developer whether or not he uses it.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: No version string in SwiftMailer 4.0.0?

Post by Chris Corbyn »

I may create a "Swift" class that contains such information. Currently there is no "Swift" class like there was in version 3 ;)

I've also got an idea so that it will appear in the message headers, but with the option to turn it off.

http://swiftmailer.lighthouseapp.com/pr ... l-constant

I'll sort this tomorrow. Pretty busy studying other character set handling implementations to improve performance in 4.1 at the moment :)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: No version string in SwiftMailer 4.0.0?

Post by Chris Corbyn »

Version number as of 4.0.2 will always be available via Swift::VERSION constant:

http://swiftmailer.org/downloads/get/Swift-4.0.2.tar.gz

If you want this information in the message headers:

Code: Select all

$message->addTextHeader('X-Mailer', sprintf('Swift Mailer %s', Swift::VERSION));
This version number will *always* match the version number of the file you downloaded due to the way it's generated.
Post Reply