Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

AutoEmailer


  • You cannot reply to this topic
197 replies to this topic

#181 mr_absinthe

  • Community Member
  • 368 posts
  • Real Name:Alex
  • Location:London, UK

Posted 26 October 2009, 09:28

View PostJack_mcs, on 25 October 2009, 00:38, said:

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: info@mystore.com" field in email header was repeated 2500 times.
Absinthe Original Liquor Store

#182 mr_absinthe

  • Community Member
  • 368 posts
  • Real Name:Alex
  • Location:London, UK

Posted 20 November 2009, 17:56

Jack,

as mentioned above, it is ongoing issue with the "From: info@mystore.com" 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 username@someserve.com. If we can change those fields (Return-path and envelope-from), all will be fine again.
Absinthe Original Liquor Store

#183 Jack_mcs

  • Community Member
  • 24,072 posts
  • Real Name:Jack
  • Gender:Male

Posted 20 November 2009, 18:16

You can try editing the $CustomHeaders variable in the various module files. Something like
$CustomerHeaders = "Return-Path: sales@mydomain.com"


#184 mr_absinthe

  • Community Member
  • 368 posts
  • Real Name:Alex
  • Location:London, UK

Posted 21 November 2009, 17:16

View PostJack_mcs, on 20 November 2009, 18:16, said:

You can try editing the $CustomHeaders variable in the various module files. Something like
$CustomerHeaders = "Return-Path: sales@mydomain.com"

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 <info_test@mystore.com>

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 <info_test@mystore.com>
MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
From: My Store <info_test@mystore.com>

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?
Absinthe Original Liquor Store

#185 Jack_mcs

  • Community Member
  • 24,072 posts
  • Real Name:Jack
  • Gender:Male

Posted 21 November 2009, 17:49

Find the folowing
$tmessage->Send();
and add after it
$tmessage->Clear();


#186 mr_absinthe

  • Community Member
  • 368 posts
  • Real Name:Alex
  • Location:London, UK

Posted 21 November 2009, 20:58

View PostJack_mcs, on 10 January 2006, 14:07, said:

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 .= 'test@yahoo.com' . "\r\n";$headers .= 'test@yahoo.com' . "\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 .= 'test@yahoo.com' . "\r\n";
$headers .= 'test@yahoo.com' . "\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 = 'info@mystore.com';
  $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.
Absinthe Original Liquor Store

#187 Jack_mcs

  • Community Member
  • 24,072 posts
  • Real Name:Jack
  • Gender:Male

Posted 22 November 2009, 01:19

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.

#188 mr_absinthe

  • Community Member
  • 368 posts
  • Real Name:Alex
  • Location:London, UK

Posted 22 November 2009, 17:12

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 <support@mystore.com>';
as well as this
$Name = 'My Store';
$email = 'support@mystore.com';
$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;

Absinthe Original Liquor Store

#189 Jack_mcs

  • Community Member
  • 24,072 posts
  • Real Name:Jack
  • Gender:Male

Posted 22 November 2009, 18:26

It could be. I haven't tried it. I'll leave that for your enjoyment. :)

#190 mr_absinthe

  • Community Member
  • 368 posts
  • Real Name:Alex
  • Location:London, UK

Posted 07 December 2009, 11:05

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']);

Absinthe Original Liquor Store

#191 Jack_mcs

  • Community Member
  • 24,072 posts
  • Real Name:Jack
  • Gender:Male

Posted 07 December 2009, 12:08

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.

#192 mr_absinthe

  • Community Member
  • 368 posts
  • Real Name:Alex
  • Location:London, UK

Posted 07 December 2009, 12:28

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...
Absinthe Original Liquor Store

#193 Jack_mcs

  • Community Member
  • 24,072 posts
  • Real Name:Jack
  • Gender:Male

Posted 07 December 2009, 12:57

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.

#194 mr_absinthe

  • Community Member
  • 368 posts
  • Real Name:Alex
  • Location:London, UK

Posted 07 December 2009, 18:10

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: john.doe@email.com
You will now have:
To: John Doe <john.doe@email.com>

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 <you@yourcompany.com>
Reply-To: reply@yourcompany.com
To: John Doe <john.doe@email.com>

The header also should contain:
Return-path: <your_return@yourcompany.com>
(envelope-from <you@yourcompany.com>)

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.
Absinthe Original Liquor Store

#195 mr_absinthe

  • Community Member
  • 368 posts
  • Real Name:Alex
  • Location:London, UK

Posted 18 December 2009, 09:20

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.
Absinthe Original Liquor Store

#196 Jack_mcs

  • Community Member
  • 24,072 posts
  • Real Name:Jack
  • Gender:Male

Posted 18 December 2009, 12:33

I don't have whatever class you are using nor do I use FCK so I can't help with this.

#197 mr_absinthe

  • Community Member
  • 368 posts
  • Real Name:Alex
  • Location:London, UK

Posted 18 December 2009, 13:30

View PostJack_mcs, on 18 December 2009, 12:33, said:

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.
Absinthe Original Liquor Store

#198 Jack_mcs

  • Community Member
  • 24,072 posts
  • Real Name:Jack
  • Gender:Male

Posted 18 December 2009, 14:15

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.