Re: Publishing in PECL php extension smtpmail

From: Date: Sat, 27 Oct 2012 11:01:45 +0000
Subject: Re: Publishing in PECL php extension smtpmail
Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-9930@lists.php.net to get a copy of this message
Hi, i think it were much better to work with a resource instead of writing all the connection data into globals. Currently the code like this will work not as expected $smtpmail = smtpmail_connect("smtp0",42,"test","test","utf-8","\n"); $smtpmail = smtpmail_connect("smtp1",25,"test","test","utf-8","\n"); because the second call would overwrite the data of the first one. Making smtpmail_connect() returning resource would require no changes to the userspace syntax and fix this. Also currently you don't free what you estrdup for the globals. Other small things - pecl coding style http://lxr.php.net/xref/PHP_5_4/CODING_STANDARDS . C++ comments, identiation. I'd additionally translate the comments in the code to English. Besides that generally looks ok to me from the technical side. Btw. why can't you use mail() in China? Always worked for me when installing some lightweight MTA on the host where php runs, like https://wiki.archlinux.org/index.php/NBSMTP (but there are actually many others), so it should work anywhere :) Regards Anatoliy On Sat, 27 Oct 2012 15:47:40 +0800 李明贵 <keminar@gmail.com> wrote: > I am a php developer in china. I have worked six years on it .I love php and love opensource. I want to share something with others. > smtpmail is a php extension, it use esmtp protocol to send email . I develop it because of usually php's function mail can't use in china.Use php to write a fsockopen client will cost more time and is hard to a newer > learn php. Last , as you know php extension will run faster. > A simple example > <?php > $smtpmail = smtpmail_connect("smtp.qq.com",25,"test","test","utf-8","\n"); > smtpmail_from($smtpmail,"from@qq.com","SMTPMAIL"); > $result = smtpmail_send($smtpmail,'title','content',"to@qq.com","keminar"); > if (!$result) { > echo smtpmail_error(); > } > smtpmail_quit($smtpmail); > I choose the PHP License 3.01 for my extension > You can get all code from mail attachment or my blog > http://blog.linuxphp.org/smtpmail/ -- anatoliy@belsky.info <anatoliy@belsky.info>

« previous php.pecl.dev (#9930) next »