Page 1 of 1

Sendmail not working

Posted: 2024-04-16 20:44
by rpierce
Hello AppGini friends,

I've been using hooks to send emails in the hooks tablename_after_insert function, and it has been working fine until a few days ago. The PHP code I am using calls for 'sendmail'. I'm wondering if anyone has suggestions on a different or better way to send automated emails in this hook?

Thank you in advance.

Partial code. Some variables comprise much of the email message but don't affect the sendmail service.

Code: Select all

        $response =sql("SELECT contacts.email_address
            FROM `contacts`
            WHERE contacts.notify = 'yes'
            AND contacts.project_id = $auditproject",$eo);
        	while ($row = db_fetch_assoc($response)) {
	            $receipt[] = $row['email_address'];
	}
//****************************************************************************


    $msgTEXT = "<strong>The following audit finding was submitted by <u>$authorname</u>.</strong>"."


<strong>Project: </strong><u>$projectname</u>

<strong>Date of audit: </strong>$auditdate&nbsp;&nbsp;<strong>Auditor: </strong>$auditorname

<strong>Deficiency Found?: </strong>{$data['risk']}
<strong>Area audited: </strong>$area
<strong>Category: </strong>$category
<strong>Subcategory: </strong>$subcategory

<strong>Findings:</strong>
{$data['find1']}

<strong>Follow up required?: </strong>{$data['fu']}
<strong>Follow up completed?: </strong>{$data['fu_comp']}

<strong>Follow up description:
</strong>{$data['fu_desc']}

<strong>Person responsible for follow up: </strong>{$data['resp']}
<strong>Follow up closure target date: </strong>{$data['targ_date']}

<strong>Closure Status</strong>

<strong>Finding closed?: </strong>{$data['closed']}
<strong>Finding closure date: </strong>{$data['close_date']}

";
    
    
  	foreach ($receipt as $address){
    
    sendmail(array(
	
		// mail recipient
		'to' => $address,
		
		'name' => "",

		// subject
		'subject' => "An audit has been submitted for $projectname ",
		
		// message
		'message' => nl2br (stripcslashes($msgTEXT)),
        
    // sender address
        "From: [email protected]"
    ));
	}
    
    //end email code

		return TRUE;
	}

Re: Sendmail not working

Posted: 2024-04-17 22:09
by Marcelo Vitoria
I don't use SendMail, but I've been using this function for years and so far I haven't had any problems:

It's in TABLENAME.php in Hooks

Code: Select all

function Pedido_after_update($data, $memberInfo, &$args){
	               $IDPedido = $data['selectedID'];						 
                       $email_empresa = sqlValue("SELECT Email FROM Configuracao WHERE Codigo='NASCA'");			
                       $assunto = "Pedido lancado/alterado em vendas";
		       $corpo = "Prezados,\n\nPedido foi lancado / editado por {$memberInfo['username']} \n\nO Pedido pode ser acessado no Sistema.";
                       mail($email_empresa, $assunto, $corpo, "De: $REMOTE_ADDR"); 
	return TRUE;
}