BigCommerce - Hosted Ecommerce Software by Interspire

Interspire Forum

 
Go Back   Interspire Forum > Interspire Email Marketer Community Forum > Customization and Integration

Reply
 
Thread Tools Display Modes
  #1  
Old 03-05-2008, 07:09 PM
SDSL SDSL is offline
Junior Member
 
Join Date: Mar 2008
Posts: 6
Default Send Email including Embedded images

i've built cron script to send the sendstudio users an Email once a day using already set up template
but i can't get the embedded images to work

before i tell my problem i want to tell that "send perview" button from within template/autoresponder/campaign sections does not send the actual preview, while it's not embedding images.. the images gets embedded when i build campaign only


PHP Code:
require(dirname(__FILE__) . '/functions/init.php');

require(
dirname(__FILE__) . '/functions/sendstudio_functions.php');
$sendstudio_functions=&new Sendstudio_Functions();
$sendstudio_functions->LoadLanguageFile('frontend');
$templates=$sendstudio_functions->GetApi('Templates');
$email_api=$sendstudio_functions->GetApi('Email');

//~ loading the template using givin templateid
$templates->Load($argv[1]);
$html=$templates->htmlbody;
$html str_replace("%%unsubscribelink%%""anythinghere"$html);

$from "support@website.tld";
$subject "Welcome to website";

$email_api->Set('CharSet'SENDSTUDIO_CHARSET);
$email_api->Set('Subject'$subject);
$email_api->Set('FromAddress'$from);
$email_api->Set('FromName''MyName');
$email_api->Set('ReplyTo'$from);
$email_api->Set('BounceAddress'$from);
$email_api->SetSmtp(SENDSTUDIO_SMTP_SERVERSENDSTUDIO_SMTP_USERNAME,@base64_decode(SENDSTUDIO_SMTP_PASSWORD),
    
SENDSTUDIO_SMTP_PORT);

$format='h';
$email_api->Set('imagedir'TEMP_DIRECTORY."/send");
    
$email_api->Set('EmbedImages'true);
    
$email_api->AddBody('html'$html);
    
$images $email_api->GetImages();
    
$problem_images = array();
    if (
is_array($images) && !empty($images)) {
        foreach (
$images as $md5 => $image_url) {
            
$email_api->GetImage($image_url);
        }
    }
    
$email_api->AppendBody('html'$user->Get('htmlfooter'));
    
$email_api->AppendBody('html'stripslashes(SENDSTUDIO_HTMLFOOTER));
$email_api->AddRecipient($user->emailaddress''$format);
$email_api->Send();
// debug
print_r($email_api);
print_r($images);

$email_api->ForgetEmail(); 
debug text attached
Attached Files
File Type: txt email.txt (10.6 KB, 90 views)
Reply With Quote
  #2  
Old 03-05-2008, 10:21 PM
Chris S Chris S is offline
Senior Member
 
Join Date: Feb 2004
Posts: 4,642
Default

Hi,

Try the email.php from the new version (1.4.0) - you can get it from the clientarea.

If you don't want to upgrade everything, you should just be able to drop the admin/functions/api/email.php file in - though after doing that please make sure you test everything to make sure just doing that doesn't break something with sending or autoresponders.

Quote:
Originally Posted by SDSL
i've built cron script to send the sendstudio users an Email once a day using already set up template
but i can't get the embedded images to work

before i tell my problem i want to tell that "send perview" button from within template/autoresponder/campaign sections does not send the actual preview, while it's not embedding images.. the images gets embedded when i build campaign only


PHP Code:
require(dirname(__FILE__) . '/functions/init.php');

require(
dirname(__FILE__) . '/functions/sendstudio_functions.php');
$sendstudio_functions=&new Sendstudio_Functions();
$sendstudio_functions->LoadLanguageFile('frontend');
$templates=$sendstudio_functions->GetApi('Templates');
$email_api=$sendstudio_functions->GetApi('Email');

//~ loading the template using givin templateid
$templates->Load($argv[1]);
$html=$templates->htmlbody;
$html str_replace("%%unsubscribelink%%""anythinghere"$html);

$from "support@website.tld";
$subject "Welcome to website";

$email_api->Set('CharSet'SENDSTUDIO_CHARSET);
$email_api->Set('Subject'$subject);
$email_api->Set('FromAddress'$from);
$email_api->Set('FromName''MyName');
$email_api->Set('ReplyTo'$from);
$email_api->Set('BounceAddress'$from);
$email_api->SetSmtp(SENDSTUDIO_SMTP_SERVERSENDSTUDIO_SMTP_USERNAME,@base64_decode(SENDSTUDIO_SMTP_PASSWORD),
    
SENDSTUDIO_SMTP_PORT);

$format='h';
$email_api->Set('imagedir'TEMP_DIRECTORY."/send");
    
$email_api->Set('EmbedImages'true);
    
$email_api->AddBody('html'$html);
    
$images $email_api->GetImages();
    
$problem_images = array();
    if (
is_array($images) && !empty($images)) {
        foreach (
$images as $md5 => $image_url) {
            
$email_api->GetImage($image_url);
        }
    }
    
$email_api->AppendBody('html'$user->Get('htmlfooter'));
    
$email_api->AppendBody('html'stripslashes(SENDSTUDIO_HTMLFOOTER));
$email_api->AddRecipient($user->emailaddress''$format);
$email_api->Send();
// debug
print_r($email_api);
print_r($images);

$email_api->ForgetEmail(); 
debug text attached
Reply With Quote
  #3  
Old 03-05-2008, 10:49 PM
SDSL SDSL is offline
Junior Member
 
Join Date: Mar 2008
Posts: 6
Default

Chris,
I'll try and let you know
but for now ... my coding is OK ?
Reply With Quote
  #4  
Old 03-06-2008, 12:21 AM
Chris S Chris S is offline
Senior Member
 
Join Date: Feb 2004
Posts: 4,642
Default

Hi,

No that looks fine, except you don't need this:

PHP Code:
    $problem_images = array();
    if (
is_array($images) && !empty($images)) {
        foreach (
$images as $md5 => $image_url) {
            
$email_api->GetImage($image_url);
        }
    } 
Maybe that's an incomplete copy/paste but it doesn't do anything..

Quote:
Originally Posted by SDSL
Chris,
I'll try and let you know
but for now ... my coding is OK ?
Reply With Quote
  #5  
Old 03-06-2008, 12:34 AM
SDSL SDSL is offline
Junior Member
 
Join Date: Mar 2008
Posts: 6
Default

the code is a bit complete, but yes while I'm using this script through command line no need for these lines..

anyway i tried to replace the 1.3.1 email.php with the new one. but i still can't get "send preview" email with images embedded

also my script not yet embedding images!
something worng

if you get "send preview" function to embed images .. my problem will then gets solved
Reply With Quote
  #6  
Old 03-06-2008, 12:39 AM
SDSL SDSL is offline
Junior Member
 
Join Date: Mar 2008
Posts: 6
Default

Chris,
I'm following functions/sendstudio_fuctions.php:SendTestPreview() in order to accomplish my script but hence SendTestPreview() does not embed images..

i think it's bug, so someone can't see actually how email will appear unless he build campaign and put his email into mailing-list which receive this campaign message, then he can see actually how email looks like..while images then embedded.
Reply With Quote
  #7  
Old 03-06-2008, 02:20 AM
Chris S Chris S is offline
Senior Member
 
Join Date: Feb 2004
Posts: 4,642
Default

Hi,

It's not a bug - it's done on purpose - because embedded images can be either be disabled completely or disabled for a particular send. I took the safe (and less confusing) route of not showing an option about whether to embed images or not when you send a preview.

Quote:
Originally Posted by SDSL
Chris,
I'm following functions/sendstudio_fuctions.php:SendTestPreview() in order to accomplish my script but hence SendTestPreview() does not embed images..

i think it's bug, so someone can't see actually how email will appear unless he build campaign and put his email into mailing-list which receive this campaign message, then he can see actually how email looks like..while images then embedded.
Reply With Quote
  #8  
Old 03-06-2008, 02:26 AM
SDSL SDSL is offline
Junior Member
 
Join Date: Mar 2008
Posts: 6
Default

Chris,
so what would that option which will let testPreview embed images ?
is it
PHP Code:
$email_api->Set('EmbedImages'true); 
or i need some additional coding
Reply With Quote
  #9  
Old 03-06-2008, 02:46 AM
SDSL SDSL is offline
Junior Member
 
Join Date: Mar 2008
Posts: 6
Default

it's okay... i fixed it

what makes it not working is $email_api->GetImages();
Reply With Quote
  #10  
Old 03-07-2008, 01:44 AM
Chris S Chris S is offline
Senior Member
 
Join Date: Feb 2004
Posts: 4,642
Default

Hi,

Ahh - because internally it's doing this (in the email.php file, not the ss_email.php file):

PHP Code:
$this->_EmbeddedImages $this->GetImages(); 
Which sets everything up for later when it actually reads the images in etc..



Quote:
Originally Posted by SDSL
it's okay... i fixed it

what makes it not working is $email_api->GetImages();
Reply With Quote
Reply

Thread Tools
Display Modes

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 On

Forum Jump