Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 01:37 pm EDT

Geeklog Forums

Custom Welcome Email


Status: offline

Flernk

Forum User
Chatty
Registered: 07/31/03
Posts: 46
I tried to create a custom email by adding welcome_email.txt to the plugin directory, but nothing happened. I looked through the other forum posts on this subject (even the ones that are now a few years old), but I can't figure out what I'm doing wrong.

Can someone spell out the process of creating a custom welcome email?
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
The file has to be in the data directory now. Yeah, I know, that isn't really documented anywhere ...

bye, Dirk
 Quote

Status: offline

Flernk

Forum User
Chatty
Registered: 07/31/03
Posts: 46
I'm trying to write a welcome email for a subscription-based webpage. I want to add links and possibly images to the email text itself, but the txt format won't allow that. Is there a way to create a, html welcome email?
 Quote

Status: offline

Flernk

Forum User
Chatty
Registered: 07/31/03
Posts: 46
I've tried several different ways to create a custom email with links and/or images (editing the custom email file, changing the language PHP, etc.).

Is what I'm attempting simply not possible using geeklog?
 Quote

Status: offline

Flernk

Forum User
Chatty
Registered: 07/31/03
Posts: 46
This is the code in the lib-common file that sends emails:

Text Formatted Code
/**
* Send an email.
*
* All emails sent by Geeklog are sent through this function now.
*
* @param    to         string   recipients name and email address
* @param    subject    string   subject of the email
* @param    message    string   the text of the email
* @param    from       string   (optional) sender of the the email
* @param    html       bool     true if to be sent as an HTML email
* @param    priority   int      add X-Priority header, if > 0
* @return   boolean             true if successful,  otherwise false
*
*/
function COM_mail( $to, $subject, $message, $from = '', $html = false, $priority = 0 )
{
    global $_CONF, $LANG_CHARSET;

    static $mailobj;

    if( function_exists( 'CUSTOM_mail' ))
    {
        return CUSTOM_mail( $to, $subject, $message, $from, $html, $priority );
    }

    include_once( 'Mail.php' );
    include_once( 'Mail/RFC822.php' );

    $method = $_CONF['mail_settings']['backend'];

    if( !isset( $mailobj ))
    {
        if(( $method == 'sendmail' ) || ( $method == 'smtp' ))
        {
            $mailobj =& Mail::factory( $method, $_CONF['mail_settings'] );
        }
        else
        {
            $method = 'mail';
            $mailobj =& Mail::factory( $method );
        }
    }

    if( empty( $LANG_CHARSET ))
    {
        $charset = $_CONF['default_charset'];
        if( empty( $charset ))
        {
            $charset = 'iso-8859-1';
        }
    }
    else
    {
        $charset = $LANG_CHARSET;
    }    

    if( empty( $from ))
    {
        $from = COM_formatEmailAddress( $_CONF['site_name'], $_CONF['site_mail']);
    }

    $headers = array();

    $headers['From'] = $from;
    if( $method != 'mail' )
    {
        $headers['To'] = $to;
    }
    $headers['Date'] = date( 'r' ); // RFC822 formatted date
    if( $method == 'smtp' )
    {
        list( $usec, $sec ) = explode( ' ', microtime());
        $m = substr( $usec, 2, 5 );
        $headers['Message-Id'] = '<' .  date( 'YmdHis' ) . '.' . $m
                               . '@' . $_CONF['mail_settings']['host'] . '>';
    }
    if( $html )
    {
        $headers['Content-Type'] = 'text/html; charset=' . $charset;
        $headers['Content-Transfer-Encoding'] = '8bit';
    }
    else
    {
        $headers['Content-Type'] = 'text/plain; charset=' . $charset;
    }
    $headers['Subject'] = $subject;
    if( $priority > 0 )    
    {
        $headers['X-Priority'] = $priority;
    }
    $headers['X-Mailer'] = 'GeekLog ' . VERSION;

    $retval = $mailobj->send( $to, $headers, $message );
    if( $retval !== true )
    {
        COM_errorLog( $retval->toString(), 1 );
    }

    return( $retval === true ? true : false );
}

 


How do I format welcome_email.txt so that geeklog registers it as an html message, rather than plain text? Is there a way to change this code itself to force geeklog to send it as an html message?

I'm sorry I'm posting so much on this topic, I'm under deadline and my poking around isn't yealding any answers.
 Quote

Status: offline

Flernk

Forum User
Chatty
Registered: 07/31/03
Posts: 46
Well, here's an answer....


After goofing off for a while, I got it working. For anyone else interested, here's the details. It's a definite hack, so watch out.

First, I changed this line in lib-common.php:

Text Formatted Code
    if( $html )
    {
        $headers['Content-Type'] = 'text/html; charset=' . $charset;
        $headers['Content-Transfer-Encoding'] = '8bit';
    }
    else
    {
        $headers['Content-Type'] = 'text/plain; charset=' . $charset;
    }
 


to this:

Text Formatted Code
    if( $html )
    {
        $headers['Content-Type'] = 'text/plain; charset=' . $charset;
    }
    else
    {
        $headers['Content-Type'] = 'text/html; charset=' . $charset;
        $headers['Content-Transfer-Encoding'] = '8bit';
    }
 


Switching the default email format to html instead of plain text. This will destroy "Email Story" which requires plain text for formatting. I haven't taken the time to find out how to fix this because the site I'm designing doesn't require that ability.

Next, in the mail.php section of english.php ($LANG31) I changed this

Text Formatted Code
10=> 'HTML'
 


to this:

Text Formatted Code
10=> 'Send as Plain Text (Default is HTML) – Normally, you should select this option.'
 


Just as a helpful reminder when users are writing their emails to eachother.

This is by no means a long-term solution, but it works just fine for now.
 Quote

All times are EDT. The time is now 01:37 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content