Results 1 to 2 of 2

Thread: How could I add SMTP Authentication into my email script

  1. #1
    Join Date
    Feb 2007
    Posts
    145
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default How could I add SMTP Authentication into my email script

    How could I add SMTP Authentication into my email script?

    Basically this email script gets sent using PHP Mail() but i am wanting it to get sent by using googlemail's smtp outgoing mail servers instead, i have read up on this and i know it is possible.

    Some examples are below:
    http://www.codewalkers.com/c/a/Email...-Email-Script/
    http://support.webecs.com/KB/a390/ph...ntication.aspx

    But i want to know how i could integrate it with the script i already have:
    Code:
    <?php
    
        $to="ryan.fitton@googlemail.com";
    
        $sub="Email From Website";
    
        // set the default timezone to use. Available since PHP 5.1
        date_default_timezone_set('Europe/London');
    
        $Date = date("d M Y");
    
        $Time = date("h:i A");
    
    $msg .="
    	<html>
    	<body>
    	<p style='color:#000000;font-family:Helvetica,Arial,sans-serif;'>
    	You have received an automated email.
    	<br/><br/>
    	This message was sent on the $Date at $Time
    	<br/><br/>
    	--------------------------------------
    	<br/>
    	Message text goes here....
    	</p>
    	</body>
    	</html>
    ";
    
    $headers[]  = 'MIME-Version: 1.0';
    $headers[] = 'Content-type: text/html; charset=iso-8859-1' ;
    $headers[] = 'From:ryan.fitton@googlemail.com';
    
    	// the implode is because each line has to be separated by an return space (part of the RFC)
        $mail=mail($to,$sub,$msg, implode("\r\n", $headers));
    
        if($mail)
    
        {
    
            echo "Mail successfully sent";
    
        }
    
        else
    
        {
    
            echo "Sorry could not sent";
    
        }
    
    ?>
    This email script that i already have is being automatically run every Friday by CRON.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I would recommend creating a function that uses google called gmail() and defining that as you found in the examples. Then just replace mail() with gmail().
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •