fsockopen-email problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
home.art18
Forum Newbie
Posts: 1
Joined: Wed Jul 07, 2010 3:52 am

fsockopen-email problem

Post by home.art18 »

hi,

i have question to all php expert out there,

using fsockopen with my company email address i can successful send email to internal email inside our company,

but when i tried sending to gmail. there are no errors but the email wasn't sent on my gmail account.

what do you think is the problem?

here is the codes that i am using:

$email1 = $_POST['email'];

$smtpservername = 'smtp.our.com';
$email = '<mine@our.com>';
$toemail = 'email_g@gmail.com';

$comment = "Email Message";


$smtp_server = fsockopen($smtpservername, 25, $errno, $errstr, 30);

if(!$smtp_server)
{
echo "Something went wrong when sending email, please try again later";
exit;
}
//echo $_SERVER['SERVER_NAME'];
//echo $smtp_server;
fputs($smtp_server, "HELO ".$_SERVER['SERVER_NAME']."\r\n");
$inn = fgets($smtp_server, 1024);
fputs($smtp_server, "MAIL FROM: $email \r\n");
$inn = fgets($smtp_server, 1024);
fputs($smtp_server, "RCPT TO: $email1\r\n");
$inn = fgets($smtp_server, 1024);
fputs($smtp_server, "DATA\r\n");
$inn = fgets($smtp_server, 1024);
fputs($smtp_server, "Date: date date\r\n");
fputs($smtp_server, "From: our site\r\n");
fputs($smtp_server, "Subject: Thank You! \r\n");
fputs($smtp_server, "To: $email1 \r\n");
fputs($smtp_server, $comment." \r\n");
fputs($smtp_server, ".\r\nQUIT\r\n");
$inn = fgets($smtp_server, 1024);
fclose($smtp_server);
Post Reply