Hello everyone!
there is a way to send html formatted emails using the utility in the administrative area (the one that allows you to send an email to all members of the portal?).
I tried to paste the html code in the box but it doesn't work!
Is there a solution?
THANKS!
Fabiano
send html formatted emails to all portal members
-
- Posts: 2
- Joined: 2019-11-10 15:52
Re: send html formatted emails to all portal members
i don't know if there is any method you can do it from admin area, but you can do the following :
if you don't want to save every email you send as new record in table html_emails_sender, add
to hook
then just edit the same record every time you want to send an email.
regards
Saleh
- 1. on your appgini, create a new table with this fields :
- subject (varchar)
- message(text)
- 2. on your appgini, generate your app code again (be careful of losing your customization if any).
- 3. go and edit the file hooks/html_emails_sender.php, scroll down to bottom and add this function :
Code: Select all
function Send_Notification($data) { /*selecting users data from users table, supposing field custom1 contain full user name*/ $NotificationList = "Select email, custom1 From membership_users" ; $TargetEmails = db_query($NotificationList); /*message filed where you add your html*/ $message = makeSafe($data['message']); $subject = makeSafe($data['subject']); while ($list = db_fetch_assoc($TargetEmails)) {; sendmail(array( 'to' => $list['email'], 'name' => $list['custom1'], 'subject' => $subject , 'message' => $message )); } }
- 4. scroll up to till you find :
add below (inside the html_emails_sender_after_insert function) :Code: Select all
function html_emails_sender_after_insert($data, $memberInfo, &$args){
Code: Select all
Send_Notification($data);
- 5. now go to user area, add new record to the table html_emails_sender, fill the subject, put your HTML at message field, and save ! all of your users must receive your HTML email now
if you don't want to save every email you send as new record in table html_emails_sender, add
Code: Select all
Send_Notification($data);
Code: Select all
html_emails_sender_after_update
regards
Saleh
Re: send html formatted emails to all portal members
Thank you very much Saleh!
I will definitely try your solution!
I ask you two more information about your solution ..
1) Can I be sure that each recipient will receive a separate email and will not see the addresses of the other recipients?
2) there is a way to choose, when creating a record, whether to send the mail to all users or users of one or more specific groups? (for example, I image a dropdown list where I choose "all groups" or a specific group (or , even multiple specific groups) taking the list of groups from the relative table.
Thanks!
Fabiano
I will definitely try your solution!
I ask you two more information about your solution ..
1) Can I be sure that each recipient will receive a separate email and will not see the addresses of the other recipients?
2) there is a way to choose, when creating a record, whether to send the mail to all users or users of one or more specific groups? (for example, I image a dropdown list where I choose "all groups" or a specific group (or , even multiple specific groups) taking the list of groups from the relative table.
Thanks!
Fabiano
Re: send html formatted emails to all portal members
Sorry Saleh but if i have the fields "oggetto" (=field for subject) and "contenuto_messaggio" (field for message) and i set this code:
/*
function html_emails_sender_after_insert($data, $memberInfo, &$args) {
Send_Notification($data);
return TRUE;
}
and at the bottom i set this code:
function Send_Notification($data) {
/*selecting users data from users table, supposing field custom1 contain full user name*/
$NotificationList = "Select email, custom1 From membership_users" ;
$TargetEmails = db_query($NotificationList);
/*message filed where you add your html*/
$message = makeSafe($data['contenuto_messaggio']);
$subject = makeSafe($data['oggetto']);
while ($list = db_fetch_assoc($TargetEmails)) {;
sendmail(array(
'to' => $list['email'],
'name' => $list['custom1'],
'subject' => $subject ,
'message' => $message
));
}
*/
The solution work only if i put not formatted text in the contenuto_messaggio field. If i put for example <b>hello!</b> i have this error saving the form:
Not Acceptable!
An appropriate representation of the requested resource could not be found on this server. This error was generated by Mod_Security.
Hope you will suggest me how to solve it!
Thank you!
Fabiano
/*
function html_emails_sender_after_insert($data, $memberInfo, &$args) {
Send_Notification($data);
return TRUE;
}
and at the bottom i set this code:
function Send_Notification($data) {
/*selecting users data from users table, supposing field custom1 contain full user name*/
$NotificationList = "Select email, custom1 From membership_users" ;
$TargetEmails = db_query($NotificationList);
/*message filed where you add your html*/
$message = makeSafe($data['contenuto_messaggio']);
$subject = makeSafe($data['oggetto']);
while ($list = db_fetch_assoc($TargetEmails)) {;
sendmail(array(
'to' => $list['email'],
'name' => $list['custom1'],
'subject' => $subject ,
'message' => $message
));
}
*/
The solution work only if i put not formatted text in the contenuto_messaggio field. If i put for example <b>hello!</b> i have this error saving the form:
Not Acceptable!
An appropriate representation of the requested resource could not be found on this server. This error was generated by Mod_Security.
Hope you will suggest me how to solve it!
Thank you!
Fabiano