STOP!
you should have only executed

from gluon.tools import Mail
server = Mail('smtp.gmail.com:587', 'your...@gmail.com', 'youruser:password'
)
server.send('t...@example.com', 'subject', 'test body')

and copied the output here. 
You seem to have entered in the console my example output, that is NOT 
something you want to enter in a shell :P
We want to read the shell after those 3 lines to see what is going to 
happen: mine was only an example on what a successful connection prints.


On Monday, December 3, 2012 4:52:16 PM UTC+1, Aurelijus Useckas wrote:
>
> Thanx for a tip Niphlod,
>
> Here's the output:
>
> >>> send: 'ehlo [127.0.1.1]\r\n'
> reply: '250-mx.google.com at your service, [95.244.128.226]\r\n'
> reply: '250-SIZE 35882577\r\n'
> reply: '250-8BITMIME\r\n'
> reply: '250-STARTTLS\r\n'
> reply: '250 ENHANCEDSTATUSCODES\r\n'
> reply: retcode (250); Msg: mx.google.com at your service, [95.244.128.226]
> SIZE 35882577
> 8BITMIME
> STARTTLS
> ENHANCEDSTATUSCODES
> send: 'STARTTLS\r\n'
> ..........  File "<console>", line 1
>     send: 'ehlo [127.0.1.1]\r\n'
>         ^
> SyntaxError: invalid syntax
> >>>   File "<console>", line 1
>     reply: '250-mx.google.com at your service, [95.244.128.226]\r\n'
>          ^
> SyntaxError: invalid syntax
> >>>   File "<console>", line 1
>     reply: '250-SIZE 35882577\r\n'
>          ^
> SyntaxError: invalid syntax
> >>>   File "<console>", line 1
>     reply: '250-8BITMIME\r\n'
>          ^
> SyntaxError: invalid syntax
> >>>   File "<console>", line 1
>     reply: '250-STARTTLS\r\n'
>          ^
> SyntaxError: invalid syntax
> >>>   File "<console>", line 1
>     reply: '250 ENHANCEDSTATUSCODES\r\n'
>          ^
> SyntaxError: invalid syntax
> >>>   File "<console>", line 1
>     reply: retcode (250); Msg: mx.google.com at your service, [95.244.
> 128.226]
>          ^
> SyntaxError: invalid syntax
> >>>   File "<console>", line 1
>     SIZE 35882577
>                 ^
> SyntaxError: invalid syntax
> >>>   File "<console>", line 1
>     8BITMIME
>            ^
> SyntaxError: invalid syntax
> >>> Traceback (most recent call last):
>   File "<console>", line 1, in <module>
> NameError: name 'STARTTLS' is not defined
> >>> Traceback (most recent call last):
>   File "<console>", line 1, in <module>
> NameError: name 'ENHANCEDSTATUSCODES' is not defined
> >>>   File "<console>", line 1
>     send: 'STARTTLS\r\n'
>         ^
> SyntaxError: invalid syntax
> >>> send: 'ehlo [127.0.1.1]\r\n'
>   File "<console>", line 1
>     ..........send: 'ehlo [127.0.1.1]\r\n'
>     ^
>
>
> Could you help me to figure out what's wrong?
>
> On Monday, December 3, 2012 1:29:33 AM UTC+2, Niphlod wrote:
>>
>> let's inspect the code: if the exception has something to do with an 
>> error related to sending the email, the value returned is always True. 
>> That means that if (and that's not your case) there's something wrong 
>> with body, sender, cc, etc, you would see an exception. Given instead that 
>> there are no errors with the parameters you're using (because your rtn is 
>> True), if there are errors sending the email they are stored into 
>> mail.error (usually the entire traceback). 
>> If that's None, by all means the mail server (or whatever you're 
>> connecting to) is responding something like "ok, I queued it".
>> To inspect the problem further, please add a line in gluon/tools.py
>>
>>
>>                 smtp_args = self.settings.server.split(':')
>>                 if self.settings.ssl:
>>                     server = smtplib.SMTP_SSL(*smtp_args)
>>                 else:
>>                     server = smtplib.SMTP(*smtp_args)
>>                 server.set_debuglevel(1)#added line
>>
>> That will print on stderr all the "raw commands" sent to the mail server. 
>> You can try sending an email just entering the shell of your app with 
>> web2py.py -M -S yourappname and then mail.send('t...@example.com', 
>> 'subject', 'test body') or, cd-ing into web2py.py folder and
>>
>> web2py$ python
>> Python 2.6.5 (r265:79063, Oct  1 2012, 22:04:36) 
>> [GCC 4.4.3] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> from gluon.tools import Mail
>> >>> server = Mail('smtp.gmail.com:587', 'your...@gmail.com', 
>> 'youruser:password')
>> >>> server.send('t...@example.com', 'subject', 'test body')
>> following this, something like 
>> send: 'ehlo [127.0.1.1]\r\n'
>> reply: '250-mx.google.com at your service, [95.244.128.226]\r\n'
>> reply: '250-SIZE 35882577\r\n'
>> reply: '250-8BITMIME\r\n'
>> reply: '250-STARTTLS\r\n'
>> reply: '250 ENHANCEDSTATUSCODES\r\n'
>> reply: retcode (250); Msg: mx.google.com at your service, [95.244.128.226
>> ]
>> SIZE 35882577
>> 8BITMIME
>> STARTTLS
>> ENHANCEDSTATUSCODES
>> send: 'STARTTLS\r\n'
>> ..........
>>
>> should appear if the connection can be established with google servers.
>>
>>
>>
>>
>>
>>
>>
>> On Sunday, December 2, 2012 10:03:44 PM UTC+1, Aurelijus Useckas wrote:
>>>
>>> it only returns True. I'm beginning to guess there's smthng wrong with 
>>> some firewalls ISP has placed
>>>
>>> On Sunday, December 2, 2012 9:54:40 PM UTC+2, Niphlod wrote:
>>>>
>>>> and the rtn ? it's strange that no errors are returned because that 
>>>> would mean that the mail library didn't "catch" the error (i.e. no error 
>>>> messages were returned by the mail server)
>>>>
>>>> On Sunday, December 2, 2012 1:57:22 PM UTC+1, Aurelijus Useckas wrote:
>>>>>
>>>>> yes, it gives very little info:
>>>>>
>>>>> In [3] : print mail.result
>>>>> {}
>>>>>
>>>>> In [4] : print mail.error
>>>>> None
>>>>>  
>>>>>
>>>>> On Friday, November 30, 2012 1:42:16 PM UTC+2, Niphlod wrote:
>>>>>>
>>>>>> did you try to see what errors you get back ?
>>>>>>
>>>>>> rtn = mail.send('y...@example.com',
>>>>>>                       'Message subject',
>>>>>>                       'Plain text body of the message')
>>>>>>
>>>>>> print rtn
>>>>>> print mail.result
>>>>>> print mail.error 
>>>>>>
>>>>>> ?
>>>>>>
>>>>>> Il giorno venerdì 30 novembre 2012 11:16:00 UTC+1, Aurelijus Useckas 
>>>>>> ha scritto:
>>>>>>>
>>>>>>> nope... I'm running a linux. Virus free environment. No need for 
>>>>>>> McAfee ;)
>>>>>>>
>>>>>>> Thnx anyway guys, I guess I'll check with my provider. It has to be 
>>>>>>> their fault.  
>>>>>>>
>>>>>>> On Thursday, November 29, 2012 3:36:09 PM UTC+2, Mark wrote:
>>>>>>>>
>>>>>>>> If McAfee is running on the server, McAfee blocked the emails 
>>>>>>>> sending from web2py, which isn't on the whitelist of McAfee. Try to 
>>>>>>>> change 
>>>>>>>> web2py.exe into apache.exe
>>>>>>>>
>>>>>>>> On Wednesday, November 28, 2012 10:20:55 AM UTC-5, Aurelijus 
>>>>>>>> Useckas wrote:
>>>>>>>>>
>>>>>>>>> Hey, strange situation. Would apreciate your help...
>>>>>>>>>
>>>>>>>>> I have 2 identical versions of the same app running on local host 
>>>>>>>>> (v2.2.1) and the server (v2.2.1 as well). Local version handles auth 
>>>>>>>>> mail 
>>>>>>>>> (mail.send) very well, but the app which is running on server is 
>>>>>>>>> unable to 
>>>>>>>>> send anything. 
>>>>>>>>>
>>>>>>>>> This must be something with the server but I'm not sure what and 
>>>>>>>>> how to ask?? BTW the server is dedicated, I myself have deployed a 
>>>>>>>>> web2py 
>>>>>>>>> on it.
>>>>>>>>>
>>>>>>>>> Thank you in advance! 
>>>>>>>>>
>>>>>>>>

-- 



Reply via email to