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 ...
|
|||||||
|
|
LinkBack | Thread Tools | Display Modes |
|
#1
|
||||
|
||||
|
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 |
|
#2
|
||||
|
||||
|
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 |
|
#3
|
||||
|
||||
|
Quote:
__________________
B.Gordon v.3.1.5 Developer www.canadaboatshopper.com Canada Boat Shopper - Boats For Sale By Owner In And Around Canada |
|
#4
|
||||
|
||||
|
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 |
|
#5
|
||||
|
||||
|
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. |
|
#6
|
||||
|
||||
|
Quote:
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');
}
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; Code:
$mail->AddAddress([email protected]); Code:
$mail->Host = "smtp1.site.com"; $mail->Password = "mypassword"; $mail->Username = "myusername"; 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'); }
__________________
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 |
|
#7
|
||||
|
||||
|
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 |
|
#8
|
||||
|
||||
|
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 |
|
#9
|
||||
|
||||
|
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 |
|
#10
|
||||
|
||||
|
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 |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
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 |