symfony2 - swiftmail symfony duplicate check for error log / email before sending -



symfony2 - swiftmail symfony duplicate check for error log / email before sending -

i run duplicate content check before firing off email whcih uses swiftmailer within symph2 app send me dev error log entries.

this functionality sits right next error log database function, has duplicate check, although 1 much easier, uses sql.

for one, want maintain lastly mail service sent body atleast next 10 emails sent, if error log goes out of control, wont maintain firing me duplicate emails of same error.

should collect body onto object holds lastly 10 email bodies, , attach swift mailer class? or there easier way, using embedded in swift mailer kind of post sending use? or maybe session..

edit, phone call swift mailer backend helper class, think can pretty much there long atleast semi-elegant.

edit refined version of method calls both persist , firing of email

<?php class somewierdclass { public function addlogaction(request $request, $persist = true, $addemail = true) { $responseadd = array(); if ($this->getrequest()->request->all() !== null) { $data = $this->getrequest()->request->get('data') ? $this->getrequest()->request->get('data') : 'no_data'; $duplicate = $this->getrequest()->request->get('duplicate', null); } if ($addemail) { $responseadd[] = 'firedit'; $this->fireemailstring('you have error log here. <br>' . $data); } if ($persist) { $responseadd[] = 'persistedit'; $this->persistlog($data, $duplicate); } if ($responseadd) { $body = implode(', ', $responseadd); homecoming new response($body); } } }

log emails in table , check there isn't duplicate every time send email.

to this, should create helper function queries emails table entries who's body matches body send. if query returns nothing, know isn't duplicate. send email , log database. otherwise, if returned (a) record(s), send dev error log entry.

if check against lastly 10 emails, querying both $body == $new_body , $id >= ($total_rows-10)

you inject container , phone call using this

$this->container->get('helper')->sendemail($body, $subject, $recipients);

symfony2 duplicate-removal swiftmailer

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -