Author Topic: Newbie example needed  (Read 3924 times)

0 Members and 1 Guest are viewing this topic.

NickM

  • Guest
Newbie example needed
on: Tue, 23. December 2003 - 06:14:11
It's time to start sending HTML newsletters to a small list of subscribers but I have no idea how to use vlibMimeMail to do this.
Is there an example somewhere, where name and email addresses are drawn from a MySQL dbase (do I use vLibtemplate ?) and an HTML email is sent to all those in the dbase.
I just need a little kick-start. The examples provided just need to go that one step further (for me) to be extremely useful.
Hope you can help.

releasedj

  • Guest
Newbie example needed
Reply #1 on: Thu, 25. December 2003 - 18:34:34
Here is a link to an example of how to send an HTML email using vlibMimeMail to send and vlibTemplate for customization.

To amend this to your needs you will need to grab records from your database, and then loop through each record to send to each person.
Remember that once youve sent to a person, you should use vlibTemplate::clearVars() and vlibMimeMail::clearAll() so that each object is ready to use upon the next iteration.

I hope this is clear.

Kelvin
Last Edit: Wed, 16. February 2005 - 01:11:55 by ClausVB

NickM

  • Guest
Newbie example needed
Reply #2 on: Fri, 26. December 2003 - 13:08:52
Hi Kelvin,
I managed to make the example work for me. Many thanks  :)
The email gets sent correctly but I get these notices - it's more nuisance value than anything else. Any way to get rid of them?

Notice: Constant FATAL already defined in /home/fruittreevLIB/vlibMimeMail/error.php on line 13

Notice: Constant WARNING already defined in /home/fruittreevLIB/vlibMimeMail/error.php on line 14

Notice: Constant NOTICE already defined in /home/fruittreevLIB/vlibMimeMail/error.php on line 15

NickM

  • Guest
Newbie example needed
Reply #3 on: Sat, 27. December 2003 - 11:27:28
Kelvin,
Sorry to pester you, but I'm not sure how to loop through to send multiple emails.
I can send one email that contains dbase info, but I have no idea how to loop through the dbase and place email addresses into vlibmimemail.
Below is the code that works to send one email, what do I need to do to send multiple emails?

<?php
/*
This file will demonstrate how to send an email which is created with a template using vlibTemplate
and sent using vlibMimeMail.
*/


    include_once './vLIB/vlibTemplate.php';
    include_once './vLIB/vlibMimeMail.php';

    // first we build the template ...
    $tmpl = new vlibTemplate('../templates/original_temp.htm');
    $tmpl->setVar('fullname', 'Nick');
    $tmpl->setVar('newname', 'mr some guy');
      
//add dbase stuff here      


require_once("db_fns.php");

$conn = db_connect(); //function to connect
$sql = "select * from Pol_EmailList";
$result=mysql_query($sql, $conn);
$tmpl->setDbLoop('myLoop', $result);

//$tmpl->pparse();
// use grab(), which parses and returns the output, instead of pparse()
$htmlbody = $tmpl->grab();
      

    // now we build the email
    $mail = new vlibMimeMail();
    $mail->to('[email protected]', 'Recpt');
    $mail->from('[email protected]', 'Website');
    $mail->priority(1);
    $mail->subject('New database entry!');

    // set the html body and then send the email
    $mail->htmlbody($htmlbody);
     ($mail->send());
      
?>

NickM

  • Guest
Newbie example needed
Reply #4 on: Mon, 05. January 2004 - 08:59:24
Hello again Kelvin,
Hope you had a nice break over Xmas (sunning yourself on a Greek Isle, I bet).
Have you had a chance to think about how to loop through a dbase?
I've tried a number of options but can't get the email addresses from the dbase into vlibMimeMail.
I'm a little confused about it all and still hanging out for one of your "enlightend" responses.

Regards,
Nick

releasedj

  • Guest
Newbie example needed
Reply #5 on: Tue, 06. January 2004 - 01:28:03
Take a look at this below:

Code: [Select]
?php
include_once ./vLIB/vlibTemplate.php;
include_once ./vLIB/vlibMimeMail.php;

tmpl = new vlibTemplate../templates/original_temp.htm;
mail = new vlibMimeMail;

//dbase stuff here
require_oncedb_fns.php;

conn = db_connect; //function to connect
sql = SELECT email,first_name,last_name FROM Pol_EmailList;
result=mysql_querysql, conn;

while row = mysql_fetch_assocresult
{
 � �// set variable in template for this person and grab body
 � �tmpl-setVarfirst_name, rowfirst_name;
 � �tmpl-setVarlast_name, rowlast_name;
 � �htmlbody = tmpl-grab;

 � �// send mail
 � �mail-torowemail, rowfirst_name. .rowlast_name;
 � �[email protected], Website;
 � �mail-priority1;
 � �mail-subjectNew database entry;
 � �mail-htmlbodyhtmlbody;
 � �mail-send;

 � �// clean up template and email objects
 � �tmpl-clearVars;
 � �mail-clearAll;
}
?
Last Edit: Fri, 18. February 2005 - 10:10:10 by ClausVB

NickM

  • Guest
Newbie example needed
Reply #6 on: Tue, 06. January 2004 - 13:41:13
Kelvin,
Many many thanks. It works!
It's so simple. I feel like a dill :oops:
However, I still get this:
Notice: Constant FATAL already defined in /home/fruittreevLIB/vlibMimeMail/error.php on line 13

Notice: Constant WARNING already defined in /home/fruittreevLIB/vlibMimeMail/error.php on line 14

Notice: Constant NOTICE already defined in /home/fruittreevLIB/vlibMimeMail/error.php on line 15

Any idea how to get rid of it?

Offline ClausVB

  • Administrator
  • Hero Member
  • *****
  • Posts: 566
    • Homepage: clausvb.de
Newbie example needed
Reply #7 on: Tue, 06. January 2004 - 14:43:05
This is a NOTICE.

You can deactivate it in your "php.ini"

Search on "google.de" or "yahoo.com" for

php.ini +error

or

php.ini +E_ALL

And remember this is not a PHP-coding forum and error reporting within PHP is not a vLIB issue.

Imho you ask too soon in this forum and ask Kelvin to code for you instead of just getting hints.
(It's not the first time I notice it. You did it in the past, too.)

Just my 2 cents.

Regards,
Claus

releasedj

  • Guest
Newbie example needed
Reply #8 on: Tue, 06. January 2004 - 15:16:33
As for the Notices being thrown.

I'll make a change to vLIB so that this isn't the case.

As for removing them, do:

error_reporting(E_ALL ~ E_NOTICE);

That should hopefully work.

NickM

  • Guest
Newbie example needed
Reply #9 on: Wed, 07. January 2004 - 01:20:36
Claus said:
"Imho you ask too soon in this forum and ask Kelvin to code for you instead of just getting hints.
(It's not the first time I notice it. You did it in the past, too.)
Just my 2 cents."

I admit my php skills are woefull - I spend many hours trying to code things myself and many more hours trying to find ready-made code that I can adapt to suit what I want. It's not as if I make no effort before asking for help!

Once I see how things are coded and how they work I can adapt the code to do more complex things - on my own. I simply want to see an example of how the class operates.

I would even bet that there are others (beginners, like me) on this list who will now be able to use Kelvin's code to expand their use of vLibMimemail and vLib. (If you are out there, let me know :wink:

Claus, vLib is fantastic, it has helped me create dbase-driven sites quickly and easily. Now vLibMimeMail offers another opportunity for me to expand my skills. This forum is a godsend and Kelvin is a wonder. If you and Kelvin did not help with the coding I would have left long ago because I would not have been able to use the classes.

One final point - my questions may require solutions in terms of coding in php; but where else can I go to ask those questions? After all, the questions relate directly to using vLib, not to using php.

Regards,
Nick

Offline ClausVB

  • Administrator
  • Hero Member
  • *****
  • Posts: 566
    • Homepage: clausvb.de
Newbie example needed
Reply #10 on: Wed, 07. January 2004 - 10:18:14
This is not entirely correct. Imho you did not even try it.

In this post I cannot see any attempt by you at all.

That you would have to use a WHILE is obviously, but you did not post any attempt ... you just said: "I need an example."

I have similar users who say:
"I need that and could not figure out, how to do it, please make an example."
In fact this means: "Program it for me! Solve my problem!" disguised as an example for the whole community.

I have to admit, the english documentation does not have as much examples as my german documentation, but it's the lack of your effort to even try it, I put on trial here.

Please read this
http://www.catb.org/~esr/faqs/smart-questions.html#intro

Doing you homework, beeing a part of the solution is your job, not ours.

I think, it would have been easier for Kelvin to look through code you tried to program instead of doing it on his own. Perhaps this depands how complex you program your code.

I am less tolerant than Kelvin, but I do this job for nearly 2 years now. Many persons who are mods and always are polite, answer one n00b question after the other, burn out and quit, helping nobody anymore.

Quote
What we are, unapologetically, is hostile to people who seem to be unwilling to think or to do their own homework before asking questions. People like that are time sinks they take without giving back, they waste time we could have spent on another question more interesting and another person more worthy of an answer. We call people like this \"losers\" (and for historical reasons we sometimes spell it \"lusers\").


I call "lusers" to order. If they do not follow my rules, do not make their homework before they post, I will react hostile towards them. Perhaps some users turn away and do not look at vLIB again, but this way I have more time for real vLIB questions.

Look at the german forum. It's one of the most used in here. The ppl know I will help them, if they put effort in their posting.

My work for vLIB does not pay me a single dollar. I think I have the right to be paid by "smart questions". I am entitled to be treated with respect and that my support forum ist not spammed with:
"WILL I GET ANY HELP HERE?????????????"

You can honor Kelvin and my work, when you try to get a better PHP coder. Improve your skills and next time you try first, do your homework and post afterwards.

Since I want the vLIB class to live long and prosper and I want not to become a burn-out, I have to say such things to ppl like you.

Again my humble opinion and 2 cents.
Claus

NickM

  • Guest
Newbie example needed
Reply #11 on: Wed, 07. January 2004 - 12:29:08
Claus,
From the link you provided:

"On Not Reacting Like A Loser
Odds are you'll screw up a few times on hacker community forums in ways detailed in this article, or similar. And you'll be told exactly how you screwed up, possibly with colourful asides. In public.

When this happens, the worst thing you can do is whine about the experience, claim to have been verbally assaulted, demand apologies, scream, hold your breath, threaten lawsuits, complain to people's employers, leave the toilet seat up, etc. Instead, here's what you do:

Get over it. It's normal. In fact, it's healthy and appropriate."

Claus, I'm over it.

Regards,
Nick

Offline ClausVB

  • Administrator
  • Hero Member
  • *****
  • Posts: 566
    • Homepage: clausvb.de
Newbie example needed
Reply #12 on: Wed, 07. January 2004 - 15:21:04
Quote
Claus, I'm over it.
That's good.

It would have been even more good if you would have said:

"Claus, I'm over it and try to do it better next time."

:-)

Regards,
Claus

NickM

  • Guest
Newbie example needed
Reply #13 on: Wed, 07. January 2004 - 23:26:17
"Claus, I'm over it and try to do it better next time."

Regards,
Nick

releasedj

  • Guest
Newbie example needed
Reply #14 on: Thu, 12. February 2004 - 10:38:30
RE: The notices being thrown about contants being redefined.

This should be fixed in the latest release.

NickM

  • Guest
Newbie example needed
Reply #15 on: Thu, 12. February 2004 - 11:24:01
Thanks Kelvin.
Nice to know it's not always the operator's fault.