Modify the contact.php to send more than one message?

This is a discussion on Modify the contact.php to send more than one message? within the v3.1 Modules & Modifications forums, part of the v3.1 Legacy Help & Support category; Can anyone tell me what snippit of code I would need to add to the contact.php to have it send ...


Go Back   68 Classifieds Forums > v3.1 Legacy Help & Support > v3.1 Modules & Modifications

 
LinkBack Thread Tools Display Modes
  #1  
Old 01-03-2007, 06:47 PM
bgordon's Avatar
Senior Member
 
Join Date: Aug 2006
Location: Georgian Bay, Ontario Canada
Posts: 157
Rep Power: 13
Question Modify the contact.php to send more than one message?

Can anyone tell me what snippit of code I would need to add to the contact.php to have it send a copy of messages to my account via a SMTP server OTHER than the one the site uses to send the original message to my sellers.

Here is why: I pay for a blacklist-free SMTP service called SMTP.COM that will relay my site mail and guarantees not to get blacklisted (they purport to have serious spam filtering and have the respect of the blacklist services). Hopefully this is more than hype since the service is not cheap.

I was having welcome emails, and more importantly, activation emails being rejected by major mail services since my ISP's mail services were too widely used/abused and would go on and off various blacklists. I tested this theory by pointing the site to my business mail server and all was well again. Needless to say, I could not leave it pointing to my business mail server.

So: since I pay for each relayed mail message throught SMTP.COM, I don't want to use the simple mod where I add a BCC to the contact.php script. This counts as 2 relays for every 1 message. See the point?

Can someone write a small routine that kicks in after the first routine that sends off a copy of the same message to an email address I define using an SMTP server and port that I define. This gets me my copy and bypasses the paid relay service. I always got site email through my ISP which is what baffled me for so long.

Sorry for being long-winded, I just wanted to make sure you knew what I was asking for and why.

Thanks gurus.

__________________
B.Gordon
v.3.1.5 Developer
www.canadaboatshopper.com
Canada Boat Shopper - Boats For Sale By Owner In And Around Canada
Reply With Quote
  #2  
Old 01-03-2007, 06:51 PM
Moderator
 
Join Date: Mar 2006
Posts: 3,733
Rep Power: 91
Default

I would have to take a closer look at the script itself but from memory I would think you could just copy the current few lines that handle mail and place them below current section hard coding in the address etc you want to use for the duplicate mail (ie not router through the pay per mail gateway).
__________________
Larry.
(Please note: I am not a 68C employee. I am a customer and volunteer who helps with questions where I can and the forums spam free)

Set your site apart from the competition with one of my modules......
Google Map Module | You Tube Module | Google Calendar Module | Event Calendar Module

68 Classifieds Important Links
Customer Area | Issue Tracker | Knowledge Base | User Manuals
Reply With Quote
  #3  
Old 01-03-2007, 06:56 PM
bgordon's Avatar
Senior Member
 
Join Date: Aug 2006
Location: Georgian Bay, Ontario Canada
Posts: 157
Rep Power: 13
Default

Quote:
Originally Posted by Lhotch View Post
I would have to take a closer look at the script itself but from memory I would think you could just copy the current few lines that handle mail and place them below current section hard coding in the address etc you want to use for the duplicate mail (ie not router through the pay per mail gateway).
So (I too should look at it closely) is there a variable for the SMTP server that is defined in the site settings that I could simply hard-code instead of the variable? I would think it would involve some kind of loop... but I am really not a programmer... just a learning hack...
__________________
B.Gordon
v.3.1.5 Developer
www.canadaboatshopper.com
Canada Boat Shopper - Boats For Sale By Owner In And Around Canada
Reply With Quote
  #4  
Old 01-03-2007, 07:02 PM
Moderator
 
Join Date: Mar 2006
Posts: 3,733
Rep Power: 91
Default

By default the mail section of the contact.php script uses variables based on admin settings which is working fine if I understand you correctly. You just want another e-mail sent to you using something other than the pay service so instead of loping over exisiting code, I would just copy the code and paste in in below current mail code and hard code in destination for the copy.

What would happen then is 2 e-mails will be triggered, the natural one using the system defined values from admin and another (ie copy) sent by the new chunk of code that uses hard coded values...ie [email protected] instead of the variable $to.

It would be much simpler and cleaner to add a little code then try and add in loops and process since the whole e-mail section (or at least where the phpmailer class is called and mail is sent) is only like 12 lines of code or so.

Im on my way out the door now but will take a closer look at it later if I have time and post more details.
__________________
Larry.
(Please note: I am not a 68C employee. I am a customer and volunteer who helps with questions where I can and the forums spam free)

Set your site apart from the competition with one of my modules......
Google Map Module | You Tube Module | Google Calendar Module | Event Calendar Module

68 Classifieds Important Links
Customer Area | Issue Tracker | Knowledge Base | User Manuals
Reply With Quote
  #5  
Old 01-03-2007, 11:34 PM
bgordon's Avatar
Senior Member
 
Join Date: Aug 2006
Location: Georgian Bay, Ontario Canada
Posts: 157
Rep Power: 13
Default

Sounds simple enough... but I think I need to make a new routine in /kernel/classes/mailer.php where the SMTP settings seem to be defined... or maybe make a new mailer2.php with the new settings and include it in the init.php which is included in the contact.php?

Starting to sound like programming.... errr any help would be appreciated. All this to save a few bucks!
__________________
B.Gordon
v.3.1.5 Developer
www.canadaboatshopper.com
Canada Boat Shopper - Boats For Sale By Owner In And Around Canada

Last edited by bgordon; 01-03-2007 at 11:45 PM.
Reply With Quote
  #6  
Old 01-04-2007, 10:25 AM
Moderator
 
Join Date: Mar 2006
Posts: 3,733
Rep Power: 91
Default

Quote:
Originally Posted by bgordon View Post
Sounds simple enough... but I think I need to make a new routine in /kernel/classes/mailer.php where the SMTP settings seem to be defined... or maybe make a new mailer2.php with the new settings and include it in the init.php which is included in the contact.php?

Starting to sound like programming.... errr any help would be appreciated. All this to save a few bucks!
The smtp settings dont matter if your going to hard code. Just to make sure we are on the same page let me see if I have this right.

Your site works fine now and send mail through a mail service that charges you per e-mail. You have your site settings in admin setup to use SMTP pointing it to this e-mail service. You would like to get a copy of mail that goes to your users sent to you as well but dont want this to be run through the mail service itself.

If the above is correct then try the following(assuming 68c ver 3.1.5b). Open contact.php and goto line 108 you should see the following...

Code:
$mail = new Mailer();
$mail->AddAddress($to);
$mail->From = $from;
$mail->FromName = $name;
$mail->Subject = $subject;
$mail->IsHTML(true);
$mail->Body    = $htmlContent;
$mail->AltBody = $textContent;
if($mail->Send())
{
$class_tpl->assign('title',LANG_CONTACT_SUCCESS_TITLE);
$class_tpl->assign('pPageContent',LANG_CONTACT_SUCCESS_BODY);
$class_tpl->assign('body','content.tpl.php');
}
else
{
$class_tpl->assign('title',LANG_ERROR);
$class_tpl->assign('pPageContent',LANG_ERROR_MAIL .' '. $mail->ErrorInfo);
$class_tpl->assign('body','content.tpl.php');
}
The top 8 lines invoke the phpmailer class and the bottom lines check to see if mail was sent and then displays the appropriate page.

We want to send an additional e-mail, not through the defined method in admin and not forward to a new page until after the real, official e-mail is sent. With that in mind I would say to try and set you duplicate/admin copy to be sent before the real copy. This is untested but what I would do is call the mailer prior to the existing call and pass along to it any specific info that needed. For example we can start with the same lines of code to call the mailer class and pass variables to it like so...

Code:
$mail = new Mailer();
$mail->AddAddress($to);
$mail->From = $from;
$mail->FromName = $name;
$mail->Subject = $subject;
$mail->IsHTML(true);
$mail->Body    = $htmlContent;
$mail->AltBody = $textContent;
As it sits however the above will use variables for address on who to send to, we want to change this to a static value which would be where you want the COPY e-mail to go. For example....

Code:
$mail->AddAddress([email protected]);
Since we dont want to use the default host defined in admin you will also need to add a couple lines to pass along specific values to use for host, login, password etc which can be done like this....

Code:
$mail->Host       = "smtp1.site.com";
$mail->Password = "mypassword";
$mail->Username = "myusername";
In the end all the code would look like this...

Code:
// new duplicate e-mail code //
$mail = new Mailer();
$mail->Host       = "smtp1.site.com";
$mail->Password = "mypassword";
$mail->Username = "myusername";
$mail->AddAddress([email protected]);
$mail->From = $from;
$mail->FromName = $name;
$mail->Subject = $subject;
$mail->IsHTML(true);
$mail->Body    = $htmlContent;
$mail->AltBody = $textContent;
$mail->Send();    // send the copy e-mail to new address
// start default code //
$mail = new Mailer();
$mail->AddAddress($to);
$mail->From = $from;
$mail->FromName = $name;
$mail->Subject = $subject;
$mail->IsHTML(true);
$mail->Body    = $htmlContent;
$mail->AltBody = $textContent;
if($mail->Send())
{
$class_tpl->assign('title',LANG_CONTACT_SUCCESS_TITLE);
$class_tpl->assign('pPageContent',LANG_CONTACT_SUCCESS_BODY);
$class_tpl->assign('body','content.tpl.php');
}
else
{
$class_tpl->assign('title',LANG_ERROR);
$class_tpl->assign('pPageContent',LANG_ERROR_MAIL .' '. $mail->ErrorInfo);
$class_tpl->assign('body','content.tpl.php');
}
The above should send a copy of the mail through a new smtp host prior to sending the real mail through the admin defined host. This is untested but should work for ya.
__________________
Larry.
(Please note: I am not a 68C employee. I am a customer and volunteer who helps with questions where I can and the forums spam free)

Set your site apart from the competition with one of my modules......
Google Map Module | You Tube Module | Google Calendar Module | Event Calendar Module

68 Classifieds Important Links
Customer Area | Issue Tracker | Knowledge Base | User Manuals
Reply With Quote
  #7  
Old 01-04-2007, 04:04 PM
bgordon's Avatar
Senior Member
 
Join Date: Aug 2006
Location: Georgian Bay, Ontario Canada
Posts: 157
Rep Power: 13
Default

I have inserted that code and the site email works but the new email does not seem to go anywhere... Are you sure the HOST value is being parsed? I know the values I put in for the variables are correct... also I noticed that the code failed unless I surrounded the recipent email address with quotes inside the brackets...

We are really close...
__________________
B.Gordon
v.3.1.5 Developer
www.canadaboatshopper.com
Canada Boat Shopper - Boats For Sale By Owner In And Around Canada
Reply With Quote
  #8  
Old 01-04-2007, 04:30 PM
Moderator
 
Join Date: Mar 2006
Posts: 3,733
Rep Power: 91
Default

Try adding the following so that the new copy e-mail call knows to use smtp.

$mail->IsSMTP();

The final bit of new code should then look like this...

Code:
// new duplicate e-mail code //
$mail = new Mailer();
$mail->IsSMTP();
$mail->Host       = "smtp1.site.com";
$mail->Password = "mypassword";
$mail->Username = "myusername";
$mail->AddAddress("[email protected]");
$mail->From = $from;
$mail->FromName = $name;
$mail->Subject = $subject;
$mail->IsHTML(true);
$mail->Body    = $htmlContent;
$mail->AltBody = $textContent;
$mail->Send();    // send the copy e-mail to new address
__________________
Larry.
(Please note: I am not a 68C employee. I am a customer and volunteer who helps with questions where I can and the forums spam free)

Set your site apart from the competition with one of my modules......
Google Map Module | You Tube Module | Google Calendar Module | Event Calendar Module

68 Classifieds Important Links
Customer Area | Issue Tracker | Knowledge Base | User Manuals
Reply With Quote
  #9  
Old 01-04-2007, 04:52 PM
bgordon's Avatar
Senior Member
 
Join Date: Aug 2006
Location: Georgian Bay, Ontario Canada
Posts: 157
Rep Power: 13
Default

ahhh....

nope. Did not seem to make a difference.
__________________
B.Gordon
v.3.1.5 Developer
www.canadaboatshopper.com
Canada Boat Shopper - Boats For Sale By Owner In And Around Canada
Reply With Quote
  #10  
Old 01-04-2007, 05:18 PM
Moderator
 
Join Date: Mar 2006
Posts: 3,733
Rep Power: 91
Default

Quote:
Originally Posted by bgordon View Post
ahhh....

nope. Did not seem to make a difference.
Just to make sure, did you replace the values for host, user and password I had in the above code with the correct ones for your mail server?
__________________
Larry.
(Please note: I am not a 68C employee. I am a customer and volunteer who helps with questions where I can and the forums spam free)

Set your site apart from the competition with one of my modules......
Google Map Module | You Tube Module | Google Calendar Module | Event Calendar Module

68 Classifieds Important Links
Customer Area | Issue Tracker | Knowledge Base | User Manuals
Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Modify Makes Things Go Goodbye CB v3.1 Questions & Support 2 07-17-2006 10:43 PM
Message Inbox robgo777 v3.1 Suggestions and Feedback 5 07-11-2006 05:48 AM
Add message to thanks.php leontine v3.1 Questions & Support 1 06-15-2006 10:31 AM
Thank you message page- custom message? zman78 HTML, CSS, and Design Help 6 04-05-2006 09:58 PM
Phpnewads munky20 v3.0 Questions & Support 10 03-30-2006 07:59 PM


All times are GMT -4. The time now is 03:08 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22