I 'm so sad that nobody hasn't answered me :-(
Since I posted this question, I have browsered many forums, understand the Zend principles within and GET THE SOLUTION !! I write it here for poor men who struggle like me for hours ...
1. The code written is good, EXCEPT the call of classes.
2. Zend_Mail is a part of the libraries of Zend, so Zend_Mail is a library AND MUST BE CALLED AS A LIBRARY , and not as a file !
For project made with framework (Symfony for example), the libraries are placed UPON the website root folder, so you can't reach them as a normal file.
My project wasn't made with frameword, so I placed my folder libraries INSIDE the root folder, BUT I MUST REACH THE CLASSES THE SAME WAY !
The website is constructed like that :
Root folder :
- some folders and somes files in it
- "for_email" folder :
- form.php
- send_email.php
- "library" folder :
- "Zend" folder :
- Exception.php
- Loader.php
- Mail.php
- Registry.php
- Validate.php
- Mime.php
- Loader folder
- Mail folder
- Mime folder
- Validate folder
Nota : this folders came from Zend framework and haven't been modified.
So the code below is wrong :
// --------------------------------------------------
require_once('../lib/Zend/Loader.php');
require_once('../lib/Zend/Mail.php');
// --------------------------------------------------
and THIS is right :
//--------------------------------------------------
//-- reach the Zend Classes put in "library" folder :
$paths = array(
realpath(dirname(__FILE__) . '/../library'),
'.',
);
set_include_path(implode(PATH_SEPARATOR, $paths));
//-- for this script (only), you reach directly the Zend folder
require_once('Zend/Mail.php');
require_once('Zend/Mail/Transport/Smtp.php');
//--------------------------------------------------
This code is written in "send_email.php" file. The rest of the code (begin at line 4 in my first script : "$config=array(... and so on...) is unchanged.
3. the last BUT NOT THE LEAST : the php.ini
You put the code in the right place and - Boom- "connection refused to smtp server" !!
It's possible you are hosted on shared hosting, so you can't modify the php.ini and , unfortunately, you have this directive :
allow_url_fopen = Off
That means you can't rely somme external url, like .... a smtp server !!!
Some say "allow_url_fopen=On" is a lack of security, some say no : you just need "register_globals=Off", it's sufficient. I don't wan't to discuss of security lacks, because I'm not a master in it ! The facts are :
- some shared hosters (eg :Ovh) have "allow_url_fopen=On" and you can send emails via SMTP , using PHPMailer or Zend_Mail (I tested these ones).
- some shared hosters (eg: 1and1) have "allow_url_fopen=Off" and You CAN'T SEND EMAIL VIA SMTP, using PHPMailer or Zend_Mail !! Try to contact the support : they say you just have to run with the PHP function : Mail. But for me, the Mail PHP function don't work as good as SMTP (emails are sent slower and many are judged as spam by pop client ...
so use Zend_Mail with allow_url_fopen !
I'm glad to have found the solution (I have thought this site 's experts were be faster than me, the next time I guess...). I'll be happier if this solution would help someone else.
Regards
Flho