/** * <pre> * TalkMail::send( * // From * ['address' => '', 'name' => ''], * // Reply * ['address' => '', 'name' => ''], * // To * ['address' => '', 'name' => ''], * $subject, $body * ); * </pre> * @param array $from * @param array $reply * @param array $to * @param $subject * @param $body * @return bool|string * @throws PHPMailer\phpmailerException */ public static function send(array $from, array $reply, array $to, $subject, $body) { $mail = new PHPMailer(); $mail->CharSet = "UTF-8"; $mail->setFrom($from['address'], $from['name']); $mail->addReplyTo($reply['address'], $reply['name']); $mail->addAddress($to['address'], $to['name']); $mail->Subject = $subject; $mail->Body = $body; $mail->isHTML(); if ($_SERVER['HTTP_HOST'] == 'owncloud91.loc') { return true; } if (!$mail->send()) { return $mail->ErrorInfo; } else { return true; } }
static function messageSend($address, $messagedata, $projectname = "ownCloud", $alladdresses = array()) { $to = $address['email']; $from = $address['fromaddress']; $replyto = $address['replyto']; $subject = isset($messagedata['title']) ? $messagedata['title'] : 'OwnCollab message'; $body = isset($messagedata['text']) ? $messagedata['text'] : 'OwnCollab message'; $mail = new PHPMailer(); $mail->CharSet = "UTF-8"; $mail->setFrom($from, $address['fromname']); $mail->AddReplyTo($replyto, $address['fromname']); $mail->addAddress($to, $address['name']); $mail->Subject = $subject; //$mail->Body = $body; $emailparams = ['mode' => 'email', 'projectname' => $projectname, 'domain' => \OC::$server->getRequest()->getServerHost(), 'talktitle' => $subject, 'message-text' => $body, 'sender' => $messagedata['author'], 'subscriber' => $address['name'], 'subscribers' => self::getOtherSubscribers($address['name'], $alladdresses)]; if (!empty($messagedata['attachements'])) { $emailparams['attachlinks'] = unserialize($messagedata['attachements']); } $mail->Body = self::renderPartial($projectname, 'part.email', $emailparams); $mail->isHTML(); if (!empty($to) && !empty($from)) { if (!$mail->send()) { return $mail->ErrorInfo; } else { return true; } } else { return false; } }