NYCPHP Meetup

NYPHP.org

[nycphp-talk] Any ideas appreciated... short cuts are not always a good thing for script maintenance... need some advise...

Brent Baisley brenttech at gmail.com
Sat Oct 20 10:00:37 EDT 2007


You are reinventing the wheel by writing your own smtp code. I use  
swiftmailer (http://www.swiftmailer.org/) when I need a script that  
is going to send out emails on a regular basis. Another option is  
phpmailer (http://phpmailer.sourceforge.net/), but that's not really  
being updated anymore. Both are free and handle SMTP extremely well.

On Oct 19, 2007, at 10:47 PM, mikesz at qualityadvantages.com wrote:

> Greetings and Hello,
>
> I am converting a script to use SMTP if php mail() is not available
> for the users of this script. I have all the active calls working so
> that if my smtp flag is set it automatically switches to smtp and
> sends the message with the appropriate headers etc. but part of the  
> script is run by a
> cron job and I see a php mail call but don't quite understand the  
> syntax.
> Anyone care to take a guess at translating what it does?
>
> It is part of a while loop and I think its combining two conditions
> into one statement but would like confirmation.
>
> here is the code fragment:
>
> if ( !mail( $row['Email'], $row[Subj], $row[Body], "From: $site 
> [email_notify]", "-f$site[email_notify]") )
> ++$err;
>
>
> I thinks this is the equivalent of:
>
> if ( !mail( $row['Email'], $row[Subj], $row[Body], "From: $site 
> [email_notify]", "-f$site[email_notify]") )
> {
> ++$err;  //update the error queue
> }
> else
> {
> mail( $row['Email'], $row[Subj], $row[Body], "From: $site 
> [email_notify]", "-f$site[email_notify]");
> }
>
>
> Has anyone seen or used this technique before? This is the first time
> I have seen it used, though this script has a lot of short cuts that
> make the code difficult to debug sometimes, like this one.
>
> Thanks in advance for your comments,
> -- 
> Best regards,
>  mikesz                          mailto:mikesz at qualityadvantages.com
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php




More information about the talk mailing list