Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-02-2011, 06:24 PM
NickyDee NickyDee is offline
 
Join Date: Aug 2008
Posts: 53
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default HTML welcome-email code

I’m trying to make a plugin that will enable an HTML ‘welcome email’ when a user signs up. The problem seems to be that the $headers string is set to 'Content-Type: text/plain' and it needs to be 'Content-Type: text/html'.

There are already plugins that let admins send HTML emails to users that use this code to get around the problem:
Code:
 
if ($vbulletin->userinfo['usergroupid'] == 6) 
            { 
            if(strlen($message) != strlen(strip_tags($message))) 
                { 
                $headers = str_replace('Content-Type: text/plain', 'Content-Type: text/html', $headers); 
                } 
            }
So my question – can anyone suggest how I might adapt this to allow HTML welcome messages as well?

I will of course bundle it up into a plugin for everyone to use once it is complete.

--------------- Added [DATE]1299104905[/DATE] at [TIME]1299104905[/TIME] ---------------

Update:

Okay I've made some progress. The problem appears to be with the conditional which only works for adminCP emails sent from "users --> send email to users".

Code:
if ($vbulletin->userinfo['usergroupid'] == 6)
Removing the conditional would cause problems since many default vbulletin emails are not fully HTML formatted but contain some basic HTML tags. This would send them as fully HTML formatted (and they would end up all screwwed up because carriage returns are ignored in HTML emails).

So long story short... I need an additional condition that figures out whether this is the 'welcome email' or some other email. Then I can plug it in like this;

Code:
if ($vbulletin->userinfo['usergroupid'] == 6 || welcomemail_conditional == true) 
{... 

...}
Then we will have adminCP HTML emails AND HTML welcome emails but not any other emails (like forgotten password etc.)

--------------- Added [DATE]1299145970[/DATE] at [TIME]1299145970[/TIME] ---------------

Further update:

I have made a solution that works for me, but which isn't dynamic enough to be packaged into a plugin that will work for everyone. What you need to do is set your $vbphrase[welcomemail] phrase to something specific, like "Thanks for joining Sitename". Then edit the code below as needed:

Code:
 if ($vbulletin->userinfo['usergroupid'] == 6 || $subject == 'Thanks for joining Sitename')
			{
			if(strlen($message) != strlen(strip_tags($message)))
				{
				$headers = str_replace('Content-Type: text/plain', 'Content-Type: text/html', $headers);
				}
			}
This will do two things;
  • Any message you send from users --> send email to users that contains HTML will be formatted with the 'Content-Type: text/html' header.
  • The welcome email will be formatted as HTML
Reply With Quote
  #2  
Old 07-24-2012, 01:23 PM
JamesUK JamesUK is offline
 
Join Date: Jul 2004
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

any indication of what file this needs to be added to so we can allow html emails with the welcome msg and in turn add a logo image.

Thanks
Reply With Quote
  #3  
Old 10-24-2012, 02:41 AM
I.M.O.G. I.M.O.G. is offline
 
Join Date: Aug 2010
Posts: 24
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It isn't a file modification, its a plugin. So you need to go to plugin manager, add new plugin, and use the hook "mail_send". Hope that helps and is accurate.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:39 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08178 seconds
  • Memory Usage 2,182KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete