Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: SportPistol on March 04, 2012, 10:19:12 PM

Title: Daily Digest eMail - help with fixing code for proper message format
Post by: SportPistol on March 04, 2012, 10:19:12 PM
I posted this problem in the SMF 2.0 Support board and the question is still out there.  topic (http://www.simplemachines.org/community/index.php?topic=468814.0)
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:
$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?


Title: Re: Daily Digest eMail - help with fixing code for proper message format
Post by: IchBin™ 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.
Title: Re: Daily Digest eMail - help with fixing code for proper message format
Post by: SportPistol on March 06, 2012, 10:07:40 PM
Thank you.
Modified Sendmail() in ScheduledTasks.php to:
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?
Title: Re: Daily Digest eMail - help with fixing code for proper message format
Post by: IchBin™ 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.
Title: Re: Daily Digest eMail - help with fixing code for proper message format
Post by: SportPistol on March 09, 2012, 10:40:05 PM
Thank you IchBin!
Problem is resolved and closed.
I updated the Daily Digest post at topic (http://www.simplemachines.org/community/index.php?topic=414520.0) with the results.
The daily/weekly digest is now working and generating a properly formatted HTML eMail message.
Much Appreciated!