Project

General

Profile

Feature #12344 » linkvalidator-swiftmailer_v2.diff

Michael Miousse, 2011-01-19 16:30

View differences:

classes/tasks/class.tx_linkvalidator_tasks_validate.php (working copy)
*/
public function execute() {
$this->setCliArguments();
$successfullyExecuted = TRUE;
$file = t3lib_div::getFileAbsFileName($this->emailfile);
$htmlFile = t3lib_div::getURL($file);
$this->templateMail = t3lib_parsehtml::getSubpart($htmlFile, '###REPORT_TEMPLATE###');
......
&& (!$this->emailonbrokenlinkonly || $this->dif)
&& !empty($this->email)
) {
$this->reportEmail($pageSections, $modTS);
$successfullyExecuted = $this->reportEmail($pageSections, $modTS);
}
return TRUE;
return $successfullyExecuted;
}
......
*/
function reportEmail($pageSections, $modTS) {
$content = t3lib_parsehtml::substituteSubpart($this->templateMail, '###PAGE_SECTION###', $pageSections);
/** @var array $markerArray */
$markerArray = array();
/** @var array $validEmailList */
$validEmailList = array();
/** @var boolean $sendEmail */
$sendEmail = TRUE;
$markerArray['totalBrokenLink'] = $this->totalBrokenLink;
$markerArray['totalBrokenLink_old'] = $this->oldTotalBrokenLink;
$content = t3lib_parsehtml::substituteMarkerArray($content, $markerArray, '###|###', TRUE, TRUE);
$Typo3_htmlmail = t3lib_div::makeInstance('t3lib_htmlmail');
$Typo3_htmlmail->start();
$Typo3_htmlmail->useBase64();
$convObj = t3lib_div::makeInstance('t3lib_cs');
$charset = $convObj->parse_charset($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] ? $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] : 'utf-8');
$Typo3_htmlmail->subject = $convObj->conv($modTS['mail.']['subject'], $charset, $modTS['mail.']['encoding'], 0);
$Typo3_htmlmail->from_email = $modTS['mail.']['fromemail'];
$Typo3_htmlmail->from_name = $modTS['mail.']['fromname'];
$Typo3_htmlmail->replyto_email = $modTS['mail.']['replytoemail'];
$Typo3_htmlmail->replyto_name = $modTS['mail.']['replytoname'];
//$Typo3_htmlmail->addPlain($mcontent);
$Typo3_htmlmail->setHTML($Typo3_htmlmail->encodeMsg($convObj->conv($content, $charset, $modTS['mail.']['encoding'], 0)));
$Typo3_htmlmail->setHeaders();
$Typo3_htmlmail->setContent();
$Typo3_htmlmail->setRecipient($this->email);
/** @var t3lib_mail_Message $mail */
$mail = t3lib_div::makeInstance('t3lib_mail_Message');
if(t3lib_div::validEmail($modTS['mail.']['fromemail'])) {
$mail->setFrom(array($modTS['mail.']['fromemail'] => $modTS['mail.']['fromname']));
}
else{
$failure = t3lib_div::makeInstance (
'Exception',
$GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/locallang.xml:tasks.error.invalidFromEmail'),
t3lib_FlashMessage::ERROR
);
throw $failure;
$sendEmail = FALSE;
}
if(t3lib_div::validEmail($modTS['mail.']['replytoemail'])) {
$mail->setReplyTo(array($modTS['mail.']['replytoemail'] => $modTS['mail.']['replytoname']));
}
if(!empty($modTS['mail.']['subject'])) {
$mail->setSubject($modTS['mail.']['subject']);
}
else{
$failure = t3lib_div::makeInstance (
'Exception',
$GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/locallang.xml:tasks.error.noSubject'),
t3lib_FlashMessage::ERROR
);
throw $failure;
$sendEmail = FALSE;
}
if (!empty($this->email)) {
$emailList = t3lib_div::trimExplode(',', $this->email);
foreach ($emailList as $emailAdd) {
if (!t3lib_div::validEmail($emailAdd)) {
$isValid = FALSE;
$failure = t3lib_div::makeInstance (
'Exception',
$GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/locallang.xml:tasks.error.invalidToEmail'),
t3lib_FlashMessage::ERROR
);
throw $failure;
$sendEmail = FALSE;
}
else{
$validEmailList[] = $emailAdd;
}
}
}
if(is_array($validEmailList) && !empty($validEmailList)) {
$mail->setTo($this->email);
}
else{
$sendEmail = FALSE;
}
if($sendEmail) {
$mail->setBody($content,'text/html');
$mail->send();
}
return $Typo3_htmlmail->sendtheMail();
return $sendEmail;
}
locallang.xml (working copy)
<label index="tasks.validate.email">Send email report to</label>
<label index="tasks.validate.emailonbrokenlinkonly">Send email on new broken links only</label>
<label index="tasks.validate.emailfile">Email template file</label>
<label index="tasks.validate.invalidEmail">Invalid email format!</label>
<label index="tasks.validate.invalidEmail">Invalid email format!</label>
<label index="tasks.validate.invalidPage">Invalid page uid, please enter a valid page uid!</label>
<label index="tasks.validate.invalidDepth">There is no depth set, please set it to one of the offered values!</label>
<label index="tasks.error.noSubject">No subject for the notification email</label>
<label index="tasks.error.invalidToEmail">Invalid email format in one or more of the reciepient email!</label>
<label index="tasks.error.invalidFromEmail">Invalid from email format</label>
</languageKey>
</data>
</T3locallang>
res/pagetsconfig.txt (working copy)
checkhidden = 0
showUpdateButton = 1
mail{
encoding = utf-8
fromname =
fromemail =
fromname = Linkvalidator
fromemail = Linkvalidator@mydomaine.com
replytoname =
replytoemail =
subject = TYPO3 Linkvalidator report
(2-2/6)