/    Sign up×
Community /Pin to ProfileBookmark

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:
[url]http://www.codewalkers.com/c/a/Email-Code/Smtp-Auth-Email-Script/[/url]
[url]http://support.webecs.com/KB/a390/php-mail-script-with-smtp-authentication.aspx[/url]

But i want to know how i could integrate it with the script i already have:

[code]<?php

$to=”[email protected]”;

$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:[email protected]’;

// the implode is because each line has to be separated by an return space (part of the RFC)
$mail=mail($to,$sub,$msg, implode(“rn”, $headers));

if($mail)

{

echo “Mail successfully sent”;

}

else

{

echo “Sorry could not sent”;

}

?>[/code]

This email script that i already have is being automatically run every Friday by CRON.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogAug 18.2010 — The way I do it is to use PHPMailer, and make use of its built-in SMTP class. Here is an example of using SMTP with it: http://phpmailer.worxware.com/index.php?pg=examplebsmtp
×

Success!

Help @ryanfitton spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...