Log in

View Full Version : Problem with Gmail



Bornfree
04-23-2010, 02:34 AM
Hi guys,

I hope that i'm in the right place. I have this problem. I use the below script on my website which sends email to my gmail account. It was working fine for a few days but somehow now it's not working. If i use another email, it works OK! Anyone has any ideas as to what is wrong?

script

<?php
@extract($_POST);
$name = stripslashes($name);
$email = stripslashes($email);
$country = stripslashes($country);
$subject = stripslashes($subject);
$comment = stripslashes($comment);
$company = stripslashes($company);
$asb = stripslashes($asb);
$address = stripslashes($address);
mail('mygmail@gmail.com',$subject,"A message from $name from($country) has been received as follows:
Comment: $comment

Company Name: $company
ASB Number: $asb
Address: $address
","From: $name <$email>");
header("location:thankyou.htm");
?>

djr33
04-23-2010, 02:52 AM
I have no idea why that would not work. Does it fail to send the email or do you not receive the email at your gmail account?

Bornfree
04-23-2010, 02:57 AM
It used to send the emails before and i used to receive it. (though it was going into the spam folder but i created a filter to solve it). But now i don't get anything in my inbox. It can't be the sending problem coz when i type in another email (myemail@mydomain.com) it works fine. So i assume the problem is my gmail is not receiving any mails!

djr33
04-23-2010, 03:10 AM
It's really hard to figure out what is wrong then.
Try this:
if (mail(....SAME AS ABOVE...)) { echo 'it works'; } else { 'it is broken'; }
To understand:
'it works': this means the server believes the mail was sent; it probably was; something is wrong with gmail getting the email
'it is broken': your server knows it didn't work; the submission was rejected and not sent

Beyond that, I suggest looking carefully in your gmail inbox/spam/etc.

Bornfree
04-23-2010, 03:12 AM
Hi Djr33,

Thank you very much for helping, but where do i put this code and what will it do?

djr33
04-23-2010, 03:14 AM
You are just adding if (....) around the mail() function. This means that you can find out what happened.
Every function has a "return" (result) value. This is what the function "equals".
So you can also do:
if (mail(....)==TRUE)
But the code above is just a shortcut.

In other words, you'll get TRUE for success and FALSE for failure.


(Note: many functions return other values, like text or numbers, but if nothing else they use TRUE and FALSE, and even if they are supposed to return text or numbers, it is common that they will return FALSE if something goes wrong.)

Bornfree
04-23-2010, 03:19 AM
Thanks a lot. i will try it and see

Bornfree
04-23-2010, 03:24 AM
it works
Warning: Cannot modify header information - headers already sent by (output started at /home/webadmin/else.com/html/process.php:17) in /home/webadmin/else.com/html/process.php on line 18


this is what i get when i click submit button

script

<?php
@extract($_POST);
$name = stripslashes($name);
$email = stripslashes($email);
$country = stripslashes($country);
$subject = stripslashes($subject);
$comment = stripslashes($comment);
$company = stripslashes($company);
$asb = stripslashes($asb);
$address = stripslashes($address);
if ( mail('my.companysupport@gmail.com',$subject,"A message from $name from($country) has been received as follows:
Comment: $comment

Company Name: $company
ASB Number: $asb
Address: $address
","From: $name <$email>")){ echo 'it works'; } else { 'it is broken'; };
header("location:thankyou.htm");
?>

hmsnacker123
04-23-2010, 03:42 AM
At the very top of the script put:
ob_start();
and at the bottom put:

ob_end_flush();

Bornfree
04-23-2010, 03:56 AM
i get this error now

Parse error: parse error in /home/webadmin/else.com/html/process.php on line 19

Can you please give me the full script so that i can just copy and paste. Coz i maybe making some mistake

djr33
04-23-2010, 04:02 AM
No, that's fine. The first error will only occur while we are testing. (And the second error is irrelevant, since we don't need to fix that now.)
And that answers the question: "It works."

This means that your server BELIEVES the email was sent, so it probably was sent. Check your gmail spam folder, try another gmail account (maybe ask a friend) and see what is wrong. Maybe the conversation is in the trash because you deleted one of the other messages?

So now you can go back to your original script and it should work-- we have discovered the problem is not in the PHP, but probably with gmail.

Now I have no idea how to fix it. I'd suggest just using another email if that works. You could even then forward that (using your other email) automatically to gmail.

Bornfree
04-23-2010, 04:10 AM
Hi Guys, Thank you very much for your time. Anyway i have found this interesting article relating to my problem, but i do not understand how it is done. Maybe someone else who faces the same problem in future might find this useful.

If anyone can help me understand it i would really appreciate it. For now i have to my another email to solve the problem

http://www.google.com/support/forum/p/Google+Apps/thread?tid=179686d4bd75d3d2&hl=en