note 86294 added to function.fputs

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
how to add file attachment in below script ??? pl help at [email protected]. Thanks in advance

function authMail($from, $namefrom, $to, $nameto, $subject, $message)
{

// SMTP MAIL FUNCTION
/*  your configuration here  */

$smtpServer = "smtpout.secureserver.net"; //ip accepted as well
$port = "25"; // should be 25 by default
$timeout = "30"; //typical timeout. try 45 for slow servers
$username = "$from"; //the login for your smtp
$password = "387268"; //the pass for your smtp
$localhost = "127.0.0.1"; //this seems to work always
$newLine = "\r\n"; //var just for nelines in MS
$secure = 1; //change to 1 if you need a secure connect

/*  you shouldn't need to mod anything else */

//connect to the host and port
$smtpConnect = fsockopen($smtpServer, $port, $errno, $errstr, $timeout);
$smtpResponse = fgets($smtpConnect, 4096);
if(empty($smtpConnect))
{
   $output = "Failed to connect: $smtpResponse";
   return $output;
}
else
{
   $logArray['connection'] = "Connected to: $smtpResponse";
}

//say HELO to our little friend
fputs($smtpConnect, "HELO $localhost". $newLine);
$smtpResponse = fgets($smtpConnect, 4096);
$logArray['heloresponse'] = "$smtpResponse";

//start a tls session if needed
if($secure)
{
   fputs($smtpConnect, "STARTTLS". $newLine);
   $smtpResponse = fgets($smtpConnect, 4096);
   $logArray['tlsresponse'] = "$smtpResponse";

   //you have to say HELO again after TLS is started
   fputs($smtpConnect, "HELO $localhost". $newLine);
   $smtpResponse = fgets($smtpConnect, 4096);
   $logArray['heloresponse2'] = "$smtpResponse";
}

//request for auth login
fputs($smtpConnect,"AUTH LOGIN" . $newLine);
$smtpResponse = fgets($smtpConnect, 4096);
$logArray['authrequest'] = "$smtpResponse";

//send the username
fputs($smtpConnect, base64_encode($username) . $newLine);
$smtpResponse = fgets($smtpConnect, 4096);
$logArray['authusername'] = "$smtpResponse";

//send the password
fputs($smtpConnect, base64_encode($password) . $newLine);
$smtpResponse = fgets($smtpConnect, 4096);
$logArray['authpassword'] = "$smtpResponse";

//email from
fputs($smtpConnect, "MAIL FROM: $from" . $newLine);
$smtpResponse = fgets($smtpConnect, 4096);
$logArray['mailfromresponse'] = "$smtpResponse";

//email to
fputs($smtpConnect, "RCPT TO: $to" . $newLine);
$smtpResponse = fgets($smtpConnect, 4096);
$logArray['mailtoresponse'] = "$smtpResponse";

//email to
fputs($smtpConnect, "RCPT BCC: $bcc1" . $newLine);
$smtpResponse = fgets($smtpConnect, 4096);
$logArray['mailtoresponse'] = "$smtpResponse";

//the email
fputs($smtpConnect, "DATA" . $newLine);
$smtpResponse = fgets($smtpConnect, 4096);
$logArray['data1response'] = "$smtpResponse";

//construct headers
$headers = "MIME-Version: 1.0" . $newLine;
$headers .= "Content-type: text/html; charset=iso-8859-1" . $newLine;
//$headers .= "To:$nameto <$to>" . $newLine;
//$headers .= "From:$namefrom <$from>" . $newLine;
//$headers .= "Bcc:kalpesh <[email protected]>" . $newLine;
//$headers .= "Reply-to:kalpesh classes <[email protected]>" . $newLine;
//$headers .= "cc:Kalpesh <[email protected]>" . $newLine;

//observe the . after the newline, it signals the end of message
fputs($smtpConnect, "To: $nameto<$to>\r\nFrom: $namefrom <$from>\r\nReply-to: $namefrom <$replyto>\r\nSubject: $subject\r\n$headers\r\n\r\n$message\r\n.\r\n");
$smtpResponse = fgets($smtpConnect, 4096);
$logArray['data2response'] = "$smtpResponse";

// say goodbye
fputs($smtpConnect,"QUIT" . $newLine);
$smtpResponse = fgets($smtpConnect, 4096);
$logArray['quitresponse'] = "$smtpResponse";
$logArray['quitcode'] = substr($smtpResponse,0,3);
fclose($smtpConnect);
//a return value of 221 in $retVal["quitcode"] is a success
return($logArray);

}
----
Server IP: 203.199.69.133
Probable Submitter: 59.181.110.109
----
Manual Page -- http://www.php.net/manual/en/function.fputs.php
Edit        -- https://master.php.net/note/edit/86294
Del: integrated  -- https://master.php.net/note/delete/86294/integrated
Del: useless     -- https://master.php.net/note/delete/86294/useless
Del: bad code    -- https://master.php.net/note/delete/86294/bad+code
Del: spam        -- https://master.php.net/note/delete/86294/spam
Del: non-english -- https://master.php.net/note/delete/86294/non-english
Del: in docs     -- https://master.php.net/note/delete/86294/in+docs
Del: other reasons-- https://master.php.net/note/delete/86294
Reject      -- https://master.php.net/note/reject/86294
Search      -- https://master.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.