Register to shout

I already post more than 100 article/post. Try your luck using this searching form. Hope the article can be found here.

11 June 2009

PHP: Send email without setting IIS smtp relay

Just make it short for those who are seeking for solution sending email using php code.
If you are using this function mail() for example:

mail($to, $subject, $body, $headers);

Then you have to set smtp relay restrictions and allowing 127.0.0.1 to access and relay the email.

You can test the email and it should be working. You should be able to send email after that.

But in my case, there are no smtp relay setting for the IIS Manager. So, I spent couple of hours searching for solutions. So here is the solutions that help me to solve my problem.

1. Get a class.phpmailer.php, phpmailer.lang-en.php , and class.smtp.php source code from the internet.
2. Write a code to use the class. Example:

include_once('class.phpmailer.php');
$mail = new PHPMailer(); // defaults to using php "mail()"
$mailto="put email address here";

$sender="put sender email address here";
$mail->From = $sender;
$mail->FromName = $sender;

$subject = "Test Sending email" ;
$email_is_required = 0;
$name_is_required = 1;
$uself = 0;
$use_envsender = 0;
$use_utf8 = 0;

$headersep = (!isset( $uself ) ($uself == 0)) ? "\r\n" : "\n" ;
$content_type = (!isset( $use_utf8 ) ($use_utf8 == 0)) ? 'Content-Type: text/plain; charset="iso-8859-1"' : 'Content-Type: text/plain; charset="utf-8"' ;
if (!isset( $use_envsender )) { $use_envsender = 0 ; }
$envsender = "-f$mailto" ;

$http_referrer = getenv( "HTTP_REFERER" );
$comments="some comment here";

$messageproper="You got comment: $comments";

$mail->Subject = $subject;
$mail->Body = $messageproper;
$mail->AddAddress($mailto, "A NAME HERE");
$mail->Host = "192.168.1.9"; //put your email server IP address
$mail->Mailer = "smtp";

if(!$mail->Send()) {
//put some code if email cannot be send here
}else{
//put code for email successfully send here
}



0 Comment(s):

Post a Comment

Comment:>

Quick review, Learn More.. :-

[johnny.ihackstuff] Google Hacking Database
[Squid Analysis Report Generator] ...
[ Robtex Swiss Army Network Tools ] Swiss Army Network Tools
[-----] Exploit
[Bindshell] ...
[erratasec] Errata security
[learnsecurityonline] Learn Security online
[One Computer Guy] Tips and trick
[Lifedork] A hint for me
[dougknox] XP tips & fixes
[Uniblue PC-library.com] Port details
[Izakat.com] Zakat pendapatan