Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Python (http://www.programmingforums.org/forum43.html)
-   -   Sending An E-Mail With SMTP (http://www.programmingforums.org/showthread.php?t=10657)

Sane Jul 7th, 2006 5:00 PM

Sending An E-Mail With SMTP
 
I download QK SMTP Server, and have it running on my webserver. I forwarded port 25 to it, and then run this code:

:

import smtplib

host = 'jammersbase.com'
fromaddr = 'admin@jammersbase.com'
toaddrs = 'dr.sane@gmail.com'

subject = 'hello world!'
content = 'this is my test e-mail'

message = 'From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s'%(fromaddr, toaddrs, subject, content)

server = smtplib.SMTP(host)
server.sendmail(fromaddr, toaddrs, message)
server.quit()


My mail server recieves the e-mail, then tries to send it to dr.sane@gmail.com, but times out.

I must be doing some blatantly incorrect. I have little experience with this, so it's probably being approached in the completely incorrect manner.

One consideration is that my ISP is blocking the forward to dr.sane@gmail.com.

Consider pointing me in the right direction?

Arevos Jul 7th, 2006 6:31 PM

Quote:

Originally Posted by Sane
One consideration is that my ISP is blocking the forward to dr.sane@gmail.com.

This is likely. ISPs often block SMTP servers on their customer's machines in order to prevent spambots.

Why not send your email through your ISPs SMTP server?

Sane Jul 7th, 2006 7:22 PM

How do I find out my ISPs SMTP server? Would it be my <insert username here>@sympatico.ca address? In which case the server would be sympatico.ca ... ?

So you don't see anything incorrect with my logic? I wasn't sure if the server specified was supposed to be the destination, the source, or just some random server...

EDIT - This code did not work.

Quote:

Originally Posted by IDLE
error: (10054, 'Connection reset by peer')

:

import smtplib

host = 'sympatico.ca'
fromaddr = 'admin@jammersbase.com'
toaddrs = 'dr.sane@gmail.com'

subject = 'hello world!'
content = 'this is my test e-mail'

message = 'From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s'%(fromaddr, toaddrs, subject, content)

server = smtplib.SMTP(host)
server.sendmail(fromaddr, toaddrs, message)
server.quit()


Arevos Jul 7th, 2006 7:42 PM

Quite often the SMTP server is something like "mail.yourisp.com" or "smtp.yourisp.com". They'll have the address on their site somewhere, as any internet uses who wishes to send an email from a desktop email client (such as Outlook or Thunderbird) will need it.

Sane Jul 7th, 2006 8:13 PM

Yes! Thank-you! A quick google revealed it was 'smtp1.sympatico.ca'. It works too. Thank-you for your help.

To anyone, would you know of any strategies for protecting your e-mails from appearing as spam? I know using a valid source address is one thing. Any helpful advice to moderating the actual content or method of sending?

Arevos Jul 8th, 2006 7:33 AM

Quote:

Originally Posted by Sane
To anyone, would you know of any strategies for protecting your e-mails from appearing as spam? I know using a valid source address is one thing. Any helpful advice to moderating the actual content or method of sending?

The only thing I can think of is to remove all words in your emails that might commonly be mostly found in spam. Other than that, there isn't any other way; any change you make to the email's headers can be replicated by a spammer.

I suppose you have a header that all your recipients are expecting, and that is unlikely to be found on spam. For instance, mailing lists often add their name to the subjects of emails sent to them. The recipients, therefore, can be reasonably certain that any email with "[my-mailing-list]" in the subject, are not spam. Of course, this assumes the recipients have some measure of control over their spam filtering systems.


All times are GMT -5. The time now is 12:50 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC