F
Ferrous Cranus
Hello,
i have written the following snipper of code to help me send mail:
=================================================================================================================
# if html form is submitted then send user mail
#================================================================================================================
if( mailform ):
try:
if (FROM is None) or (MESSAGE is None) or ('@' not in FROM) or
('ΓÏάψε μου εδώ' in MESSAGE):
print( "<h2><font color=red>ΣυμπλήÏωσε σωστά το mail σου
και δώσε το σχολιασμό σου!</font></h2>" )
else:
# prepare mail data
TO = "(e-mail address removed)"
SUBJECT = u"Mail από τον επισκÎπτη: ( %s )" % FROM
MESSAGE = "From: %s\r\n" + "To: %s\r\n" + "Subject: %s\r\n"
+ MESSAGE + "\r\n"
MESSAGE = MESSAGE % ( FROM, TO, SUBJECT )
MESSAGE = MESSAGE.encode('utf-8')
# open Gmail's SMTP server
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
# next, log in to the server
server.login("(e-mail address removed)", "rmrcdherpbsfggcw")
# send the mail
server.sendmail( FROM, [TO], MESSAGE )
print( "<h2><font color=blue>ΕυχαÏιστώ Ï€Î¿Î»Ï Î³Î¹Î± το
ενδιαφÎÏον! Θα επικοινωνήσω μαζί σου άμεσα </font></h2>" )
except Exception as e:
print( repr(e), file=open( '/tmp/err.out', 'a' ) )
sys.exit(0)
=======================================================================
It works as expected, but the the problem is that it display the FROM
part as being send from ,my personal GMail account when it supposed to
be shown the format variable field that was passed by index.html to the
mail.py script.
Si there a workaround for that please?
i have written the following snipper of code to help me send mail:
=================================================================================================================
# if html form is submitted then send user mail
#================================================================================================================
if( mailform ):
try:
if (FROM is None) or (MESSAGE is None) or ('@' not in FROM) or
('ΓÏάψε μου εδώ' in MESSAGE):
print( "<h2><font color=red>ΣυμπλήÏωσε σωστά το mail σου
και δώσε το σχολιασμό σου!</font></h2>" )
else:
# prepare mail data
TO = "(e-mail address removed)"
SUBJECT = u"Mail από τον επισκÎπτη: ( %s )" % FROM
MESSAGE = "From: %s\r\n" + "To: %s\r\n" + "Subject: %s\r\n"
+ MESSAGE + "\r\n"
MESSAGE = MESSAGE % ( FROM, TO, SUBJECT )
MESSAGE = MESSAGE.encode('utf-8')
# open Gmail's SMTP server
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
# next, log in to the server
server.login("(e-mail address removed)", "rmrcdherpbsfggcw")
# send the mail
server.sendmail( FROM, [TO], MESSAGE )
print( "<h2><font color=blue>ΕυχαÏιστώ Ï€Î¿Î»Ï Î³Î¹Î± το
ενδιαφÎÏον! Θα επικοινωνήσω μαζί σου άμεσα </font></h2>" )
except Exception as e:
print( repr(e), file=open( '/tmp/err.out', 'a' ) )
sys.exit(0)
=======================================================================
It works as expected, but the the problem is that it display the FROM
part as being send from ,my personal GMail account when it supposed to
be shown the format variable field that was passed by index.html to the
mail.py script.
Si there a workaround for that please?