inserting data and images in an email message variable

17 posts by 3 authors in: Forums > CMS Builder
Last Post: November 15, 2012   (RSS)

By gkornbluth - November 14, 2012

Good morning Greg,

This morning I changed the To: for all of the emails to my email address so that I would receive all the emails.

Even with all of the changes, the problem still exists.

I'm a bit confused as to why sending 3 or 4 emails works perfectly, but when i send to the entire list (75) they come out trashed (even with a .2 second sleep).

That said, I found a note about the length of a line needing to be less than 70 characters when using the mail function, and I'm going to try playing with wordwrap some more.

If you have any other ideas, please let me know.

Thanks

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] inserting data and images in an email message variable

By gregThomas - November 14, 2012

Hi Jerry,

You could try using CMS Builders mail function to see if that makes a difference. Below is an example of a basic implementation:

$message = 'This is a test message';
$mailArray = array(
'to' => 'example@example.com',
'from' => 'example@example.com',
'subject' => 'This is a subject',
'html' => $message
);
$errors = sendMessage($mailArray);


Also if you use this function in CMS Builder 2.17 it will log your messages for you if you have the feature enabled.

Thanks
Greg Thomas







PHP Programmer - interactivetools.com

By gkornbluth - November 15, 2012 - edited: November 15, 2012

Hi Greg,

Thanks for the tip about the mail function (didn’t remember that there was one). That seems to have fixed the formatting and exclamation point issues I had.

Two Small issues left...

1) When looping through record list, the email for the last record in the record list always comes up blank. I don’t have any idea how to fix that (except for inserting a dummy record, which is not really a fix, just a quick workaround).

2) I can’t get a variable to display inside the subject line using the $mailArray.

The $where variable is defined much earlier in the page as the name of the exhibition. It renders "Your submission to the $where Exhibition has been Juried" in the email subject line.

Here’s the code I’m using to send the emails.
$the_from = "exhibition-submissions@artistsofpalmbeachcounty.org";
$the_subject = "Your submission to the $where Exhibition has been Juried";
$the_to = $record['email'];
$mailArray = array(
'to' => '$the_to',
'from' => '$the_from',
'subject' => "$the_subject",
'html' => $message
);
$errors = sendMessage($mailArray);


You’re the best,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] inserting data and images in an email message variable

By gregThomas - November 15, 2012

Hi Jerry,

I'm not sure what's causing the first point, could you post the latest version of your code?

I think the where variable not being converted because you are putting quotation marks around the variable in the $mailArray function, which makes PHP convert the entire variable to a string and not process any variables in it. Try this instead:

$the_from = "exhibition-submissions@artistsofpalmbeachcounty.org";
$the_subject = "Your submission to the $where Exhibition has been Juried";
$the_to = $record['email'];
$mailArray = array(
'to' => $the_to,
'from' => $the_from,
'subject' => $the_subject,
'html' => $message
);
$errors = sendMessage($mailArray);


Thanks
Greg Thomas







PHP Programmer - interactivetools.com

By gkornbluth - November 15, 2012

Hi Greg,

removing the quotation marks was a good idea, but didn't work. Neither did using either single or double quotes around:
$the_subject = "Your submission to the $where Exhibition has been Juried";

The entire file is attached.

I hope I don't feel too silly after these issues are solved.

Thanks again,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By gkornbluth - November 15, 2012

Thanks Greg,

A second and more experienced pair of eyes always helps in the end.

I took out the second mailArray (left over by mistake) and that seems to have solved both issues.

I knew I'd be embarrassed in the end...

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php