chain2005 Posted April 3, 2007 Share Posted April 3, 2007 I'm building an autoresponder service similiar to 1ShoppingCart.com and frankly I'm having the PHP Mailing Blues... It should be so much easier! I can get everything to mail out fine the problem is a lot of spam blockers are blocking my emails. I started off using the mail() but new it's limitations soon moved to a pre-coded SMTP mailer (see code below)... Now everytime an email is sent out to like a Hotmail account it always goes directly into the Junk Mail container. Hotmail is saying all these emails do not have a SENDER ID. I'm not sure what that is or how to set one, which is pretty much why I've come here! If anyone knows how I could fix this, I would owe my deepest gratitude to! This problem has been costing me a lot of time! Just a reminder everything works properly when sent to a local email but outside emails are not working... function authSendEmail($from, $namefrom, $to, $nameto, $subject, $message) { //SMTP + SERVER DETAILS /* * * * CONFIGURATION START * * * */ $smtpServer = "localhost"; $port = "25"; $timeout = "30"; $username = ""; $password = ""; $localhost = "localhost"; $newLine = "\r\n"; /* * * * CONFIGURATION END * * * * */ //Connect to the host on the specified port $smtpConnect = fsockopen($smtpServer, $port, $errno, $errstr, $timeout); $smtpResponse = fgets($smtpConnect, 515); if(empty($smtpConnect)) { $output = "Failed to connect: $smtpResponse"; return $output; } else { $logArray['connection'] = "Connected: $smtpResponse"; } //Request Auth Login fputs($smtpConnect,"AUTH LOGIN" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['authrequest'] = "$smtpResponse"; //Send username fputs($smtpConnect, base64_encode($username) . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['authusername'] = "$smtpResponse"; //Send password fputs($smtpConnect, base64_encode($password) . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['authpassword'] = "$smtpResponse"; //Say Hello to SMTP fputs($smtpConnect, "HELO $localhost" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['heloresponse'] = "$smtpResponse"; //Email From fputs($smtpConnect, "MAIL FROM: $from" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['mailfromresponse'] = "$smtpResponse"; //Email To fputs($smtpConnect, "RCPT TO: $to" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['mailtoresponse'] = "$smtpResponse"; //The Email fputs($smtpConnect, "DATA" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $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; fputs($smtpConnect, "To: $to\nFrom: $from\nSubject: $subject\n$headers\n\n$message\n.\n"); $smtpResponse = fgets($smtpConnect, 515); $logArray['data2response'] = "$smtpResponse"; // Say Bye to SMTP fputs($smtpConnect,"QUIT" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['quitresponse'] = "$smtpResponse"; } Link to comment https://forums.phpfreaks.com/topic/45370-php-mailing-blues/ Share on other sites More sharing options...
chronister Posted April 3, 2007 Share Posted April 3, 2007 I am not too darn familiar with mail() but I think you have to add this in the headers $headers .= "X-Mailer: PHP/" . phpversion(); I am pretty sure that this is the SENDER ID it is looking for. Link to comment https://forums.phpfreaks.com/topic/45370-php-mailing-blues/#findComment-220338 Share on other sites More sharing options...
chain2005 Posted April 3, 2007 Author Share Posted April 3, 2007 Hey, I've just added that and it seems to work a little better now 1 out of the 2 that previously blocked it doesn't block it! Any other ideas on how to fix it? Thanks! Link to comment https://forums.phpfreaks.com/topic/45370-php-mailing-blues/#findComment-220616 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.