Advertisement:
NameCheap

Author Topic: Daily Digest eMail - help with fixing code for proper message format  (Read 1795 times)

Offline SportPistol

  • Semi-Newbie
  • *
  • Posts: 12
  • Gender: Male
I posted this problem in the SMF 2.0 Support board and the question is still out there.  topic
Since this problem is code question, thought I would post it here. 
From the topic above, the Daily Digest code that was implemented generates an eMail with new topics; however, the URL Links and message are not properly formatted.
Here is an example:

The following topics have been started:
-----------------------------------------------
"<a href="hxxp://www.mywebsite.org/forums/index.php?topic=1513">Whats New Automatons - Admin Test Message II</a>" in "<a href="hxxp://www.mywebsite.org/forums/index.php?board=32">Sandbox</a>"

The code that generates this line in the eMail is:
Code: [Select]
$email['body'] .= "\n" . sprintf($langtxt[$lang]['topic_lines'], ('<a href="' . $scripturl . '?topic=' . $topic['id'] . '">' . $topic['subject'] . '</a>'), ('<a href="' . $scripturl . '?board=' . $board['id'] . '">' . $board['name'] . '</a>'));
What must be changed in this code to deliver a properly formatted message with active URL links?



Offline IchBin™

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 11,110
  • Gender: Male
  • I don't speak German.
    • IchBin.us
Re: Daily Digest eMail - help with fixing code for proper message format
« Reply #1 on: March 05, 2012, 09:51:19 PM »
I think what you have to do is to tell the sendmail function to send an HTML email. Nothing you have to do in the body section there. Look for the sendmail() function call after that code you have their, check to see if the parameter is set to true for sending an HTML email.
Brad "IchBin™" Grow        TinyPortal        Themes
Coding Guidelines       

Offline SportPistol

  • Semi-Newbie
  • *
  • Posts: 12
  • Gender: Male
Re: Daily Digest eMail - help with fixing code for proper message format
« Reply #2 on: March 06, 2012, 10:07:40 PM »
Thank you.
Modified Sendmail() in ScheduledTasks.php to:
Code: [Select]
sendmail($email['email'], $email['subject'], $email['body'], null, null, true, 4);
Changing the format of the eMail message to HTML corrected the Absolute URL behavior.
Fixed one problem and created another.

eMail message is now a run on sentence.  the Line Feed (paragraph returns) are lost.
Any suggestions on where to correct the formatting of the message?

Offline IchBin™

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 11,110
  • Gender: Male
  • I don't speak German.
    • IchBin.us
Re: Daily Digest eMail - help with fixing code for proper message format
« Reply #3 on: March 06, 2012, 10:24:52 PM »
The formatting is in the code you posted. Simple add some line < br >'s to it where you need them.
Brad "IchBin™" Grow        TinyPortal        Themes
Coding Guidelines       

Offline SportPistol

  • Semi-Newbie
  • *
  • Posts: 12
  • Gender: Male
Re: Daily Digest eMail - help with fixing code for proper message format
« Reply #4 on: March 09, 2012, 10:40:05 PM »
Thank you IchBin!
Problem is resolved and closed.
I updated the Daily Digest post at topic with the results.
The daily/weekly digest is now working and generating a properly formatted HTML eMail message.
Much Appreciated!