zucarino
Založený: 29.12.2005
Príspevky: 44
Bydlisko: Rio de Janeiro - Brazil
Zaslal: 2007-09-06 16:06
Návrat hore
Odpovedať s citátom
|
Hi all
I would like to suggest the "full" STMP configuration to send notify emails. For example, something like this:
| Kód: |
$opts['notify'] = array(
'smtp-host' => 'IP_MY_SMTP_SERVER', // new feature
'smtp-port' => '25', // new feature
'smtp-ssl' => false, // new feature
'pop-before-smtp => true, // new feature
'auth_user' => 'ACCOUNT_TO_SEND_EMAIL', // new feature
'auth_passw' => 'ACCOUNT_PASSWORD' // new feature
'from' => 'admin@my_system.com',
'prefix' => 'INFORM - ',
'update' => 'manager1@my_system.com',
'insert' => 'manager2@my_system.com',
'delete' => 'manager3@my_system.com',
'all' => 'admin@my_system.com'
); |
What do you (PME Masters and simple mortals like me) think?! :)
Best regards!
_________________ ---
Victor Zucarino
vffzbr at yahoo dot com dot br
|
zucarino
Založený: 29.12.2005
Príspevky: 44
Bydlisko: Rio de Janeiro - Brazil
Zaslal: 2007-12-13 16:30
Návrat hore
Odpovedať s citátom
|
Any ideas...?!
Best regards,
_________________ ---
Victor Zucarino
vffzbr at yahoo dot com dot br
|
michal
Založený: 17.06.2003
Príspevky: 537
Bydlisko: Slovakia
Zaslal: 2007-12-18 09:07
Návrat hore
Odpovedať s citátom
|
maybe it would be a good idea to make the email notify as an after trigger (which it is in reality).
this would allow to make this feature more usefull.
what do you think ?
|
zucarino
Založený: 29.12.2005
Príspevky: 44
Bydlisko: Rio de Janeiro - Brazil
Zaslal: 2007-12-18 10:19
Návrat hore
Odpovedať s citátom
|
Hi Michal
Yes, could it be. I think about something simple, but work like an extension is one choice too. The trigger is easy to configure, if it is possible so there is the way. But how can I do it? Need hack the code?
Thanks!
_________________ ---
Victor Zucarino
vffzbr at yahoo dot com dot br
|
michal
Založený: 17.06.2003
Príspevky: 537
Bydlisko: Slovakia
Zaslal: 2007-12-18 10:38
Návrat hore
Odpovedať s citátom
|
just move the email notify code from the core class to a trigger (except for the part in constructor). and hack the trigger.
once finished and tested, i will put it into cvs.
i personally don't use this feature, so i cannot help much.
|
zucarino
Založený: 29.12.2005
Príspevky: 44
Bydlisko: Rio de Janeiro - Brazil
Zaslal: 2008-01-03 17:27
Návrat hore
Odpovedať s citátom
|
Hi Michal, happy new year :-)
Ok I will try it and then back to you.
Best regards!
_________________ ---
Victor Zucarino
vffzbr at yahoo dot com dot br
|
raisingmn
Založený: 05.02.2008
Príspevky: 2
Zaslal: 2008-02-05 18:13
Návrat hore
Odpovedať s citátom
|
Victor,
Did you have any success with your notify trigger? If so, would you mind sharing the code?
thanks,
Glen
|
zucarino
Založený: 29.12.2005
Príspevky: 44
Bydlisko: Rio de Janeiro - Brazil
Zaslal: 2008-02-07 10:05
Návrat hore
Odpovedať s citátom
|
Hi Raisingmn,
Not yet... May be PEAR will be necessary. I will try it next days, soon as possible. Then share the results here.
Best regards!
_________________ ---
Victor Zucarino
vffzbr at yahoo dot com dot br
|
raisingmn
Založený: 05.02.2008
Príspevky: 2
Zaslal: 2008-02-07 17:07
Návrat hore
Odpovedať s citátom
|
Hi Victor,
I created a trigger which sends a Notify email when a specific value changes on the record. Here is the trigger file ("NotifyTrigger.inc"):
| Kód: |
<?php
if (($newvals['InBilling'] == "Yes") && ($oldvals['InBilling'] == "No")) {
$this -> email_notify(false, $newvals);
}
?> |
In the PHPmyedit template file, I added:
| Kód: |
// Email Notifications
$opts['notify'] = array(
'from' => 'my@email.com',
'prefix' => 'A record has been updated: ',
'insert' => 'my@email.com'
);
// Trigger
$opts['triggers']['update']['after'] = 'NotifyTrigger.inc';
|
Then, in phpMyEdit.class.php, I commented out the code that would normally send an Insert Notification email:
| Kód: |
// Notify list
//if (@$this->notify['insert'] || @$this->notify['all']) {
// $this->email_notify(false, $newvals);
//}
|
Now, whenever a user changes a record's InBilling from "No" to "Yes", a Notification email is sent.
Hope that helps in your project.
Glen
|
zucarino
Založený: 29.12.2005
Príspevky: 44
Bydlisko: Rio de Janeiro - Brazil
Zaslal: 2008-02-08 00:18
Návrat hore
Odpovedať s citátom
|
Hi Glen
Good job! :-) Thanks, fine hack to separate notifications by records. Yes I will use this example in a couple of cases.
But I think to make the notification more 'mature', using advanced options like:
| Kód: |
'smtp-host' => 'IP_MY_SMTP_SERVER',
'smtp-port' => '25',
'smtp-ssl' => false,
'pop-before-smtp => true,
'auth_user' => 'ACCOUNT_TO_SEND_EMAIL',
'auth_passw' => 'ACCOUNT_PASSWORD', |
So we can host PME and use some specific mail server to notify. Probably with PEAR we can do it (more easy and secure), but is necessary modify the core code.
I have no free time now to work on it, but still trying :-)
Best regards!
_________________ ---
Victor Zucarino
vffzbr at yahoo dot com dot br
|
zucarino
Založený: 29.12.2005
Príspevky: 44
Bydlisko: Rio de Janeiro - Brazil
Zaslal: 2008-04-29 12:40
Návrat hore
Odpovedať s citátom
|
Hi all
At last, I finished the mail notify script with extra options. I used the XPM Class (
http://www.xpertmailer.com/
), fast and simple.
Here an example using PME Triggers to send a notification after update a record. Check PME documentation for more details:
http://opensource.platon.sk/projects/download.php?project_id=5&package=phpMyEdit-doc
1) Download XPM v4.05 and unpack, directory class/xpm_v405 for example.
2) Create the Mail Notify file
email_notify_TUA.php
, something like this:
| Kód: |
<?php
require_once("class/xpm_v405/MAIL.php");
// Show message:
echo "<span style='background-color: #FEFFE6'>Register $this->rec updated!</span>";
// Email body used by XPM:
$email_body = "
<center>
<p><b>My System - Mail Notify</b></p>
<table style='font-family: Arial; font-size: 12px; color: #000080; background-color: #F3F3F3; border: 1px solid #dbdbdb' cellspacing=0 cellpadding=3px>
<tr><td style='background-color: #FEFFE6' colspan=2><center>Register <b>$this->rec</b> updated.</center></td></tr>";
$email_body .= "
<tr>
<td style='background-color: #C5DBED'><center><b>BEFORE:</b></center></td>
<td style='background-color: #AEFBC6'><center><b>AFTER:</b></center></td>
</tr>
<tr>
<td valign='top'>
<table style='font-family: Arial; font-size: 12px; color: #000080; background-color: #F3F3F3; border: 0px' cellspacing=0 cellpadding=1px>";
foreach($oldvals as $key => $val){
$email_body .= "
<tr><td style='background-color: #f8f8f8'><b>" . $key . "</b></td></tr>
<tr><td style='background-color: #ffffff'>" . $val . "</td></tr>";
}
$email_body .= "
</table>
</td>
<td valign='top'>
<table style='font-family: Arial; font-size: 12px; color: #000080; background-color: #F3F3F3; border: 0px' cellspacing=0 cellpadding=1px>";
foreach($newvals as $key => $val){
$email_body .= "
<tr><td style='background-color: #f8f8f8'><b>" . $key . "</b></td></tr>
<tr><td style='background-color: #ffffff'>" . $val . "</td></tr>";
}
$email_body .= "
</table>
</td>
</tr>
</table>
</center>";
// Define mail options, check XPM documentation for more details:
$mail = new MAIL;
$conn = $mail->Connect('your_smtp_server', 25, 'user_name', 'password') or die(print_r($m->Result));
$mail->Text('text/html', 'iso-8859-1', 'quoted-printable') OR die('error');
$mail->From('from_address@your_company.com);
$mail->AddTo('to_address@your_company.com');
$mail->AddCc('cc_address@your_company.com');
$mail->Subject('My System - Mail Notify');
$mail->Html($email_body);
// Send and show message:
echo $mail->Send($conn) ? 'Mail sent!' : 'Error!';
// Disconnect from mail server:
$mail->Disconnect();
?> |
This script creates an HTML mail, but if you want plain text just change the code. Check XPM documentation too, some examples will help you.
3) Add this line on your PME file to use the trigger (before the line who calls the PME Class):
| Kód: |
| $opts['triggers']['update']['after'] = 'email_notify_TUA.php'; |
4) Test...
Best regards![/b]
_________________ ---
Victor Zucarino
vffzbr at yahoo dot com dot br
|
smokinpuppy
Založený: 26.03.2012
Príspevky: 14
Zaslal: 2012-06-17 11:20
Návrat hore
Odpovedať s citátom
|
Thank you very much for your code, it is very useful and was helpful to me. I modified your code a little to Send a notify email to new users with username, password, and other info. If you'd like to see it, it is at:
http://opensource.platon.sk/forum/projects/viewtopic.php?p=3982669#3982669
Thank you again,
Robert
|
|
Odoslať novú tému
Odpovedať na tému
|