@@ -97,7 +97,9 @@ public function addTo($email, $name = "")
9797
9898 public function removeTo ($ email )
9999 {
100- if (array_key_exists ($ email , $ this ->to )) unset($ this ->to [$ email ]);
100+ if (array_key_exists ($ email , $ this ->to )) {
101+ unset($ this ->to [$ email ]);
102+ }
101103 $ this ->replaceHeaderTo ();
102104 return $ this ;
103105 }
@@ -116,7 +118,9 @@ public function addCc($email, $name = "")
116118
117119 public function removeCc ($ email )
118120 {
119- if (array_key_exists ($ email , $ this ->cc )) unset($ this ->cc [$ email ]);
121+ if (array_key_exists ($ email , $ this ->cc )) {
122+ unset($ this ->cc [$ email ]);
123+ }
120124 $ this ->replaceHeaderCc ();
121125 return $ this ;
122126 }
@@ -135,7 +139,9 @@ public function addBcc($email, $name = "")
135139
136140 public function removeBcc ($ email )
137141 {
138- if (array_key_exists ($ email , $ this ->bcc )) unset($ this ->bcc [$ email ]);
142+ if (array_key_exists ($ email , $ this ->bcc )) {
143+ unset($ this ->bcc [$ email ]);
144+ }
139145 $ this ->replaceHeaderBcc ();
140146 return $ this ;
141147 }
@@ -148,8 +154,12 @@ public function getBcc()
148154 public function setFrom ($ email , $ name = "" )
149155 {
150156 $ email = (string )$ email ;
151- if (!$ email ) return $ this ;
152- if (!$ this ->checkEmail ($ email )) return $ this ;
157+ if (!$ email ) {
158+ return $ this ;
159+ }
160+ if (!$ this ->checkEmail ($ email )) {
161+ return $ this ;
162+ }
153163 $ contact = $ this ->getContact ($ email , $ name );
154164 $ this ->setHeaderRaw ("From " , $ contact );
155165 return $ this ;
@@ -269,7 +279,7 @@ private function createBodyMessagePlainPart($content)
269279 {
270280 $ text = "\r\nContent-type: text/plain; charset=UTF-8 \r\n" ;
271281 $ text .= "Content-Transfer-Encoding: base64 \r\n\r\n" ;
272- $ text .= chunk_split ($ content ). "\r\n" ;
282+ $ text .= chunk_split ($ content ) . "\r\n" ;
273283 return $ text ;
274284 }
275285
@@ -282,7 +292,7 @@ private function createBodyMessageHtmlPart($content)
282292
283293 $ part = "\r\nContent-type: text/html; charset=UTF-8 \r\n" ;
284294 $ part .= "Content-Transfer-Encoding: base64 \r\n\r\n" ;
285- $ part .= chunk_split ($ content ). "\r\n" ;
295+ $ part .= chunk_split ($ content ) . "\r\n" ;
286296 $ parts [] = $ part ;
287297 $ parts [] = "-- " ;
288298 $ text .= implode ("-- $ boundary " , $ parts );
@@ -299,7 +309,7 @@ public function getBody()
299309 $ part = "\r\nContent-type: {$ attachment ["mime " ]}; name= $ name \r\n" ;
300310 $ part .= "Content-Transfer-Encoding: base64 \r\n" ;
301311 $ part .= "Content-Disposition: attachment \r\n\r\n" ;
302- $ part .= chunk_split ($ attachment ["content " ]). "\r\n" ;
312+ $ part .= chunk_split ($ attachment ["content " ]) . "\r\n" ;
303313 $ parts [] = $ part ;
304314 }
305315 $ parts [] = "-- " ;
@@ -317,7 +327,7 @@ public function getPersonalMessages()
317327 {
318328 $ result = array ();
319329 $ recipients = array_replace ($ this ->to , $ this ->cc , $ this ->bcc );
320- foreach ($ recipients as $ email=> $ recipient ) {
330+ foreach ($ recipients as $ email => $ recipient ) {
321331 $ clone = clone $ this ;
322332 $ clone ->to = array (
323333 $ email => $ recipient ,
@@ -362,13 +372,23 @@ private function checkEmail($email)
362372 private function addAddress ($ type , $ email , $ name )
363373 {
364374 $ email = (string )$ email ;
365- if (!$ email ) return false ;
366- if (!$ this ->checkEmail ($ email )) return false ;
375+ if (!$ email ) {
376+ return false ;
377+ }
378+ if (!$ this ->checkEmail ($ email )) {
379+ return false ;
380+ }
367381 $ contact = $ this ->getContact ($ email , $ name );
368382 switch ($ type ) {
369- case "to " : $ this ->to [$ email ] = $ contact ; break ;
370- case "cc " : $ this ->cc [$ email ] = $ contact ; break ;
371- case "bcc " : $ this ->bcc [$ email ] = $ contact ; break ;
383+ case "to " :
384+ $ this ->to [$ email ] = $ contact ;
385+ break ;
386+ case "cc " :
387+ $ this ->cc [$ email ] = $ contact ;
388+ break ;
389+ case "bcc " :
390+ $ this ->bcc [$ email ] = $ contact ;
391+ break ;
372392 }
373393 return true ;
374394 }
@@ -391,10 +411,14 @@ private function replaceHeaderBcc()
391411 private function getContact ($ email , $ name = "" )
392412 {
393413 $ email = (string )$ email ;
394- $ name = preg_replace ("/[^\pL\s\,\ .\d]/ui " , "" , (string )$ name );
414+ $ name = preg_replace ("/[^\pL\s, .\d]/ui " , "" , (string )$ name );
395415 $ name = trim ($ name );
396- if (preg_match ("/[^a-z0-9\s]+/ui " , $ name )) $ name = $ this ->headerEncode ($ name );
397- if ($ name ) $ name = "$ name " ;
416+ if (preg_match ("/[^a-z0-9\s]+/ui " , $ name )) {
417+ $ name = $ this ->headerEncode ($ name );
418+ }
419+ if ($ name ) {
420+ $ name = "$ name " ;
421+ }
398422 return "$ name< $ email> " ;
399423 }
400424
@@ -426,7 +450,7 @@ public function unserialize($serialized)
426450 "bcc " => array (),
427451 "boundary " => md5 (time ()),
428452 );
429- foreach ($ keys as $ key=> $ default ) {
453+ foreach ($ keys as $ key => $ default ) {
430454 $ this ->$ key = array_key_exists ($ key , $ raw ) ? $ raw [$ key ] : $ default ;
431455 }
432456 }
@@ -436,4 +460,4 @@ private function headerEncode($value)
436460 $ value = mb_encode_mimeheader ($ value , "UTF-8 " , "B " , "\r\n" , 0 );
437461 return $ value ;
438462 }
439- }
463+ }
0 commit comments