Blank Subject with Phpmailer on Zend i5/OS
An online job application system that emails an administrator the application once it was submitted wasn't sending the email. On my local machine it worked fine, but as soon as I tried on wcdev it didn't work. The first fix was to use Phpmailer since Zend i5/OS doesn't support the mail() function.
So the emails were being sent but a lot of times there was no subject line, or in other words it was left blank. After much trial and error and many file pushes thanks to Ryan, I figured out that it only happens when there is a file attached to the email.
After more exploration I saw that the subject was being passed correctly to the send function, but that it still wasn't being set for some reason.
For one reason or another Zend ignores the subject field in the mail() function, but everything in the body and headers was showing correctly.
So the quick fix I found is to set the subject in the email header. So far it is working just like it should.
The quick hack is on line 909 or so of the PHPMailer class file:
/* mail() sets the subject itself */ // if($this->Mailer != 'mail') { // $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject))); // } //The subject must be set in the header for the Zend i5/OS $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject))); |
Print This Post
find your .ini
Sometimes I dabble in php a little so when I run onto something I wanna remember I like to tuck it away somewhere where I'll remember where it is. This handy little snippet will tell you where your php.ini file is loading from. This is especially useful if you are using xampp/wampp/lampp since they tend to have multiple php.ini files and it's anyones guess which one they are using (at least xampp does).
<?php /*****CHECK TO SEE WHAT PHP.INI FILE IS LOADING*******/ $path = php_ini_loaded_file(); if ($path) { echo 'path to php.ini: ' . $path; } else { echo 'A php.ini file is not loaded'; } ?> |
Here's a quick game, who can tell me how many times the word "where" was used in this post (including "somewhere")?
Print This Post
Automatic FTP
A few weeks ago I was looking for a way to automate downloading thousands of files from an ftp site, I figured using php would be sufficient since that is what the site I was working with used. I tried google and some of the better php sites but to no avail. So I found some code that was similar to what I wanted and tweaked (and by tweaked i mean almost completely rewrote) it to suit my needs. Now I'm not claiming to be a php genius (or any kind of genius for that matter) but I'm pretty impressed with what I came up with. In a nutshell what this code does is open up a mysql session and an ftp session to a remote server, then it runs a query in the mysql database to create an array for php to use. Then it loops through each item in the array and checks with the remote ftp server for the file, updates to that file (time based), and if the file matches a certain size to be ignored.
This turned out to be quite handy because by the time I was done I could modify the code slightly and search in different locations on the server as well as store the files on a different spot on my local machine.
To test this I ran a 13k item array through this script and it was quite flawless...took about 3.5 hours to run but that's still way faster than downloading by hand even if you include the time it took to write the script.
So I decided to share this script since i couldn't find one myself, feel free to modify it in any way, if you find a way to make it better, more efficient or even hyperthread the downloads I'd like to know so please send an email with the code. Just make sure something like ftpgrabber is in the subject line...otherwise you'll get deleted as spam er somethin'.
Print This Post