PHP - Php Email Sent To Gmail Is A Spam
i am using mail functions in php and i am sending mails but the mails are going to spam in gmail and for yahoo its going to inbox. my problem is i want to send the email to inbox only as most of them use gmail ....should i use any smtp or any other mail library functions?
can anyone guide me? Similar TutorialsHere is one of my emails. Delivered-To: jason@gmail.com Received: by 10.204.57.134 with SMTP id c6cs22321bkh; Tue, 13 Sep 2011 07:23:32 -0700 (PDT) Received: by 10.101.168.12 with SMTP id v12mr3751263ano.48.1315923810914; Tue, 13 Sep 2011 07:23:30 -0700 (PDT) Return-Path: <contact@big.com> Received: from big.com (big.com [173.0.59.100]) by mx.google.com with ESMTP id c19si889696anj.173.2011.09.13.07.23.29; Tue, 13 Sep 2011 07:23:29 -0700 (PDT) Received-SPF: pass (google.com: domain of contact@big.com designates 173.0.59.100 as permitted sender) client-ip=173.0.59.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of contact@big.com designates 173.0.59.100 as permitted sender) smtp.mail=contact@big.com; dkim=neutral (body hash did not verify) header.i=@big.com Received: by big.com (Postfix, from userid 33) id 1BDCE2F4041A; Tue, 13 Sep 2011 10:23:20 -0400 (EDT) DKIM-Signatu v=1; a=rsa-sha256; c=simple/simple; d=big.com; s=mail; t=1315923800; bh=ysNGlrscqmqCPbqxJlWWHLaW3SU6MgDVQCze+cevPS4=; h=To:Subject:Message-ID:Date:MIME-Version:Sender:From:Reply-To: Content-Type; b=PDPCRvKGQRP3LeeDNhZQwbX6aMXOZEyqRXV1E+kuDDq05NYRIrmJCcQRhwEIaSosh yoZ0pF5wtrXjgY1KA0hgee7qzSVDhweguBfOydn1qE6nsL1pq CQgsHmtvu9dwPGw9z uUEHM9bg5DwiG0RT5KLYf4oZTJmJpc8n2oyK26/I= To: jason@gmail.com Subject: Closed Beta Invitation from Jason Gordon Message-ID: <87847890-050333@big.com> Date: Tue, 13 Sep 2011 10:38:17 -0400 MIME-Version: 1.0 X-Mailer: PHP-5.3.8 X-Sender: "big" <contact@big.com> X-Priority: 3 Organization: big Errors-To: contact@big.com Sender: contact@big.com From: "big" <contact@big.com> Reply-To: "big" <contact@big.com> Content-Type: multipart/alternative; boundary=87847890 --48673093 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit <a href="http://big.com/u/jasonGordon?utm_source=beta_invite&utm_medium=email&utm_content=referer_name&utm_campaign=join_beta" alt="Jason Gordon's profile" title="Jason Gordon's profile">Jason Gordon</a> invited you to join the newest community of entreprenuers and investors, big. Why participate in our closed beta? Here you will be able to find, research and connect with entrepreneurs or investor so much easier than ever before. You will be one of the first people to ever lay eyes on our exclusive software! Sign up by clicking <a href="http://big.com/join?9b782e=&key=7RG5poe9lgxmUSIcQTPji8EtFMnXyOYW3Cf&utm_source=beta_invite&utm_medium=email&utm_content=sign_up&utm_campaign=join_beta" title="big Beta Referral">here</a> If the link does not work, go to <a href="http://big.com" title="big">big.com</a>, click "Join big" and enter your closed beta access key. Your closed beta access key is: 7RG5poe9lgxmUSIcQTPji8EtFMnXyOYW3Cf Please leave us feedback so that we can improve our software. big Team --48673093 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Closed Beta Invitation</title> </head> <body> <table width="500px" cellspacing="0" cellpadding="13" style="border: 1px solid #e7e7e7;"> <tr> <td> <table cellspacing="0" cellpadding="5" bgcolor="#ffffff" width="480px" style="border: 1px solid #999999;"> <tr> <td bgcolor="#489fcc" cellspacing="15" style="border-bottom: 1px solid #999999; border-top: 0; border-left: 0; border-right: 0; font-family: verdana; letter-spacing: 1px; font-weight: bold; color: white;" width="480px"> big </td> </tr> <tr> <td> <table style="line-height: 26px; font-family: arial; font-size: 13px;" width="100%" cellspacing="10" cellpadding="0"> <tr> <td width="100%"> <table style="line-height: 26px; text-align: justify;" width="100%" cellpadding="0" cellspacing="0"> <tr> <td width="100%"> <a href="http://big.com/u/jasonGordon?utm_source=beta_invite&utm_medium=email&utm_content=referer_name&utm_campaign=join_beta" alt="Jason Gordon's profile" title="Jason Gordon's profile">Jason Gordon</a> invited you to join the newest community of entreprenuers and investors, big. Why participate in our closed beta? Here you will be able to find, research and connect with entrepreneurs or investor so much easier than ever before. You will be one of the first people to ever lay eyes on our exclusive software! </td> </tr> </table> </td> </tr> <tr> <td align="center" width="100%"> <table style="border-top: 1px solid #b8b8b8; border-bottom: 1px solid #b8b8b8;" width="100%" cellpadding="0" cellspacing="5"> <tr> <td width="100%" align="center"> Sign up by clicking <a href="http://big.com/join?9b782e=&key=7RG5poe9lgxmUSIcQTPji8EtFMnXyOYW3Cf&utm_source=beta_invite&utm_medium=email&utm_content=sign_up&utm_campaign=join_beta" title="big Beta Referral">here</a> </td> </tr> </table> </td> </tr> <tr> <td width="100%" style="text-align: justify;"> If the link does not work, go to <a href="http://big.com" title="big">big.com</a>, click "Join big" and enter your closed beta access key. Your closed beta access key is: </td> </tr> <tr> <td align="center" width="100%"> <table bgcolor="#e6e6e6" style="border: 1px solid #b8b8b8;" width="100%" cellpadding="0" cellspacing="5"> <tr> <td width="100%" align="center"> 7RG5poe9lgxmUSIcQTPji8EtFMnXyOYW3Cf </td> </tr> </table> </td> </tr> <tr> <td width="100%"> Please leave us feedback so that we can improve our software. </td> </tr><tr> <td width="100%"> big Team </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </body> </html> --48673093-- My headers function is... Code: [Select] function mail_header ($type, $random_hash) { $type = (int)$type; if ($type === 0) { $boundary = $random_hash; $x_mailer = phpversion(); $time_stamp = date("r"); $headers = 'Message-ID: <'.$boundary.'-050333@big.com>' . "\r\n"; $headers .= 'Date: ' . $time_stamp . "\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'X-Mailer: PHP-' . $x_mailer . "\r\n"; $headers .= 'X-Sender: "big" <contact@big.com>' . "\r\n"; $headers .= 'X-Priority: 3' . "\r\n"; $headers .= 'Organization: big' . "\r\n"; $headers .= 'Errors-To: contact@big.com' . "\r\n"; $headers .= 'Sender: contact@big.com' . "\r\n"; $headers .= 'From: "big" <contact@big.com>' . "\r\n"; $headers .= 'Reply-To: "big" <contact@big.com>' . "\r\n"; $headers .= 'Return-Path: "big" <contact@big.com>' . "\r\n"; $headers .= 'Content-Type: multipart/alternative; boundary=' . $boundary . "\r\n"; } return $headers; } HI, i have a problem, a big one. I used a php script to send some info from my html forms to my gmail. So it functions easy, somebody fills out the form and he click send, after that, his information is sent to me on my gmail, and i can work with it later. Now stupid google have some new filters (from year 2014 ) and it treats some of those mails as spam. Code is written in the way that allows me to get those mails as it is sent from the user himself, from his email. Can anybody correct my script so it won't be treated as a spam, because i know it is possible but don't know how... here is the code - https://gist.github....67145d500c5cf47 // Receiving variables i think because of my code used to send the mail, on my site, its appearing in the spam folder of most of my clients PLUS myself is their a way to eradicate this? correct headers? etc? Hello all, I used simple php email function but it send an email in junk folder or spam. Can anyone tell me why is this so? Her is the code: $host = "ssl://smtp.gmail.com"; $port = "465"; $to = " xx@gmail.com"; // note the comma $subject = " $_POST[company_website] "; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: About Wholesale Account' . "<$_POST[email]>\r\n"; $headers .= 'Cc: mail@gmail.com' . "\r\n"; $headers .= 'Bcc: cc@gmail.com' . "\r\n"; mail($to, $subject, $message, $headers); Hi the user fill details and then the email his sent to me the only problem is that the emails keeps going to my spam, can someone help me out please I looked already php website and email format looks the same. This is the link to my form. http://www.people.eurico.co.uk/ here my form script Code: [Select] <?php // Set email variables $email_to = 'xxxxx@xxxxxxx.co.uk'; $email_subject = 'Call back form'; // Set required fields $required_fields = array('fullname','email','telephone','comment'); // set error messages $error_messages = array( 'fullname' => 'Please enter a Name to proceed.', 'email' => 'Please enter a valid Email.', 'telephone' => 'Please telephone.', 'comment' => 'Please enter your Message to continue.' ); // Set form status $form_complete = FALSE; // configure validation array $validation = array(); // check form submittal if(!empty($_POST)) { // Sanitise POST array foreach($_POST as $key => $value) $_POST[$key] = remove_email_injection(trim($value)); // Loop into required fields and make sure they match our needs foreach($required_fields as $field) { // the field has been submitted? if(!array_key_exists($field, $_POST)) array_push($validation, $field); // check there is information in the field? if($_POST[$field] == '') array_push($validation, $field); // validate the email address supplied if($field == 'email') if(!validate_email_address($_POST[$field])) array_push($validation, $field); } // basic validation result if(count($validation) == 0) { // Prepare our content string $email_content = 'peoplesmartlearning.co.uk: ' . "\n\n"; // simple email content foreach($_POST as $key => $value) { if($key != 'submit') $email_content .= $key . ': ' . $value . "\n"; } // if validation passed ok then send the email mail($email_to, $email_subject, $email_content); // Update form switch $form_complete = TRUE; } } function validate_email_address($email = FALSE) { return (preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i', $email))? TRUE : FALSE; } function remove_email_injection($field = FALSE) { return (str_ireplace(array("\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:"), '', $field)); } ?> The HTML Code: [Select] <div class="call_us_form"> <p class="title">WE'LL CALL YOU BACK</p> <?php if($form_complete === FALSE): ?> <form class="contact_form" id="fm-form" method="post" action="index.php" > <fieldset> <div class="fm-req"> <label for="fm-firstname">Name</label> <input type="text" id="fullname" class="detail" name="fullname" value="<?php echo isset($_POST['fullname'])? $_POST['fullname'] : ''; ?>" /> <?php if(in_array('fullname', $validation)): ?><script type="text/javascript">alert("Please enter a Name"); history.back();</script><?php endif; ?> </div> <div class="fm-req"> <label for="fm-firstname">Email</label> <input type="text" id="email" class="detail" name="email" value=" <?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>" /> <?php if(in_array('email', $validation)): ?><script type="text/javascript">alert("Please enter a valid Email Address"); history.back();</script><?php endif; ?> </div> <div class="fm-req"> <label for="fm-firstname">Number</label> <input type="text" id="telephone" class="detail" name="telephone" value="<?php echo isset($_POST['telephone'])? $_POST['telephone'] : ''; ?>" /> <?php if(in_array('telephone', $validation)): ?><script type="text/javascript">alert("Please enter telephone number"); history.back();</script><?php endif; ?> </div> <div class="fm-req"> <label for="fm-lastname">Message</label> <textarea cols="40" rows="5" id="comment" name="comment" class="mess"><?php echo isset($_POST['comment'])? $_POST['comment'] : ''; ?></textarea> <?php if(in_array('comment', $validation)): ?><script type="text/javascript">alert("Please enter your message"); history.back();</script><?php endif; ?> </div> <input class="submit_button" type="submit" value="Call us" /> </fieldset> </form> <?php else: ?> <p>Thank you for your Message!</p> <p>We will get back to you as soon as we can</p> <script type="text/javascript"> setTimeout ('ourRedirect()', 5000) function ourRedirect () { location.href='index.php' } </script> <?php endif; ?> i have some code which sends a confrim link via the posted email. In hotmail it works fine, once the link is clicked they are confirmed but gmail adds %09 to the link making it break. example WHERE hash = their email hashed posted email = test@test.com confirm link(hotmail) confirm.php?email=HASH&o=test@test.com(works) confirm link(gmail)confirm.php?email=%09HASH&o=test@test.com(Doesnt work) anyone know why gmail does this? I am looking for a script that is used in Facebook. Wherein, user enters the email address and password and the system will automatically fetch the addresses from the address book of Hotmail or Gmail etc and sends invitation to join the site network. Do you have any link for such a script that comes free. Looking forward to that. Thanks, Faisal I am trying to eliminate this issue but I have had no luck here is my current code: Code: [Select] $from = 'help@my.com'; $body = "<html>\n"; $body .= "<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif;\">\n"; $body .= $message; $body .= "</body>\n"; $body .= "</html>\n"; $boundary = uniqid('np'); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers = "From: $from"; $headers .= "\nMIME-Version: 1.0\n" ."Content-Type: multipart/alternative;\n" ." boundary=\"{$mime_boundary}\""; $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; \n" . "Content-Transfer-Encoding: 7bit\n\n" . $body . "\n\n" . "--{$mime_boundary}--\n"; mail($to, $subject, $message, $headers, '-f'.$from); I have tried adding the plain text part but nothing has worked, could someone else look at this and show me what I need to add so that it has the text/plain MIME part as well? i wanting users to be able to update there email address and check to see if the new email already exists. if the email is the same as current email ignore the check. i have no errors showing up but if I enter a email already in the db it still accepts the new email instead of bringing the back the error message. Code: [Select] // email enterd from form // $email=$_POST['email']; $queryuser=mysql_query("SELECT * FROM members WHERE inv='$ivn' ") or die (mysql_error()); while($info = mysql_fetch_array( $queryuser )) { $check=$info['email']; // gets current email // } if($check!=$email){ // if check not equal to $email check the new email address already exists// $queryuser=mysql_query("SELECT * FROM members WHERE email='$email' "); //$result=mysql_query($sql); $checkuser=mysql_num_rows($queryuser); if($checkuser != 0) { $error= "0"; header('LOCATION:../pages/myprofile.php?id='.$error.''); } } cheers Using the attached code below I'm sending an HTML email using PHP. It works fine, except with Gmail. If the email is sent to a Gmail account the email contents are blank and sender is unknown. I've looked around and it seems there is some widespread issue but i haven't found an answer/solution. Any help or light shed on this would be great. <?PHP //lots of stuff before this including variable setting, which all are working properly $to = $email; $subject = 'Your claim is in process!'; $random_hash = md5(date('r', time())); $headers = "From: The Insurance Agency\r\nReply-To: info@XXXXXXXXXX.com"; $headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\""; ob_start(); ?> --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Dear <?PHP echo $fname?>, Thank you for submitting your claim on our website. We're sorry to hear about your loss on <?PHP echo $dateofloss ?>; our office has received your information and will contact you as soon as possible.Sincerely, Brian R Miller, Priciple --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit <img src="http://beta.XXXXXXX.com/img/uniform/emailhead.gif" alt="" /> <p style="font-family:Arial, Helvetica, sans-serif; font-size:12px; margin:15px 0 5px 0;">Dear <?PHP echo $fname ?>,</p> <p style="font-family:Arial, Helvetica, sans-serif; font-size:12px; margin:0;">Thank you for submitting your claim on our website. We're sorry to hear about your loss on <?PHP echo $dateofloss ?>; our office has received your information and will contact you as soon as possible.</p> <p style="font-family:Arial, Helvetica, sans-serif; font-size:12px; margin:20px 0 0 200px;">Sincerely,</p> <p style="margin: 10px 0 0 200px;"><img src="http://beta.XXXXXX.com/img/uniform/briansig.gif" alt="" /></p> <p style="font-family:Arial, Helvetica, sans-serif; font-size:10px; margin:0px 0 0 200px;">Brian R Miller, priciple</p> <p style="font-family:Arial, Helvetica, sans-serif; font-size:10px; margin:200px 0 0 0">This email has been sent by an automated service</p> --PHP-alt-<?php echo $random_hash; ?>-- <?PHP $message = ob_get_clean(); mail($to, $subject, $message, $headers); ?> Hi
Could you please tell me how can i implement gmail api to send email to user contact on behalf of that user.
I am writing a google contact API to get users contacts, I get everything back except for the email address of the contact. Anyone know how to get the contacts email address? Code: [Select] <?php class gdata{ private $headers; private $googleAuth = 'http://www.google.com/mate/feeds'; private $google = 'http://www.google.com/mate/feeds/contacts/default/full'; public $token; public function headers(){ $this->headers['GData-Version'] = '3.0'; $this->headers['Authorization'] = "AuthSub token=\"$this->token\""; $this->headers['Content-Type'] = "application/x-www-form-urlencoded"; $this->headers['Host'] = "www.google.com"; $this->headers['User-Agent'] = "php/".phpversion(); $this->headers['Accept'] = "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"; $this->headers['Connection'] = "keep-alive"; } public function request_contacts($email){ $ch = curl_init(); $headers = array(); foreach($this->headers as $k => $v){ $headers[] = "$k: $v"; } $url = preg_replace("/\[email_address\]/", $email, $this->google); echo $url; curl_setopt($ch, CURLOPT_URL, $this->google); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $opt = curl_exec($ch); $xml = simplexml_load_string($opt); header("Content-type: text/plain"); foreach($xml->entry as $user){ //echo $user['link'] } print_r($xml->entry[5]); } public function auth(){ $next = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?a=getContacts'; header("Location: https://www.google.com/accounts/AuthSubRequest?next=".urlencode($next)."&scope=".urlencode($this->googleAuth)."&session=1&secure=0"); } } $gAPI = new gdata(); if($_GET['a'] == 'getContacts'){ $gAPI->token = $_GET['token']; $gAPI->headers(); $gAPI->request_contacts('untuned20@gmail.com'); }else{ $gAPI->auth(); } ?> I am trying to run this but it wont work. I get the following error. Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.gmail.com:993/imap/ssl/novalidate-cert/norsh}Inbox in /home/u984345410/public_html/default.php Here is a snipit of the code Code: [Select] function CountUnreadMails($login, $passwd) { $mbox = imap_open("{imap.gmail.com:993/imap/ssl/novalidate-cert/norsh}Inbox", $login, $passwd, OP_READONLY); $count = 0; if (!$mbox) { echo "Error"; } else { $headers = imap_headers($mbox); foreach ($headers as $mail) { $flags = substr($mail, 0, 4); $isunr = (strpos($flags, "U") !== false); if ($isunr) $count++; } } imap_close($mbox); return $count; } I cant get this to work and I found a host with imap-ssl here is my code though i've been messing around with it. It cant get the imap_open to work. Code: [Select] $mbox = imap_open ("{imap.gmail.com:993/imap/ssl/novalidate-cert/norsh}Inbox", "username", "password", OP_READONLY) or die("can't connect: " . imap_last_error()); $check = imap_mailboxmsginfo($mbox); echo $check->Unread; / Please please help. Thanks I'm using a simple form to grab an email address and send the person who signs up and automatic response. It was working for a while and now it's not. Not sure what happened. My hosting company told me to look into my headers. Can anyone help? Here is my code. Thanks, Code: [Select] <?php /* Set e-mail recipient */ $subject = "Sign Up"; $headers = "From: admin@xxx.com" . "\r\n" . "CC: admin@xxx.com"; /* Check all form inputs using check_input function */ $sign_up_email_address = check_input($_POST['sign_up_email_address'], "Please enter your email address."); /* If e-mail is not valid show error message */ if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $sign_up_email_address)) { show_error("E-mail address not valid"); } /* Let's prepare the message for the e-mail */ $response_message = "Sample Message"; /* Send the message using mail() function */ mail($sign_up_email_address, $subject, $response_message, $headers); /* Functions we used */ function check_input($data, $problem='') { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0) { show_error($problem); } return $data; } function show_error($myError) { ?> <?php echo $myError; ?> Thank you, I'm using the php mail function and sending to Gmail accounts it shows "Unknown Sender" This is my header: Code: [Select] $headers = "From: XXXXX\r\nReply-To: XXXX@XXXXX.com"; $headers .= "\r\nContent-Type: text/html; charset='iso-8859-1' Content-Transfer-Encoding: 7bit"; I read somewhere that removing the "\r" would work but no luck... any help would be awesome This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=307948.0 Hi guys , my script works perfectly in Gmail however i now need it to work in Outlook , when the form is submitted i get this error.
2014-10-25 18:49:00 SMTP ERROR: Failed to connect to server: Connection timed out (110) 2014-10-25 18:49:00 SMTP connect() failed. Mailer Error: SMTP connect() failed.
<?php require("../lib/phpmailer/PHPMailerAutoload.php"); if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['phone']) || empty($_POST['message']) || !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)) { echo "No arguments Provided!"; return false; } $m = new PHPMailer(); $m->IsSMTP(); $m->SMTPAuth = true; $m->SMTPDebug = 2; $m->Host = "smtp.live.com"; $m->Username = "test@outlook.com"; $m->Password = "pass"; $m->SMTPSecure = 'tls'; $m->Port = 465; // ive also tried 587 $m->From = "test@outlook.com"; $m->FromName = "test@outlook.com"; $m->addReplyTo('test@outlook.com ','Reply Address'); $m->addAddress('test@outlook.com', 'Some Guy'); $name = $_POST['name']; $email_address = $_POST['email']; $phone = $_POST['phone']; $message = $_POST['message']; $m->Subject = $subject; $m->Body = "You have received a new message. <br><br>". " Here are the details:<br> Name: $name <br> Phone Number: $phone <br>". "Email: $email_address<br> Message <br> $message"; $m->AltBody = "You have received a new message. <br><br>". " Here are the details:<br> Name: $name <br> Phone Number: $phone <br>". "Email: $email_address<br> Message <br> $message"; if(!$m->Send()) { echo "Mailer Error: " . $m->ErrorInfo; } else { echo "Message sent!"; return true; } ?> $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error()); $emails = imap_search($inbox,'ALL'); if($emails) { $output = ''; rsort($emails); foreach($emails as $email_number) { $overview = imap_fetch_overview($inbox,$email_number,0); $message = imap_fetchbody($inbox,$email_number,2); $output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">'; $output.= '<span class="subject">'.$overview[0]->subject.'</span> '; $output.= '<span class="from">'.$overview[0]->from.'</span>'; $output.= '<span class="date">on '.$overview[0]->date.'</span>'; $output.= '</div>'; $output.= '<div class="body">'.$message.'</div>'; } echo $output; } imap_close($inbox); this code is not working, returns this when i try to execute. Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.gmail.com:993/imap/ssl}INBOX in /Applications/MAMP/htdocs/gmailconnection.php on line 9 Cannot connect to Gmail: Can't open mailbox {imap.gmail.com:993/imap/ssl}INBOX: invalid remote specification Notice: Unknown: Can't open mailbox {imap.gmail.com:993/imap/ssl}INBOX: invalid remote specification (errflg=2) in Unknown on line 0 Any ideas?? Is there a working gmail connection/email retriever on this site? I couldnt find I've just setup an Apache server with a basic LAMP stack. We've decided to use Google Apps (gmail) as our mail server / host. So our ubuntu server is only serving up HTTP files. Because the server is not configured as a mail server, and we're using Gmail for our MX and mail servers, how do I go about using sending out emails via PHP on the Apache Box? I've tried installing Postfix, and configuring using this tutorial, and still a no go. http://www.blogternals.com/2009/04/30/postfix-google-apps-gmail-smtp-relay/ Any Ideas? |