Chrisj Posted August 4, 2015 Share Posted August 4, 2015 I'm using an existing php web site script where a user can turn on or off the ability to be notified (by email) if an internal message on the site has arrived into user's inbox. I'd like to modify the script so that the sender, of the internal message, be notified (by email), if the recipient has chosen not to be notified of internal messages. This is (part) the existing code: // check if receipients allow notifications is yes , send them a notification that they have an message if (notification_preferences($to_id, 'privatemessage') == true) { // send pm notification email to recipients registartion email addy $email_template = 'email_templates/newmessage.htm'; $subject = $config['email_new_email']; // at this point we do not have any email to send to $to = $members_email; $from = $config['notifications_from_email']; //send email template to TBS for rendering of variable inside $template = $email_template; $inner_template1 = "themes/$user_theme/templates/inner_email_compose.htm"; $TBS = new clsTinyButStrong; $TBS->NoErr = true; $TBS->LoadTemplate("$template"); $TBS->tbs_show(TBS_NOTHING); $message = $TBS->Source; //load postage.php include ('includes/postage.php'); $blk_notification = 1; $message_type = $config['word_success']; // Success $error_message = $config['error_25']; //25 == Request has been completed XXXXX=>success unset($_SESSION['update_token']); $_SESSION['update_token'] = ''; } If I replace the last } with } else { and then add the above code - modified - to notify the sender (by email) if the recipient has chosen not to be notified of internal messages. But I don't what to change in the code above, that would instruct it to } else { send something to the sender(of the internal message) email address. Can you help me with this part of my attempted modification? I've attached the entire code in txt (instead of php). Any help will be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/297630-help-with-adding-an-auto-reply-type-of-message/ Share on other sites More sharing options...
requinix Posted August 4, 2015 Share Posted August 4, 2015 1. Add an else, like you said. 2. Copy the code you have now into the else branch. You're copying it because that's how it sends emails already, not because you want to send the same email. 3. Modify the appropriate parts: - Email template, probably both $email_template and $inner_template1 - Subject too - The $to email should be the sender (the $from doesn't change as that's the system email) Everything else looks the same as it deals with templating and with sending emails in general. Quote Link to comment https://forums.phpfreaks.com/topic/297630-help-with-adding-an-auto-reply-type-of-message/#findComment-1518025 Share on other sites More sharing options...
Chrisj Posted August 5, 2015 Author Share Posted August 5, 2015 Thanks for that reply. Much appreciated. However, I'm hoping I can get clarification on: - Subject too I'm not sure what you mean there. And I understand this: - The $to email should be the sender (the $from doesn't change as that's the system email) but I don't know how to change $members_email to "the sender". Any additional assistance will be welcomed. Much thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/297630-help-with-adding-an-auto-reply-type-of-message/#findComment-1518041 Share on other sites More sharing options...
requinix Posted August 5, 2015 Share Posted August 5, 2015 (edited) - Subject tooI'm not sure what you mean there. You'll probably want to edit the subject line of the email. Right now it's some "email_new_email" value, which sounds generic so you may not need to do anything with the subject after all. And I understand this: - The $to email should be the sender (the $from doesn't change as that's the system email)but I don't know how to change $members_email to "the sender". $to is the email address to send to. Initially it was the $members_email which is (apparently) the person you were trying to send to at first, but now you need to make it be the sender's email address instead. I don't know where you will need to get that value from because it's not referenced in the code you posted. Edited August 5, 2015 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/297630-help-with-adding-an-auto-reply-type-of-message/#findComment-1518042 Share on other sites More sharing options...
Chrisj Posted August 18, 2015 Author Share Posted August 18, 2015 Thanks again for your reply. I don't know how to find sender's email address value. I've attached the emailcompose php file (in txt form). Can you tell me if you can determine if that value is in there, please? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/297630-help-with-adding-an-auto-reply-type-of-message/#findComment-1519218 Share on other sites More sharing options...
Chrisj Posted August 18, 2015 Author Share Posted August 18, 2015 I uploaded but didn't attach. Please find it attached. Thanks again emailcompose.txt Quote Link to comment https://forums.phpfreaks.com/topic/297630-help-with-adding-an-auto-reply-type-of-message/#findComment-1519219 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.