I'm currently setting up email verification for my website that is working with google app engine. I want the users to click a verification link and I would also like to style the email a little using html and css.
So I have my python script all set up. And I have a mail objekt and I do this:
mail.send_mail(sender="...",
to=".....",
subject="Verification Mail"
body="""
Dear ....
Thanks for signing up on example.com
Please click the link below to verify your email adress.
http://example.com/verifymail?email="""+adress+""""&hash="""+hash+"""
We hope you enjoy our platform.
""")
Now this works perfectly fine.
But what I would like is to place an anchor tag inside my mail like
<a href='http://example.com/verifymail?email="""+adress+""""&hash="""+hash+"""'>Verify Email</a>
But doing that will literally print out the html source inside the mail, instead of understanding this as HTML. (It correctly fills in the variables btw). I would also like to add some more things to the newsletter but I guess getting it to understand the tags at all would solve all my problems.
Is there any solution to this?
The reason that your email is interpreted as plain text instead of HTML is that body is interpreted as plain text.
In order for your content to be interpreted as HTML, you will need to set the html attribute as the HTML version of the email, i.e. add something like html="<h3>Hello World</h3>". Check the official API for reference: https://cloud.google.com/appengine/docs/python/refdocs/google.appengine.api.mail
More background about content type: some email clients cannot interpret HTML messages, so usually both HTML and plain text version are sent to the user to guarantee compatibility. That's why an email has both "plain text" and "HTML" fields.
Related
In a Djano project, I need to get the complete URL of my web app in a view, along with the URL's anchor tag. For instance, if the URL is:
http://example.com/#section0
I need to get that in its entirely, including the #section0 part. As you'd already know, HTTP_REFERER doesn't suffice (which is what I've tried).
What's a good way to read URLs in python/django? Beginner here, please advise.
Sorry, but the anchor tag is never sent to the server. The only way a server could know what it was is if the server itself sent the user to a url with the anchor tag.
See here for more information:
Is the anchor part of a URL being sent to a web server?
We are using Google Docs as a Email template resource in one of our application.
We have n number of templates for different different emails.
When the mail is to be sent, what we do is:
Get the html content of that particular template using Google Drive api.
Send that html content in Email using GMail api.
Now the problem is, the some of html attributes changes automatically when person receives email eg. the bold/italics/underline, fonts are replaced by the default fonts of Google Mail.
I have created a sample email template here. You can try playing with it.
Have anyone came across such problem ?
Is there any other alternative to accomplish ?
I tried using newly released Inbox api to sort out and tag my mails, but I am stuck at categorising mails after I had successfully logged in using api.
I am not quite sure where exactly you are struck , but please refer to the following document https://www.inboxsdk.com/docs/#ComposeView though it is documented in javascript
I've been searching for a good hour or two for this but I haven't found anything to what I'm looking for.
I'm making a chat application( socket server made in Python ) and it's working fine. The main chat area where messages are stored use HTML, it just displays the username in bold along with their avatar and message. The problem I'm having is how do I stop the user from entering HTML and messing with the main chat? I'm currently using regex "/<.*?>/g" to remove HTML tags however I'd rather let the user send things like
<p>Hi everyone</p>
but instead of parsing what was sent as HTML just normal text?
For example, right now. While a user is typing I'm using regex to remove
<whatever>
tags as soon as they're typed. What I want is for the user to be able to type
<b>bold text</b>
and send but not display it as bold and show the b tags.
Here's what "mainChat" text box looks like http://prntscr.com/46hd4t, this stores all messages
Here's what "chatMessage" text box looks like http://prntscr.com/46hdc6, this is where the user writes their message
Sites such as reddit and Stack Overflow use a standard called markdown for editing text that takes care of these issues. Some popular options for markdown editors include WMD, markitup and Epic Editor. Just Google markdown there are many options to choose from.
The goal here, given a user facebook profile url, access and open the profile page. Some simple python code:
from urllib2 import urlopen
url = "http://www.facebook.com/username"
page = urlopen(url)
The problem is that for some "username" this causes HTTP ERROR 404. I noticed this error only happening when the path includes a name rather than the "profile.php?id=XXX" format.
Notice that we only have the url here and not the user id.
UPDATE:
This turned out to happen also for some of the "profile.php?id=XXX" and other username formats.
This is a privacy feature of Facebook. Users have the ability to hide their profile page so that only logged in users can view their page. Accessing the page with /profile.php?id=XXX or with /username makes no difference. You must be logged-in in order to view the HTML page.
In your context, you'd have to first log in to a valid Facebook account before requesting the page and you should no longer receive the 404's.
One way to check this is on the graph API, graph.facebook.com/USERNAME will return a link property in the resulting JSON if they have a public page, and it will be omitted on private pages.
Not every Facebook account is accessible as FIRST.LAST, so you won't be able to reliably do this.
There is currently no guarantee that an account is accessible with a vanity name.
Works perfectly fine as long as the username exists.
Are you trying to open the page in a Web Browser or access the HTML source generated by the page?
If the latter, have you thought of using the Facebook Graph API to achieve whatever it is that you are doing? This will be much faster and the API is all documented. Plus the page's HTML source could change at any point in time, whereas the Graph API will not.
Edit
You could use the Graph API without having to even create an application to get the user ID, but going to http://graph.facebook.com/username and parsing the JSON response. You can then access the profile HTML using http://www.facebook.com/profile.php?id=userId