send email on column edit
send email on column edit
hbanaharis
Posts: 32Questions: 14Answers: 3
I would like to use PHPMailer to send an email on datatable edit event.
When a column value is altered I would like to collect a number of associated row values and pass them via ajax to a php page which will then use PHPMailer to send the email.
What is an example of collecting row data in order to use them in an ajax function?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Are you using Editor here, and you want to send an e-mail when a value changes? If so, the server-side events are how to do this.
The blog post that introduced server-side events for Editor has an example of how you might send e-mail with the events.
Allan
Im using the editor and noted the example you cited:
Could you please provide an example using PHPMailer instead of the C# mail script
adding this
creates a system error
the error: https://datatables.net/manual/tech-notes/12
Sorry, I can't provide support for a third party script such as PHPMailer. The example you show above actually uses PHP's built in
mail
method, it doesn't use any C# there. The PHPMailer documentation includes an example showing how you can use their software.Regarding the error - that's because the server will no longer be returning valid JSON as explained in the tech note. Editor expects valid JSON to be returned, but that
echo
statement makes it invalid. If you are trying to do some logging, I would suggest using PHP'serror_log()
function and watching the server's error log.Allan
Im not suggesting you support PHPmailer, Im requesting that you provide an example of how a script like PHPmailer could be integrated in a postEdit context. The php mail function has a number of constraints that PHPmailer overcomes and having programmatic email control enhances the value of datatables.
If its simply not possible to use a call to PHPmailer script within ->('postEdit', ... ) please say so and perhaps suggest another way to the PHPmailer script on an edit. Thanks
I'm afraid I'm not really sure what you are looking for. This is how you could use
PHPMailer
insidepostEdit
, just as you would with any other PHP code:Is that okay to get you started?
Allan