2009/9/14 Chris <dmag...@gmail.com>:
> nagendra prasad wrote:
>>
>> Hi all,
>>
>> Below is the code that I have coded after replies from all of you. But
>> before that I want to thank all of you for your help. I have coded the
>> email
>> code but still it is giving me an error. Please help me.
>
> ... and the error is what exactly?
>
>> <?php
>>
>> //sending email script
>>
>> $to = "exam...@gmail.com";
>> $subject = "Email from admin";
>>
>> if ($_POST['submit'])
>> {
>> //get data from form
>>
>> $name = $_POST['name'];
>> $message = $_POST['message'];
>> if ($name&&$message)
>> {
>> $namelen = 20;
>> $messagelen = 300;
>> if (strlen($name)<=$namelen && strlen($message)<=$messagelen)
>> {
>>  //everything is ok
>>
>>  ini_set("SMTP", "smtp.gmail.com");
>
> Where's your smtp authentication? You can't just set the mail server and
> that's it.
>
> http://deepakssn.blogspot.com/2006/06/gmail-php-send-email-using-php-with.html
>
> Use phpmailer (as this article suggests) and you'll have a lot better chance
> of things working.
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Follow these steps...

1 - What is the domain of the recipient? gmail.com
2 - What is recipients SMTP server? nslookup -q=mx gmail.com

[2009/09/14 10:10:58] [C:\] [] >nslookup -q=mx gmail.com
Server:  bv-vm-svr-1.bandvulc.local
Address:  10.0.30.1

Non-authoritative answer:
gmail.com       MX preference = 40, mail exchanger =
alt4.gmail-smtp-in.l.google.com
gmail.com       MX preference = 10, mail exchanger =
alt1.gmail-smtp-in.l.google.com
gmail.com       MX preference = 5, mail exchanger = gmail-smtp-in.l.google.com
gmail.com       MX preference = 30, mail exchanger =
alt3.gmail-smtp-in.l.google.com
gmail.com       MX preference = 20, mail exchanger =
alt2.gmail-smtp-in.l.google.com

alt4.gmail-smtp-in.l.google.com internet address = 72.14.247.27
alt1.gmail-smtp-in.l.google.com internet address = 209.85.129.114
gmail-smtp-in.l.google.com      internet address = 74.125.79.114
alt3.gmail-smtp-in.l.google.com internet address = 209.85.223.14
alt2.gmail-smtp-in.l.google.com internet address = 209.85.218.33

Use one of the servers you see here. These are the public SMTP servers
set to RECEIVE email from anyone. No authority required.

What _IS_ required is a valid recipient.

The output of the nslookup command can also be seen by using getmxrr() in PHP.

Look at the user notes on http://docs.php.net/getmxrr for versions of
getmxrr() for versions of PHP on windows which didn't have this
function.

At a fundamental level, this is how email is sent. You normally send
it to a server you are allowed to send to (a relay). This normally
requires some sort of security (not always - but may require you to
POP3 login to your mailbox). You send the mail. The local server
receives it. By using the domain of the recipient the server finds
where to send it. The recipients server knows nothing about YOUR
server - no authority - but has to accept the message.

Using getmxrr() is bypassing the local relay step and going direct.

Obviously, you have to handle all the errors, retries, etc. But you
can also step through the servers if one is offline or whaterver.



-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to