jakebur01 Posted August 7, 2007 Share Posted August 7, 2007 What would be the best way to add a Bcc into this? $smtpConnect = fsockopen($smtpServer, $port, $errno, $errstr, $timeout); //echo $errstr." - ".$errno; $smtpResponse = fgets($smtpConnect, 4096); if(empty($smtpConnect)) { $output = "Failed to connect: $smtpResponse"; //echo $output; return $output; } else { $logArray['connection'] = "Connected to: $smtpResponse"; echo "E-Mail Sent Successfully<br><p />Please check your junk mail or spam mail folder if you do not receive an e-mail in your inbox.<br><p />"; } //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"; //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; //observe the . after the newline, it signals the end of message fputs($smtpConnect, "To: $to\r\nFrom: $from\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); Also, is their anything I might could add into this to keep it from going into a junk mail folder? I'm pretty happy with it, it goes to most all e-mails i've tested with it. I just wish I could add in the bcc. Link to comment https://forums.phpfreaks.com/topic/63799-solved-need-touching-up/ Share on other sites More sharing options...
frost Posted August 7, 2007 Share Posted August 7, 2007 I think you could just add $headers .= "Bcc: $bccto " . $newLine; right after $headers .= "To: $nameto <$to>" . $newLine; Link to comment https://forums.phpfreaks.com/topic/63799-solved-need-touching-up/#findComment-317979 Share on other sites More sharing options...
jakebur01 Posted August 8, 2007 Author Share Posted August 8, 2007 Wouldn't I need to do a " fputs() for it? Link to comment https://forums.phpfreaks.com/topic/63799-solved-need-touching-up/#findComment-318014 Share on other sites More sharing options...
frost Posted August 8, 2007 Share Posted August 8, 2007 I don't think so, try the bcc way? Link to comment https://forums.phpfreaks.com/topic/63799-solved-need-touching-up/#findComment-318447 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.