Email multiple people after update hook

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
bruceholt
Posts: 22
Joined: 2016-07-30 20:16

Email multiple people after update hook

Post by bruceholt » 2018-10-04 09:09

I have a hook after update which emails the customer to notify them that their delivery is on it's way.. I would like to add an email address to that (a permanent email address, not one from the database) so that we have a record of the email that was sent. In other words, a cc (carbon copy) email.

My code is:

Code: Select all

	function sales_after_update($data, $memberInfo, &$args){
		ob_start(); ?>
		
<p>Hello <?php echo sqlValue("select name from customer where id='" . makeSafe($data['customer_name']) . "'"); ?>,</p>		
<p>Thank you for your purchase.</p>
<p>Paypal Transaction Number (if applicable): <?php echo $data['paypal_transaction_id']; ?>
<p>Your purchase has been sent via <?php echo sqlValue("select carriers from carriers where id='" . makeSafe($data['carrier']) . "'"); ?> to:</p>
<p><?php echo sqlValue("select address from customer where id='" . makeSafe($data['customer_address']) . "'"); ?><br>
<?php echo sqlValue("select city from customer where id='" . makeSafe($data['customer_address']) . "'"); ?><br>
<?php echo sqlValue("select state from customer where id='" . makeSafe($data['customer_address']) . "'"); ?>, <?php echo sqlValue("select post_code from customer where id='" . makeSafe($data['customer_address']) . "'"); ?><br>
<?php echo sqlValue("select country from customer where id='" . makeSafe($data['customer_address']) . "'"); ?></p>
<p>Tracking number (if applicable): <?php echo $data['tracking_number']; ?></p>


<p>Visit <a href="https://auspost.com.au/mypost/track/#/details/<?php echo $data['tracking_number']; ?>">https://auspost.com.au/mypost/track/#/details/<?php echo $data['tracking_number']; ?></a> to track your delivery.</p>

		
		<?php
		$mail_body = ob_get_contents();
		ob_end_clean();
		
		$email = sqlValue("select email from customer where id='" . makeSafe($data['customer_name']) . "'");
		
		 $emailed = sqlValue("select emailed from sales where sales_number='" . makeSafe($data['customer_name']) . "'");
		if($emailed == 'Yes') return true; // return from the function skipping the mail sending part
		
		mail(
			$email,
			'Kurraglen Industries purchase ' ,
			$mail_body,
			"From: sales@kurraglenindustries.com.au\r\n" .
			"MIME-Version: 1.0\r\n" .
			"Content-type: text/html; charset=iso-8859-1\r\n"
		);
		
		sql("update sales set emailed='Yes' where sales_number='" . makeSafe($data['customer_name']) . "'", $eo);
		
		return TRUE;
	}
	
Thanks in advance. Bruce.

User avatar
a.gneady
Site Admin
Posts: 938
Joined: 2012-09-27 14:46
Contact:

Re: Email multiple people after update hook

Post by a.gneady » 2018-10-11 14:11

Try this:

Code: Select all

mail(
	$email,
	'Kurraglen Industries purchase ' ,
	$mail_body,
	"From: sales@kurraglenindustries.com.au\r\n" .
	"MIME-Version: 1.0\r\n" .
	"Content-type: text/html; charset=iso-8859-1\r\n" .
	"Cc: example@mail.com\r\n"
);
AppGini: Responsive, collaborative web db apps in minutes.
:idea: Learn all the tips and tricks of customizing AppGini apps through our online course.

bruceholt
Posts: 22
Joined: 2016-07-30 20:16

Re: Email multiple people after update hook

Post by bruceholt » 2018-10-12 20:21

Hi,

I tried that but unfortunately with that line in it, sales_view.php returns a blank page.

User avatar
a.gneady
Site Admin
Posts: 938
Joined: 2012-09-27 14:46
Contact:

Re: Email multiple people after update hook

Post by a.gneady » 2018-10-18 11:35

Hmm .. is there any error message reported in your server's error_log file?
AppGini: Responsive, collaborative web db apps in minutes.
:idea: Learn all the tips and tricks of customizing AppGini apps through our online course.

bruceholt
Posts: 22
Joined: 2016-07-30 20:16

Re: Email multiple people after update hook

Post by bruceholt » 2018-10-29 04:58

Thanks all working now but I'm not sure what I did :?

Post Reply