Jack_mcs Posted October 15, 2009 Author Share Posted October 15, 2009 Thanks for posting your code. It sounds like it might be useful to others. Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
mr_absinthe Posted October 23, 2009 Share Posted October 23, 2009 Jack, Â I'm still experiencing the same issue as last year, but it is getting worse. Â One of our customers reported the issue and forwarded our message - "the From field in this email I received from you. Almost 2500 repeats of the from address "[email protected]." Â I've not been counting those From fields, but there were a lots! Â Any idea what might be causing it please? I need to be pointed some direction where to look at. Â It cannot be related to php (now on 5, before on 4) nor sql (now on 5). Quote Absinthe Original Liquor Store Link to comment Share on other sites More sharing options...
Jack_mcs Posted October 23, 2009 Author Share Posted October 23, 2009 (edited) I'm still experiencing the same issue as last year, but it is getting worse. Â One of our customers reported the issue and forwarded our message - "the From field in this email I received from you. Almost 2500 repeats of the from address "[email protected]." Â I've not been counting those From fields, but there were a lots! Â Any idea what might be causing it please? I need to be pointed some direction where to look at. Â It cannot be related to php (now on 5, before on 4) nor sql (now on 5). While I can almost remember everything I did yesterday (sometimes), :) I can't remember what problem you were having a year ago. Are you saying the customer received 2,500 emails? If so, and if that matches the number of your customer accounts, then it would seem the loop isn't working properly in that part of the code. But without knowing which part of the application it is, I can't suggest what to look at. Edited October 23, 2009 by Jack_mcs Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
mr_absinthe Posted October 24, 2009 Share Posted October 24, 2009 I'm sorry, I forgot to mention the post number, it is post #153 and #156. :blush:  The customer received one email only, but the "From" field contained some 2500 our email addresses (or the "From: field was repeated 2500 times) . It looked like this:  From: [email protected] From: [email protected] From: [email protected] From: [email protected] From: [email protected] From: [email protected] From: [email protected] From: [email protected] etc, etc  I've contacted my host and they confirmed that the problem's source is going to lie in the PHP code. Quote Absinthe Original Liquor Store Link to comment Share on other sites More sharing options...
Jack_mcs Posted October 25, 2009 Author Share Posted October 25, 2009 My reply would be the same as before for the most part. The loop is controlled by the results from the database query. It's a pretty simply loop:  - fetch an entry from the database querry - if the date falls within range, send the email - start over  If multiple emails are being sent, it seems like it would have to be multiple entries in the database that match the date range and has that customers email address. It could also be that the date comparison code is failing. Are your dates enterered in UL format by chance? That would break the code since it assumes mm/dd/yyyy not dd/mm/yyyy. Other than that, it would be a difficult problem to isolate unless you can make it fail at will. Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
mr_absinthe Posted October 26, 2009 Share Posted October 26, 2009 My reply would be the same as before for the most part. The loop is controlled by the results from the database query. It's a pretty simply loop:  - fetch an entry from the database querry - if the date falls within range, send the email - start over  If multiple emails are being sent, it seems like it would have to be multiple entries in the database that match the date range and has that customers email address. It could also be that the date comparison code is failing. Are your dates enterered in UL format by chance? That would break the code since it assumes mm/dd/yyyy not dd/mm/yyyy. Other than that, it would be a difficult problem to isolate unless you can make it fail at will. No, No multiple emails, the customer received one email only, his birthday was OK, the only problem was that the sender of that email, the "From: [email protected]" field in email header was repeated 2500 times. Quote Absinthe Original Liquor Store Link to comment Share on other sites More sharing options...
mr_absinthe Posted November 20, 2009 Share Posted November 20, 2009 Jack,  as mentioned above, it is ongoing issue with the "From: [email protected]" field in email header being repeated 2500 times. Understand - one message, but thousands of "From fields". Different recipients, and I've exhausted all options.  I also wanted to ask you - is there a possibility to force change the Return-path and envelope-from? Since these messages are cron generated, these two fields (Return-path and envelope-from) are showing email address in the following form: username@name_of_the_server.com. This will have the one and only output: NONE OF THOSE MESSAGES IS DELIVERED! The reason is quite simple:  SMTP error from remote mail server after MAIL FROM: SIZE=2845: host mx4.comcast.net [76.96.26.14]: 550 5.1.0 Invalid sender domain  SMTP error from remote mail server after MAIL FROM: SIZE=4341: host manxnetsf05.manx.net [195.10.115.234]: 501 Sender domain must exist  Many people using this excellent (in my humble opinion) contribution will not even notice that those messages are NOT being delivered to customers - simply because the return path is [email protected]. If we can change those fields (Return-path and envelope-from), all will be fine again. Quote Absinthe Original Liquor Store Link to comment Share on other sites More sharing options...
Jack_mcs Posted November 20, 2009 Author Share Posted November 20, 2009 You can try editing the $CustomHeaders variable in the various module files. Something like $CustomerHeaders = "Return-Path: [email protected]" Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
mr_absinthe Posted November 21, 2009 Share Posted November 21, 2009 You can try editing the $CustomHeaders variable in the various module files. Something like $CustomerHeaders = "Return-Path: [email protected]" Â Thank you for your reply, it doesn't seem to help. I do not think that this could be changed in the file - that is according to my research I did. I'll report more as soon as I'll be sure. BUT... I have also did some testing relating to the "From" field as mentioned earlier - I know that you probably don't like this subject <_< Â What is happening is that the whole header is being multiplied by the number of messages being sent on that day! I'm talking about these three fields in auto_announce.php: $headers .= 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n"; $headers .= "From: ". $Name . " <" . $email . ">\n"; Â The very first message that is executed by the script, is perfectly OK and will have this in the header: MIME-Version: 1.0 Content-type: text/html; charset=iso-8859-1 From: My Store <[email protected]> Â The second message created and sent will have it twice there: MIME-Version: 1.0 Content-type: text/html; charset=iso-8859-1 From: My Store <[email protected]> MIME-Version: 1.0 Content-type: text/html; charset=iso-8859-1 From: My Store <[email protected]> Â Third message three times and so on. If there is 258 messages being sent on that day, the very last message will have the header inserted 258 times! Â Jack, I do not want to bother you, I've spent countless hours trying to find out what might be causing it and I'm please that I've found the scenario at least. It is not server related as I've experienced the same problem years ago and I've since moved to a different server, php and mySQL. There must be some coding error that is causing it... Shall I post the whole auto_announce.php? Quote Absinthe Original Liquor Store Link to comment Share on other sites More sharing options...
Jack_mcs Posted November 21, 2009 Author Share Posted November 21, 2009 Find the folowing $tmessage->Send(); and add after it $tmessage->Clear(); Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
mr_absinthe Posted November 21, 2009 Share Posted November 21, 2009 Hmm, I don't know what to tell you. It all works fine so it must be server specific. The program uses a mail class to send the emails. Maybe there is something in there that is causing this. The following code is taken from the email function in oscommerce. You can add the following to the bottom of the file, replacing the line $tmessage->Send(); with $headers = 'MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";$headers .= '[email protected]' . "\r\n";$headers .= '[email protected]' . "\r\n";mail($to, 'test', $message, $headers); If the mail is received properly, then it is the mail class.Jack Since I was having problems with html, you suggested replacing the line $tmessage->Send(); with $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= '[email protected]' . "\r\n"; $headers .= '[email protected]' . "\r\n"; mail($to, 'test', $message, $headers); back in 2006, more in post 73. Therefore my code was like this: Â // Mail it $tmessage->SetHtmlContent($message); $serverFileMimeType = 'text/html'; $tmessage->SetFileContent($pathToServerFile, $serverFileMimeType); // $tmessage->Send(); // changed to \n instead of \r\n below - otherwise no html - mr_absinthe $headers .= 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n"; $headers .= "From: ". $Name . " <" . $email . ">\n"; mail($Recipiant, $Subject, $message, $headers); Â Therefore inserting $tmessage->Clear(); did not help. Â After reverting it back to the original and inserting the line, all seems to be fine, the code now looks: // Mail it $tmessage->SetHtmlContent($message); $serverFileMimeType = 'text/html'; $tmessage->SetFileContent($pathToServerFile, $serverFileMimeType); $tmessage->Send(); $tmessage->Clear(); Â AND THE PROBLEM IS GONE!!! THANK YOU!!! And I hope that this post can help someone as well. Â I also wanted to modify the $Sender - the "From:" field is showing the email address only at the moment, I've therefore modified the code in auto_emailer.php //Set some common items $Name = 'My Store'; $email = '[email protected]'; $Sender = ''. $Name . ' <' . $email . '>'; $Recipiant = ''; $Cc = ''; $Bcc = ''; $currentDate = date('Y-m-d'); Â However it doesn't work, the "From:" field is still showing email address only. As you can see above, it was working fine with $headers. Quote Absinthe Original Liquor Store Link to comment Share on other sites More sharing options...
Jack_mcs Posted November 22, 2009 Author Share Posted November 22, 2009 It is probably due to the strval function used in the email class that code uses. You can try finding this line in class.Email.php $this->From = strval($from); and changing it to $this->From = $from; Or maybe editing the Email function in that file to accept the additional data and build the from string within it. Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
mr_absinthe Posted November 22, 2009 Share Posted November 22, 2009 Jack, the following change in class.Email.php made no difference $this->To = strval($to); // $this->From = strval($from); $this->From = $from; $this->Subject = strval($subject); $this->Headers = strval($headers);  despite the fact that I have tried $Sender = 'My Store <[email protected]>'; as well as this $Name = 'My Store'; $email = '[email protected]'; $Sender = ''. $Name . ' <' . $email . '>'; in auto_emailer.php  Any other ideas? Could it be the line 223 in class.Email.php? //** start generating headers for the message. Add the from email address and //** the current date of sending. $headers = 'Date: ' . date('r', time()) . EmailNewLine . 'From: ' . strval($this->From) . EmailNewLine; Quote Absinthe Original Liquor Store Link to comment Share on other sites More sharing options...
Jack_mcs Posted November 22, 2009 Author Share Posted November 22, 2009 It could be. I haven't tried it. I'll leave that for your enjoyment. :) Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
mr_absinthe Posted December 7, 2009 Share Posted December 7, 2009 OK Jack, it appears that after some testing, I made a progress with the message header... I have the ReturnPath working as well as the Reply-To address. What I would also like to change is the "To:" field. I think that it is important to take every possible step to avoid being considered as spammer these days, therefore it should be always personalized to the recipient's name, not their email address. However I'm struggling there a little bit, therefore I need your help again :rolleyes: This is the working code for the recipient that I'm using at the moment $address = ($customer['customers_email_address']); Quote Absinthe Original Liquor Store Link to comment Share on other sites More sharing options...
Jack_mcs Posted December 7, 2009 Author Share Posted December 7, 2009 You don't say what it is you want to change it to but, regardless, the to fields is handled by the same code so changing it would involve the same process you used for the from field. Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
mr_absinthe Posted December 7, 2009 Share Posted December 7, 2009 Sorry for not explaining. The from field is OK and it is the same for each email, it doesn't change and contains the company name. I'd like to personalize the email "To:" field so that the receiver gets a message to "My Name <myemail>" instead of just his mail-address as it is done now. Something like this: $address = ($customer['customers_firstname'] $customer['customers_lastname'] . ' <' . $customer['customers_email_address'] . '>'); However the above code doesn't work... Quote Absinthe Original Liquor Store Link to comment Share on other sites More sharing options...
Jack_mcs Posted December 7, 2009 Author Share Posted December 7, 2009 As mentioned, the answer is the same as before regarding the from field. The to field is built in the mail class and that uses the strval function. You need to edit it there to change that, possibly sending a new argument and building the string there. Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
mr_absinthe Posted December 7, 2009 Share Posted December 7, 2009 Just to let you know, what I was looking for was this: $address = ($customer['customers_firstname'] . ' ' . $customer['customers_lastname'] . ' <' . $customer['customers_email_address'] . '>');  What the above does is fully personalized "To:" field. So instead of this in message header To: [email protected] You will now have: To: John Doe <[email protected]>  If you want to make sure that all of your email messages ARE being delivered, make sure that the header looks like this:  From: Your Company <[email protected]> Reply-To: [email protected] To: John Doe <[email protected]>  The header also should contain: Return-path: <[email protected]> (envelope-from <[email protected]>)  You could also include: X-Priority: 1 X-MSMail-Priority: High  The above changes will minimize the possibility of your messages being treated as spam. I was unable to achieve all of the above with the class.Email.php due to the fact that it is quite out dated. After updating to a new mail class, all work like a charm. Quote Absinthe Original Liquor Store Link to comment Share on other sites More sharing options...
mr_absinthe Posted December 18, 2009 Share Posted December 18, 2009 Jack, Â I was forced to use new email class to achieve what I wanted. I had to change various fields in auto_announce.php, as follows: // Set Subject $mail->setSubject('Your Birthday Gift from My Store'); // Set message $mail->setHTML('<html><head><title>Happy birthday</title></head><body><p>Dear ' . $customer['customers_firstname'] . ',<br><br><!-- start message //--><span style="color: rgb(51, 102, 255);"><span style="color: rgb(0, 0, 0);">Please enjoy this complimentary birthday gift...</span><!-- stop message //--></body></html>'); // Mail it $result = $mail->send(array($address)); Â As mentioned earlier, the result is fine, message contains spam proof header, however it is now not editable (obviously) in FCK due to: $ae_array['subject'] = $_POST['subject']; $ae_array['message'] = $_POST['message']; Â Would you be so kind as to help me and tell me how to change it please? It relates to $Subject that is now $mail->setSubject and $message become $mail->setHTML. Quote Absinthe Original Liquor Store Link to comment Share on other sites More sharing options...
Jack_mcs Posted December 18, 2009 Author Share Posted December 18, 2009 I don't have whatever class you are using nor do I use FCK so I can't help with this. Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
mr_absinthe Posted December 18, 2009 Share Posted December 18, 2009 I don't have whatever class you are using nor do I use FCK so I can't help with this. I believe that the class has nothing to do with it and you use FCKeditor on admin/auto_emailer_announce.php where the message is being edited. It is auto_emailer_announce that needs to be changed to load the correct subject and message body as mentioned above. Quote Absinthe Original Liquor Store Link to comment Share on other sites More sharing options...
Jack_mcs Posted December 18, 2009 Author Share Posted December 18, 2009 You are correct. I switched to TinyMCE in the new version and got them confused. But you've changed the code considerably from the released code. While it sounds like the changes were beneficial, I don't offer support for such changes. Quote Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.