How to use!

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
steakpie
Forum Newbie
Posts: 7
Joined: Sat Apr 19, 2008 8:39 pm

How to use!

Post by steakpie »

Hey folks :D

I have read through and search the forum, but am unable to find a usage demo for swift mailer.

I understand nothing of OOP and have no idea where to start with classes, but really want to give SwiftMailer a bash for my next project!

Can anyone give or point to a good an explaination of how i could inplement SwiftMailer into my program?

At present, I am doing this ...

Code: Select all

 
if( @$_POST['submitregister'] ){
    
    # VALIDATE AND CLEANSE HERE..
    
    if( $err['errmsg']== '' ){
        # no errors as yet, proceed ...
        # see if email/username is in DB ...
        $sql = "SELECT ...";
        $res = mysql_query($sql) or die();
        $row = @mysql_fetch_array($res);
        if( $row['email'] != '' ){
            $err['errmsg'].="@This email address is already in use, and can not be registered again.";
            $err['email'] = 1;
        }
    }
    # Do some more validation ...
    if( $err['errmsg'] == '' ){
 
        $sql = "INSERT  ...";
        mysql_query($sql) or $err['errmsg'] = "@Unable to complete your request. Please try again later.";
        
        if( $err['errmsg'] == "" ){
            $msg['success'] = "@Your temporary password has now been emailed to to you.";
            $msg['success'].= "@Your temporary is".$password;
            $body = "Dear ".$clean_data['fname'].",<br>";
            $body.= "Thank you for your registration at <a href=".getsettingssingle(3)." target=_blank>".getsettingssingle(2)."</a>";
            $body.= "<br><br>Your Login password is ";
            $body.= "<br><b>".$password."</b><br><br>Thanks,<br>Webmaster";
            $subj = $clean_data['fname'].", Your temporary password for ".getsettingssingle(2);
            $head = "From: ".getsettingssingle(1)." \nContent-Type: text/html";
            @mail(safe_4_email($clean_data['email']),$subj,$body,$head) or die();
            $msg['success'].= "@Your registration is now done. An email containing your temporary password has been emailed to you.";
        }
    }
 }
 
How would i make the switch over using SwiftMailer instaed of that nasty

Code: Select all

mail()
funtion!!

I sincerly hope one of you guys can help me out :)

Des
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: How to use!

Post by Chris Corbyn »

Have you read the documentation? There are some basic tutorials and from the amount of code you posted it shouldn't be too hard to change; provided you wrote the code you posted and not copied & pasted it ;)
steakpie
Forum Newbie
Posts: 7
Joined: Sat Apr 19, 2008 8:39 pm

Re: How to use!

Post by steakpie »

Hi Chris,

Yea, I gave the docs a scan, but rying to find laymans way of making the change over will take some sleep or stronger coffee!!

The code was a quick copy and paste of one of the pages I am creating that use's the mail func'

I have been putting off learning OOPs as I feel its will jst slow down my progression in learning PHP, but its looking like that I will need to put some projects on hold and get learning just to make use of all the fanstatic class libs that are out their!
Post Reply