Page 1 of 1

send mail, canned responses

Posted: Mon Oct 08, 2007 8:19 am
by tb@djh.dk
Hi

I have tried different copy/paste/"change a bit" tricks a could come up with.
All I wanna do is send an e-mail to all staff, when a new canned response is created and/or a response has been changed?

Anyone has a very good idea?
It will be highly appreciated.

Posted: Sun Oct 14, 2007 7:32 pm
by Klemen
Try something like

Code: Select all

$admins=array();
$sql = "SELECT `email` FROM `hesk_users`";
$result = hesk_dbQuery($sql) or hesk_error("$hesklang[cant_sql]: $sql");
while ($myuser=hesk_dbFetchAssoc($result)) {$admins[]=$myuser['email'];}
$email=implode(',',$admins);

mail($email,"New canned response added","A new canned response has been added to ..."); 

ok, whats wrong with this one

Posted: Mon Oct 15, 2007 10:14 am
by tb@djh.dk
Thank you very much for that, I have a small problem, when I use this code, the mail doesn't have anything in "From" field
If I leave these to lines out,
$headers="From: $hesk_settings[noreply_mail]\n";
$headers.="Reply-to: $hesk_settings[noreply_mail]\n"; it says its from www, where does the www come from?

$admins=array();
$sql = "SELECT `email` FROM `hesk_users`";
$result = hesk_dbQuery($sql) or hesk_error("$hesklang[cant_sql]: $sql");
while ($myuser=hesk_dbFetchAssoc($result)) {$admins[]=$myuser['email'];}
$email=implode(',',$admins);

/* Get e-mail message for customer */
$fp=fopen('emails/canned_response.txt','r');
$message=fread($fp,filesize('emails/canned_response.txt'));
fclose($fp);

$message=str_replace('%%message%%',$msg,$message);
$message=str_replace('%%title%%',$savename,$message);
$message=str_replace('%%NAME%%',$name,$message);
$message=str_replace('%%SUBJECT%%',$subject,$message);


/* Send e-mail */
$headers="From: $hesk_settings[noreply_mail]\n";
$headers.="Reply-to: $hesk_settings[noreply_mail]\n";
mail($to = "user@domain.dk",$hesklang['canned_response'].$subject,$message,$headers);

Posted: Mon Oct 15, 2007 12:49 pm
by Klemen
That's the default PHP setting, include the From: header (reply-to isn't necessary) to display the correct from address.