Jump to content

Help with adding an auto-reply type of message


Chrisj

Recommended Posts

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. 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 

- Subject too

I'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 by requinix
Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.