Set Opt Out for invalid Emails Logic Hook using beans ?

Hi All ,

i am using before save

for triggering mail and if mail id is provided incorrect then it should set that mail id as opt_out in leads module


<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class customer
{
	function mail_chk(&$focus, $event, $arguments)
	{
			require_once('include/SugarPHPMailer.php'); 
			$emailObj = new Email(); 
			// echo '<pre>';
			// print_r($emailObj);
			echo '<pre>';
			echo $focus->opt_out = 1 ;
			// $focus->webtolead_email_opt_out = 1;
			print_r($focus);
			die;
			$defaults = $emailObj->getSystemDefaultEmail(); 
			$mail_c = new SugarPHPMailer();
			$mail_c->setMailerForSystem();
			$mail_c->From = $defaults['email']; 
			$mail_c->FromName = $defaults['name'];
			$mail_c->Subject = "Greetings From Salusfin";
			$mail_c->Body = "Thank you very much for contacting us and interest in our products, our marketing team will get back to you as soon as possible";
			$mail_c->prepForOutbound();
			$mail_c->AddAddress($focus->email1);
			$mail_c->IsHTML(true);
			@$mail_c->Send();
		}
}

but i don’t know how to set email id opt_out using bean or any other way ???

can any one guide me on this

Thank you for your time and support

:blink:

HI All it seems i find the solution

For email sugar/ suite don’t maintain by module wise

so we just need to

update the Table :- email_addresses

search for the mail id and set 1 to opt_out field

that’s it

Thank you for your time and support

HI All ,

the opt_out problem got solved

but how can i check the delivery status in sugarphpmailer ???


if( !mail->send() ){

// this won't work because my smtp is sending the mail but the mail id is not valid so how can i check the dilivery status in sugarphpmailer ?????

}

Thanks for your time and support

Hi All ,

The simple answer is to comply with the laws in most countries and policies of most hired servers by using opt-in mailing lists

Thanks for time and support

Hi, I need to check “invalid” checkbox when sugar tells me the mail was not sent ( looks like it was your case ), well I need to know in which file I need to put the update query ???

Thanks