How to use setFrom method of mailer class

Best Atoum code snippet using mailer.setFrom

Mail.php

Source:Mail.php Github

copy

Full Screen

...14 public function suAdminCityhallAccess($user, $content)15 {16 $message = \Swift_Message::newInstance()17 ->setSubject('NOUS Ensemble Accès de votre compte super-admin communauté')18 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))19 ->setTo($user->getEmail());20 $message->addPart($content, 'text/html');21 $this->container->get('mailer')->send($message);22 }23 public function adminCityhallAccess($user, $content)24 {25 $message = \Swift_Message::newInstance()26 ->setSubject('NOUS Ensemble Accès de votre compte admin communauté')27 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))28 ->setTo($user->getEmail());29 $message->addPart($content, 'text/html');30 $this->container->get('mailer')->send($message);31 }32 public function updateReportingModerate($user, $content, $reporting)33 {34 $message = \Swift_Message::newInstance()35 ->setSubject('NOUS Ensemble Votre signalement ' . $reporting->getTitle())36 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))37 ->setTo($user->getEmail());38 $message->addPart($content, 'text/html');39 $this->container->get('mailer')->send($message);40 }41 public function userReport($content, $object, $to)42 {43 $message = \Swift_Message::newInstance()44 ->setSubject('NOUS Ensemble Signalement de compte citoyen : ' . $object)45 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))46 ->setTo($to);47 $message->addPart($content, 'text/html');48 $this->container->get('mailer')->send($message);49 }50 public function enableUser($user, $content, $enable)51 {52 $message = \Swift_Message::newInstance()53 ->setSubject('NOUS Ensemble Votre compte citoyen a été ' . ($enable ? 'activé' : 'désactivé') . ' par la communauté')54 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))55 ->setTo($user->getEmail());56 $message->addPart($content, 'text/html');57 $this->container->get('mailer')->send($message);58 }59 60 public function acceptUser($user, $content)61 {62 $message = \Swift_Message::newInstance()63 ->setSubject('NOUS Ensemble Votre demande de liaison à une Communauté a été acceptée')64 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))65 ->setTo($user->getEmail());66 $message->addPart($content, 'text/html');67 $this->container->get('mailer')->send($message);68 }69 70 public function refuseUser($user, $content)71 {72 $message = \Swift_Message::newInstance()73 ->setSubject('NOUS Ensemble Votre demande de liaison à une Communauté a été refusée')74 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))75 ->setTo($user->getEmail());76 $message->addPart($content, 'text/html');77 $this->container->get('mailer')->send($message);78 }79 public function enableUserAdmin($user, $content, $enable)80 {81 $message = \Swift_Message::newInstance()82 ->setSubject('NOUS Ensemble Votre compte admin communauté a été ' . ($enable ? 'activé' : 'désactivé') . ' par la communauté')83 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))84 ->setTo($user->getEmail());85 $message->addPart($content, 'text/html');86 $this->container->get('mailer')->send($message);87 }88 public function commentDelete($mails, $content)89 {90 $message = \Swift_Message::newInstance()91 ->setSubject('NOUS Ensemble Suppression d’un commentaire')92 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))93 ->setTo($mails);94 $message->addPart($content, 'text/html');95 $this->container->get('mailer')->send($message);96 }97 public function moderateAssociation($user, $content)98 {99 $message = \Swift_Message::newInstance()100 ->setSubject('NOUS Ensemble Votre groupe/association a été accepté par la communauté.')101 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))102 ->setTo($user->getEmail());103 $message->addPart($content, 'text/html');104 $this->container->get('mailer')->send($message);105 }106 public function enableAssociation($user, $content, $enable)107 {108 $message = \Swift_Message::newInstance()109 ->setSubject('NOUS Ensemble Votre groupe / association a été ' . ($enable ? 'activé' : 'désactivé') . ' par la communauté')110 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))111 ->setTo($user->getEmail());112 $message->addPart($content, 'text/html');113 $this->container->get('mailer')->send($message);114 }115 public function moderateMerchant($user, $content)116 {117 $message = \Swift_Message::newInstance()118 ->setSubject('NOUS Ensemble Votre commerce / partenaire a été accepté par la communauté')119 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))120 ->setTo($user->getEmail());121 $message->addPart($content, 'text/html');122 $this->container->get('mailer')->send($message);123 }124 public function enableMerchant($user, $content, $enable)125 {126 $message = \Swift_Message::newInstance()127 ->setSubject('NOUS Ensemble Votre commerce / partenaire a été ' . ($enable ? 'activé' : 'désactivé') . ' par la communauté')128 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))129 ->setTo($user->getEmail());130 $message->addPart($content, 'text/html');131 $this->container->get('mailer')->send($message);132 }133 public function updateArticle($user, $content, $article)134 {135 $message = \Swift_Message::newInstance()136 ->setSubject('NOUS Ensemble Votre article ' . $article->getTitle() . ' a été mis à jour')137 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))138 ->setTo($user->getEmail());139 $message->addPart($content, 'text/html');140 $this->container->get('mailer')->send($message);141 }142 public function enableArticle($user, $content, $enable)143 {144 $message = \Swift_Message::newInstance()145 ->setSubject('NOUS Ensemble Votre article a été ' . ($enable ? 'activé' : 'désactivé') . ' par la communauté')146 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))147 ->setTo($user->getEmail());148 $message->addPart($content, 'text/html');149 $this->container->get('mailer')->send($message);150 }151 public function updateEvent($user, $content, $event)152 {153 $message = \Swift_Message::newInstance()154 ->setSubject('NOUS Ensemble Votre événement ' . $event->getTitle() . ' a été mis à jour')155 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))156 ->setTo($user->getEmail());157 $message->addPart($content, 'text/html');158 $this->container->get('mailer')->send($message);159 }160 public function enableEvent($user, $content, $enable)161 {162 $message = \Swift_Message::newInstance()163 ->setSubject('NOUS Ensemble Votre événement a été ' . ($enable ? 'activé' : 'désactivé') . ' par la communauté')164 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))165 ->setTo($user->getEmail());166 $message->addPart($content, 'text/html');167 $this->container->get('mailer')->send($message);168 }169 public function enableGoodPlan($user, $content, $enable)170 {171 $message = \Swift_Message::newInstance()172 ->setSubject('NOUS Ensemble Votre bon plan a été ' . ($enable ? 'activé' : 'désactivé') . ' par la communauté')173 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))174 ->setTo($user->getEmail());175 $message->addPart($content, 'text/html');176 $this->container->get('mailer')->send($message);177 }178 public function moderateEvent($user, $content,$entity)179 {180 $message = \Swift_Message::newInstance()181 ->setSubject('NOUS Ensemble Votre événement a été '.($entity->getModerate() == 'accepted' ? 'accepté' : 'refusé').' par la communauté')182 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))183 ->setTo($user->getEmail());184 $message->addPart($content, 'text/html');185 $this->container->get('mailer')->send($message);186 }187 public function moderateGoodPlan($user, $content)188 {189 $message = \Swift_Message::newInstance()190 ->setSubject('NOUS Ensemble Votre bon plan a été accepté par la communauté')191 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))192 ->setTo($user->getEmail());193 $message->addPart($content, 'text/html');194 $this->container->get('mailer')->send($message);195 }196 197 public function newArticleEvent($content)198 {199 $message = \Swift_Message::newInstance()200 ->setSubject('NOUS Ensemble Un événement associé à un article a été créé')201 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))202 ->setTo($this->container->getParameter('event_email'));203 $message->addPart($content, 'text/html');204 $this->container->get('mailer')->send($message);205 }206 207 public function deleteAccountMail($subject, $content)208 {209 $message = \Swift_Message::newInstance()210 ->setSubject($subject)211 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))212 ->setTo($this->container->getParameter('admin_email'));213 $message->addPart($content, 'text/html');214 $this->container->get('mailer')->send($message);215 }216 public function addSuAdminAssociation($user, $content, $association)217 {218 $message = \Swift_Message::newInstance()219 ->setSubject('NOUS Ensemble Vous êtes maintenant super-administrateur du groupe / association ' . $association->getName())220 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))221 ->setTo($user->getEmail());222 $message->addPart($content, 'text/html');223 $this->container->get('mailer')->send($message);224 }225 public function removeSuAdminAssociation($user, $content, $association)226 {227 $message = \Swift_Message::newInstance()228 ->setSubject('NOUS Ensemble Vous n\êtes plus super-administrateur du groupe / association ' . $association->getName())229 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))230 ->setTo($user->getEmail());231 $message->addPart($content, 'text/html');232 $this->container->get('mailer')->send($message);233 }234 public function addSuAdminMerchant($user, $content, $merchant)235 {236 $message = \Swift_Message::newInstance()237 ->setSubject('NOUS Ensemble Vous êtes maintenant super-administrateur du commerce / partenaire ' . $merchant->getName())238 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))239 ->setTo($user->getEmail());240 $message->addPart($content, 'text/html');241 $this->container->get('mailer')->send($message);242 }243 public function removeSuAdminMerchant($user, $content, $merchant)244 {245 $message = \Swift_Message::newInstance()246 ->setSubject('NOUS Ensemble Vous n\êtes plus super-administrateur du commerce / partenaire ' . $merchant->getName())247 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))248 ->setTo($user->getEmail());249 $message->addPart($content, 'text/html');250 $this->container->get('mailer')->send($message);251 }252 //api mails253 public function contactMail($body, $to, $objet, $filepath=null)254 {255 /*$body = $this->container->get('templating')->renderResponse('AppBundle:Mail:contact.html.twig', [256 'user' => $user,257 'content' => $content,258 'photo' => $photo,259 'location' => $location260 ]);*/261 $message = \Swift_Message::newInstance()262 ->setSubject('NOUS Ensemble - ' . $objet)263 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))264 ->setTo($to);265 if($filepath && file_exists($filepath)) {266 $message->attach(\Swift_Attachment::fromPath($filepath));267 }268 /*dump($message->attach(\Swift_Attachment::fromPath($filepath)));269 exit;*/270 $message->addPart($body, 'text/html');271 $this->container->get('mailer')->send($message);272 }273 public function contactConfirmationMail($body, $object, $user)274 {275 $message = \Swift_Message::newInstance()276 ->setSubject('NOUS Ensemble - ' . $object)277 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))278 ->setTo($user->getEmail());279 $message->addPart($body, 'text/html');280 $this->container->get('mailer')->send($message);281 }282 public function sendCreationMail($user, $type)283 {284 $body = $this->container->get('templating')->render('AppBundle:Mail:accountCreation.html.twig', [285 'user' => $user,286 'type' => $type,287 ]);288 $message = \Swift_Message::newInstance()289 ->setSubject('NOUS Ensemble Compte ' . $type . ' en attente de validation')290 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))291 ->setTo($user->getEmail());292 $message->addPart($body, 'text/html');293 $this->container->get('mailer')->send($message);294 }295 public function sendResettingMail($user, $password)296 {297 $body = $this->container->get('templating')->render('AppBundle:Mail:resetting_password.html.twig', [298 'password' => $password,299 ]);300 $message = \Swift_Message::newInstance()301 ->setSubject('NOUS Ensemble Demande de réinitialisation du mot de passe')302 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))303 ->setTo($user->getEmail());304 $message->addPart($body, 'text/html');305 $this->container->get('mailer')->send($message);306 }307 public function sendBenevolesMail($sender, $user, $object, $email, $event, $account, $type)308 {309 $body = $this->container->get('templating')->render('AppBundle:Mail:benvoles.html.twig', [310 'email' => $email,311 'event' => $event,312 'account' => $account,313 'type' => $type == "merchant" ? "du commerce / partenaire" : "du groupe / association",314 ]);315 $message = \Swift_Message::newInstance()316 ->setSubject('NOUS Ensemble ' . $object)317 ->setFrom($sender->getEmail())318 ->setTo($user->getEmail());319 $message->addPart($body, 'text/html');320 $this->container->get('mailer')->send($message);321 }322 public function sendRoomMail($sender, $user, $event, $content)323 {324 $body = $this->container->get('templating')->render('AppBundle:Mail:roomAsking.html.twig', [325 'sender' => $sender,326 'event' => $event,327 'content' => $content,328 ]);329 $message = \Swift_Message::newInstance()330 ->setSubject('NOUS Ensemble Demande de réservation d\'une salle')331 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))332 //->setFrom($sender->getEmail())333 ->setTo($user);334 $message->addPart($body, 'text/html');335 $this->container->get('mailer')->send($message);336 }337 public function sendConfirmationMail($user, $email, $password)338 {339 $body = $this->container->get('templating')->render('AppBundle:Mail:confirmation.html.twig', [340 'email' => $email,341 'password' => $password,342 'firstname' => $user->getFirstname(),343 'lastname' => $user->getLastname(),344 ]);345 $message = \Swift_Message::newInstance()346 ->setSubject('NOUS Ensemble Validation Compte')347 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))348 ->setTo($email);349 $message->addPart($body, 'text/html');350 $this->container->get('mailer')->send($message);351 }352 public function sendInfoAdminMail($email, $user, $type, $entity)353 {354 $body = $this->container->get('templating')->render('AppBundle:Mail:addAdmin.html.twig', [355 'user' => $user,356 'type' => $type,357 'entity' => $entity358 ]);359 $account = ($type == 'association') ? " du groupe / association " : " du commerce / partenaire ";360 $subject ="NOUS Ensemble Vous êtes maintenant administrateur " . $account . " " . $entity->getName();361 $message = \Swift_Message::newInstance()362 ->setSubject($subject)363 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))364 ->setTo($email);365 $message->addPart($body, 'text/html');366 $this->container->get('mailer')->send($message);367 }368 public function sendInvitationMail($email, $user)369 {370 $body = $this->container->get('templating')->render('AppBundle:Mail:invitation.html.twig', [371 'user' => $user,372 ]);373 $message = \Swift_Message::newInstance()374 ->setSubject('NOUS Ensemble ' . $user->getLastname() . " vous a invité à rejoindre NOUS-Ensemble")375 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))376 ->setTo($email);377 $message->addPart($body, 'text/html');378 $this->container->get('mailer')->send($message);379 }380 public function sendJoinPrivateCommunity($email, $user,$community)381 {382 $body = $this->container->get('templating')->render('AppBundle:Mail:joinPrivateCommunity.html.twig', [383 'user' => $user,384 'community' => $community385 ]);386 $message = \Swift_Message::newInstance()387 ->setSubject('NOUS Ensemble ' . $user->getLastname() . " souhaite rejoindre votre communauté privée ".$community->getName())388 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))389 ->setTo($email);390 $message->addPart($body, 'text/html');391 $this->container->get('mailer')->send($message);392 }393 public function sendCarpoolAnswerCreator($carpool, $user,$phoneUser)394 {395 $body = $this->container->get('templating')->render('AppBundle:Mail:carpoolAnswerCreator.html.twig', [396 'user' => $user,397 'phoneUser' => $phoneUser,398 'carpool' => $carpool399 ]);400 $message = \Swift_Message::newInstance()401 ->setSubject('NOUS Ensemble ' . $user->getLastname() . " souhaite rejoindre votre covoiturage")402 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))403 ->setTo($carpool->getCreateBy()->getEmail());404 $message->addPart($body, 'text/html');405 $this->container->get('mailer')->send($message);406 }407 public function sendCarpoolAnswerUser($carpool, $user)408 {409 $body = $this->container->get('templating')->render('AppBundle:Mail:carpoolAnswerUser.html.twig', [410 'user' => $user,411 'carpool' => $carpool412 ]);413 $message = \Swift_Message::newInstance()414 ->setSubject('NOUS Ensemble demande de covoiturage')415 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))416 ->setTo($user->getEmail());417 $message->addPart($body, 'text/html');418 $this->container->get('mailer')->send($message);419 }420 public function sendCancelCarpoolAnswerCreator($carpool, $user)421 {422 $body = $this->container->get('templating')->render('AppBundle:Mail:carpoolCancelAnswerCreator.html.twig', [423 'user' => $user,424 'carpool' => $carpool425 ]);426 $message = \Swift_Message::newInstance()427 ->setSubject('NOUS Ensemble ' . $user->getLastname() . " a annulé sa demande de covoiturage")428 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))429 ->setTo($carpool->getCreateBy()->getEmail());430 $message->addPart($body, 'text/html');431 $this->container->get('mailer')->send($message);432 }433 public function sendCancelCarpoolAnswerUser($carpool, $user)434 {435 $body = $this->container->get('templating')->render('AppBundle:Mail:carpoolCancelAnswerUser.html.twig', [436 'user' => $user,437 'carpool' => $carpool438 ]);439 $message = \Swift_Message::newInstance()440 ->setSubject('NOUS Ensemble annulation de la demande de covoiturage')441 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))442 ->setTo($user->getEmail());443 $message->addPart($body, 'text/html');444 $this->container->get('mailer')->send($message);445 }446 public function sendJoinMerchantOrAssociation($user,$merchant,$phone, $merchantOrAssociation)447 {448 $body = $this->container->get('templating')->render('AppBundle:Mail:joinMerchantOrAssociation.html.twig', [449 'user' => $user,450 'phone' => $phone,451 'merchant' => $merchant,452 'merchantOrAssociation' => $merchantOrAssociation453 ]);454 if($merchantOrAssociation == 'merchant') {455 $subject = 'NOUS Ensemble ' . $user->getLastname() . " souhaite rejoindre Votre commerce / partenaire ".$merchant->getName();456 }else{457 $subject = 'NOUS Ensemble ' . $user->getLastname() . " souhaite rejoindre votre Groupe / Association ".$merchant->getName();458 }459 $message = \Swift_Message::newInstance()460 ->setSubject($subject)461 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))462 ->setTo($merchant->getSuAdmin()->getEmail());463 $message->addPart($body, 'text/html');464 $this->container->get('mailer')->send($message);465 }466 public function contactMerchant($goodplan, $user, $data)467 {468 $body = $this->container->get('templating')->render('AppBundle:Mail:contactMerchant.html.twig', [469 'user' => $user,470 'goodplan' => $goodplan,471 'data' => $data472 ]);473 $message = \Swift_Message::newInstance()474 ->setSubject('NOUS Ensemble d\'information')475 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))476 ->setTo($goodplan->getMerchant()->getSuAdmin()->getEmail());477 $message->addPart($body, 'text/html');478 $this->container->get('mailer')->send($message);479 }480 /**481 * @param Carpooling $carpool482 * @param User $user483 */484 public function sendCarpoolRecap($carpool, $user)485 {486 $body = $this->container->get('templating')->render('AppBundle:Mail:mailRecapCarpool.html.twig', [487 'user' => $user,488 'carpool' => $carpool,489 ]);490 $message = \Swift_Message::newInstance()491 ->setSubject('NOUS Ensemble d\'information')492 ->setFrom(array($this->container->getParameter('no_reply_email') => $this->container->getParameter('no_reply_name')))493 ->setTo($user->getEmail());494 $message->addPart($body, 'text/html');495 $this->container->get('mailer')->send($message);496 }497}...

Full Screen

Full Screen

MailerTest.php

Source:MailerTest.php Github

copy

Full Screen

...43 */44 public function testSetMessageNormal()45 {46 $body = 'hello twig';47 $this->object->setFrom($GLOBALS['MAIL_FROM']);48 $this->object->setName($GLOBALS['MAIL_NAME']);49 $res = $this->object->setMessage(50 'test subject',51 $body52 );53 $this->assertInternalType('object', $res);54 }55 /**56 * 正常系 $formが正しく設定されるか57 *58 * @covers Lib\SwiftMailer\Mailer::setFrom()59 * @test testSetFromNormal()60 */61 public function testSetFromNormal()62 {63 $class = new \ReflectionClass($this->object);64 $ref = $class->getProperty('from');65 $ref->setAccessible(true);66 $this->object->setFrom('test@example.com');67 $res = $ref->getValue($this->object);68 $this->assertEquals('test@example.com', $res);69 }70 /**71 * 正常系 $nameが正しく設定されるか72 *73 * @covers Lib\SwiftMailer\Mailer::setName()74 * @test testSetNameNormal()75 */76 public function testSetNameNormal()77 {78 $class = new \ReflectionClass($this->object);79 $ref = $class->getProperty('name');80 $ref->setAccessible(true);81 $this->object->setName('システム自動通知');82 $res = $ref->getValue($this->object);83 $this->assertEquals('システム自動通知', $res);84 }85 /**86 * 正常系 添付ファイルを添付してもメッセージも返すか87 *88 * @covers Lib\SwiftMailer\Mailer::setAttachment()89 * @test testSetAttachmentNormal()90 */91 public function testSetAttachmentNormal()92 {93 $class = new \ReflectionClass($this->object);94 $ref = $class->getProperty('attach');95 $ref->setAccessible(true);96 $this->object->setAttachment(97 'tests/imgs/test.jpg',98 'image/jpeg'99 );100 $res = $ref->getValue($this->object);101 $this->assertInternalType('object', $res);102 }103 /**104 * 正常系 メッセージを返すか105 *106 * @covers Lib\SwiftMailer\Mailer::send()107 * @test testSetSendNormal()108 */109 public function testSendNormal()110 {111 $body = 'hello twig';112 $this->object->setFrom($GLOBALS['MAIL_FROM']);113 $this->object->setName($GLOBALS['MAIL_NAME']);114 $this->object->setMessage(115 'タイトル',116 $body117 );118 $res = $this->object->send(119 'test@example.com'120 );121 $this->assertEquals(1, $res['1']);122 }123 /**124 * 異常系例外 間違ったメールアドレスでもメッセージを返すか125 *126 * @covers Lib\SwiftMailer\Mailer::send()127 * @test testSetSendExceptionRfc()128 */129 public function testSetSendExceptionRfc()130 {131 $body = 'hello twig';132 $this->object->setFrom($GLOBALS['MAIL_FROM']);133 $this->object->setName($GLOBALS['MAIL_NAME']);134 $this->object->setMessage(135 'タイトル',136 $body137 );138 $res = $this->object->send(139 'failure'140 );141 $this->assertEquals('RFC Compliance Error', $res['1']);142 }143 /**144 * 正常系 添付画像を含むメッセージを返すか145 *146 * @covers Lib\SwiftMailer\Mailer::send()147 * @test testSetSendAttachmentNormal()148 */149 public function testSendAttachmentNormal()150 {151 $body = 'hello twig';152 $this->object->setAttachment(153 'tests/imgs/test.jpg',154 'image/jpeg',155 'test'156 );157 $this->object->setFrom($GLOBALS['MAIL_FROM']);158 $this->object->setName($GLOBALS['MAIL_NAME']);159 $this->object->setMessage(160 '添付画像テスト',161 $body162 );163 $res = $this->object->send(164 'test@example.com'165 );166 $this->assertEquals(1, $res['1']);167 }168 /**169 * 正常系 ログファイルが生成されるか170 *171 * @covers Lib\SwiftMailer\Mailer::saveLog()172 * @test testSetSaveLog()173 */174 public function testSetSaveLog()175 {176 $body = 'hello twig';177 $this->object->setFrom($GLOBALS['MAIL_FROM']);178 $this->object->setName($GLOBALS['MAIL_NAME']);179 $this->object->setMessage(180 'タイトル',181 $body182 );183 $this->object->send(184 'test@example.com'185 );186 $this->object->saveLog();187 $file = $this->object->getPath();188 $this->assertFileExists($file);189 }190 /**191 * 正常系 ログファイルのパスが取得できるか192 *193 * @covers Lib\SwiftMailer\Mailer::getPath()194 * @test testSetGetPath()195 */196 public function testSetGetPath()197 {198 $body = 'hello twig';199 $this->object->setFrom($GLOBALS['MAIL_FROM']);200 $this->object->setName($GLOBALS['MAIL_NAME']);201 $this->object->setMessage(202 'タイトル',203 $body204 );205 $this->object->send(206 'test@example.com'207 );208 $res = $this->object->getPath();209 $this->assertInternalType('string', $res);210 }211}...

Full Screen

Full Screen

Mailer.php

Source:Mailer.php Github

copy

Full Screen

...14 }15 public function sendNewUser($user)16 {17 $message = (new \Swift_Message('Bienvenue'))18 ->setFrom('naopedia@gmail.com')19 ->setTo($user->getEmail())20 ->setBody(21 $this->templating->render(22 // templates/emails/registration.html.twig23 'emails/signin.html.twig',24 array('user' => $user)25 ),26 'text/html'27 );28 $this->mailer->send($message);29 }30 public function sendResetPassword($user)31 {32 $message = (new \Swift_Message('Reset de mot de passe'))33 ->setFrom('naopedia@gmail.com')34 ->setTo($user->getEmail())35 ->setBody(36 $this->templating->render(37 // templates/emails/registration.html.twig38 'emails/resetPassword.html.twig',39 array('user' => $user)40 ),41 'text/html'42 );43 $this->mailer->send($message);44 }45 public function sendObservatioValid($observation)46 {47 $message = (new \Swift_Message('Observation validée'))48 ->setFrom('naopegia@gmail.com')49 ->setTo($observation->getUser()->getEmail())50 ->setBody(51 $this->templating->render(52 'emails/email-validation.html.twig',53 array('observation' => $observation)54 ),55 'text/html'56 );57 $this->mailer->send($message);58 }59 public function sendObservatioRefuse($observation)60 {61 $message = (new \Swift_Message('Observation Refusée'))62 ->setFrom('naopegia@gmail.com')63 ->setTo($observation->getUser()->getEmail())64 ->setBody(65 $this->templating->render(66 'emails/email-refus.html.twig',67 array('observation' => $observation)68 ),69 'text/html'70 );71 $this->mailer->send($message);72 }73 public function sendContributionRefuse($bird)74 {75 $message = (new \Swift_Message('Contribution Refusée'))76 ->setFrom('naopegia@gmail.com')77 ->setTo($bird->getContributor()->getEmail())78 ->setBody(79 $this->templating->render(80 'emails/email-refus-contribution.html.twig',81 array('bird' => $bird)82 ),83 'text/html'84 );85 $this->mailer->send($message);86 }87 public function sendContributionValid($bird)88 {89 $message = (new \Swift_Message('Contribution Refusée'))90 ->setFrom('naopegia@gmail.com')91 ->setTo($bird->getContributor()->getEmail())92 ->setBody(93 $this->templating->render(94 'emails/email-validation-oiseau.html.twig',95 array('bird' => $bird)96 ),97 'text/html'98 );99 $this->mailer->send($message);100 }101 public function sendContact($name, $surname, $email, $mobile, $subject, $message)102 {103 $message = (new \Swift_Message($subject))104 ->setFrom('naopegia@gmail.com')105 ->setTo($email)106 ->setBody(107 $this->templating->render(108 'emails/contact.html.twig',109 array(110 'name' => $name,111 'surname'=>$surname,112 'email'=>$email,113 'mobile'=>$mobile,114 'message'=>$message)115 ),116 'text/html'117 );118 $this->mailer->send($message);119 }120 public function sendGoldenbook($user)121 {122 $message = (new \Swift_Message("Le livre d'or"))123 ->setFrom('naopegia@gmail.com')124 ->setTo($user->getEmail())125 ->setBody(126 $this->templating->render('emails/email-livre-nao.html.twig'),'text/html');127 $this->mailer->send($message);128 }129}...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger setFrom code on LambdaTest Cloud Grid

Execute automation tests with setFrom on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful