send mail, canned responses

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
tb@djh.dk
Posts: 12
Joined: Wed Aug 22, 2007 8:54 am

send mail, canned responses

Post 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.
As always, thanks in advance :-)
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Post 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 ..."); 
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
tb@djh.dk
Posts: 12
Joined: Wed Aug 22, 2007 8:54 am

ok, whats wrong with this one

Post 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);
As always, thanks in advance :-)
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

That's the default PHP setting, include the From: header (reply-to isn't necessary) to display the correct from address.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Post Reply