[development] development Digest, Vol 86, Issue 17

Dayton Perkins perkinsd at chartermi.net
Sat Feb 13 17:11:20 UTC 2010


Wow that was an easy fix! Thanks so much, Jamie!
development-request at drupal.org wrote:
> Send development mailing list submissions to
> 	development at drupal.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://lists.drupal.org/mailman/listinfo/development
> or, via email, send a message with subject or body 'help' to
> 	development-request at drupal.org
>
> You can reach the person managing the list at
> 	development-owner at drupal.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of development digest..."
>
>
> Today's Topics:
>
>    1. Re: Mail script problem: please help (Jamie Holly)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sat, 13 Feb 2010 11:51:10 -0500
> From: Jamie Holly <hovercrafter at earthlink.net>
> Subject: Re: [development] Mail script problem: please help
> To: development at drupal.org
> Message-ID: <4B76D87E.7010509 at earthlink.net>
> Content-Type: text/plain; charset="iso-8859-1"
>
> You're overwriting the $user variable since this script is running in 
> the global namespace:
>
>
> $user= $_GET['u'];
>
> $user is populated with the user object on bootstrap and now you're 
> changing it. That's your problem. To prevent conflicts I would wrap 
> everything below:
>
>          drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
>
> into a function and just call that.
>
> Jamie Holly
> http://www.intoxination.net
> http://www.hollyit.net
>
>
> On 2/13/2010 10:52 AM, Dayton Perkins wrote:
>   
>> I am using Mime Mail to send mails to users who are opted in to a 
>> users mailing list for a certain user role. I had written a similar 
>> script for another site, looping through email addresses and invoking 
>> mimemail() for each. Unfortunately though I pumped up the memory 
>> limit, that script white screened ( haven't checked in too much detail 
>> as the "client" is a non-payer), though the script did send out the mails.
>>
>> So for this project, I decided to class it up a bit using jQuery to 
>> loop through sending $get requests to the server and load in a 
>> "loading" graphic whilst waiting for a response for each mail in turn. 
>> I put my mailing script in the docroot since putting it in my module 
>> resulted in path errors. Everything works, including sending the 
>> emails, loading in the loading graphic per email and then a sent 
>> message, writing to the database, etc.  EXCEPT for 2 things.
>> When I open the script in a browser, I get the following notices:
>>
>> *Notice*: Trying to get property of non-object in 
>> */home/content/t/o/n/tonebari/html/modules/dblog/dblog.module* on line 
>> *135*
>> *Notice*: Trying to get property of non-object in 
>> */home/content/t/o/n/tonebari/html/includes/database.mysqli.inc* on 
>> line *102*
>> *Notice*: Trying to get property of non-object in 
>> */home/content/t/o/n/tonebari/html/modules/dblog/dblog.module* on line 
>> *135*
>> *Notice*: Trying to get property of non-object in 
>> */home/content/t/o/n/tonebari/html/includes/database.mysqli.inc* on 
>> line *102*
>> *Notice*: Trying to get property of non-object in 
>> */home/content/t/o/n/tonebari/html/modules/dblog/dblog.module* on line 
>> *135*
>> *Notice*: Trying to get property of non-object in 
>> */home/content/t/o/n/tonebari/html/includes/database.mysqli.inc* on 
>> line *102*
>> *Notice*: Trying to get property of non-object in 
>> */home/content/t/o/n/tonebari/html/modules/dblog/dblog.module* on line 
>> *135*
>> *Notice*: Trying to get property of non-object in 
>> */home/content/t/o/n/tonebari/html/includes/database.mysqli.inc* on 
>> line *102
>>
>>
>> Additionally, *when I run the AJAX page, it sends the emails, writes 
>> the data and everything looks dandy, but when I navigate to another 
>> page I find I have been logged out! :-) I do see the first notice 
>> above is inside dblog_watchdog() Seems to me that the browser isn't 
>> sending cookies? I added global $user; print_r($user); right after the 
>> call to drupal_bootstrap, (after re-logging ;-) )and I see that I my 
>> user data is present.
>> help? *
>>
>> *here's the mailer script
>> <?php
>> error_reporting(E_ALL);
>> require_once './includes/bootstrap.inc';
>> drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
>> $sender = 'no-reply at example.com';
>> $last = $_GET['l'];
>> $cid = $_GET['c'];
>> $user= $_GET['u'];
>> if($user==0){ // not a user || no uid ;These emails are added to the 
>> database another way...
>>     $recipient = $_GET['e'];
>>     $mail = $recipient;
>> } else {
>>      $recipient = get_user($user); // This gets the user object I also 
>> tried just using global $user and $user->mail
>>      $mail = $recipient->mail;
>> }
>> if(!isset($_SESSION['mailer-errors'])) { $_SESSION['mailer-errors']=0; }
>> $subject = $_SESSION['subject'];
>> $code=randStrng();
>> $optLink = '<p>'.l('Opt out of these emails', 
>> 'http://example.com/center/opt', array('query' => 
>> 'cid='.$cid.'&code='.$code.'&mail='.$mail)).'</p>';
>> $body = $_SESSION['body'].$optLink;
>> if($sent = mimemail($sender, $recipient, $subject, $body)) {
>>     write_promo_data($user, $recipient, $cid,  $code);
>>     echo 1;
>> } else {
>>     echo 0;
>>     $_SESSION['mailer-errors'] ++;
>> }
>> if($last ==1) {
>>     if($_SESSION['mailer-errors']==0) {
>>         unset($_SESSION['send']);
>>         unset($_SESSION['subject']);
>>         unset($_SESSION['body']);
>>         unset($_SESSION['created']);
>>     }
>>     unset($_SESSION['mailer-errors']);
>> }
>> -- 
>> /Kindest regards,/ *Dayton Perkins*
>> Good News Design
>> Intelligent Web Programming for Business
>> 3611 Butternut Drive, Suite 40
>> Holland MI 49424
>> 616-399-5617
>> http://goodnewsdesign.com
>> Signature <http://goodnewsdesign.com>
>>     
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://lists.drupal.org/pipermail/development/attachments/20100213/4bf3fb7d/attachment.html 
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: not available
> Type: image/gif
> Size: 20888 bytes
> Desc: not available
> Url : http://lists.drupal.org/pipermail/development/attachments/20100213/4bf3fb7d/attachment.gif 
>
> ------------------------------
>
>   


-- 
/Kindest regards,/ *Dayton Perkins*
Good News Design
Intelligent Web Programming for Business
3611 Butternut Drive, Suite 40
Holland MI 49424
616-399-5617
http://goodnewsdesign.com
Signature <http://goodnewsdesign.com>


More information about the development mailing list