How can I connect with strophejs using an email address as a user name. - xmpp

I am able to connect successfully to Open fire using strophe, unfortunately, when a users username is in the format of an email, the connection incorrectly uses everything that is after the first # symbol as the domain. Then the connection does not work.
Is this a bug or is this something that can be done differently (e.g by using some format to specify the domain some other way).
Thanks

Call Strophe.escapeNode(string to escape) before sending the username/jid to the server.
var jid = Strophe.escapeNode(foo#domain.com) + '#jabberserver.com';

Related

How to recieve email from Contact Us from written with Flask

I just created a Contact Us form using Flask. The code seems to work correclty as explained in many tutorials like this one: link.
The reason why it all works it is because at the beginning of the app file I need to insert the username and password of the person who is sending the mail (in this case it's me) through the form:
mail = Mail()
app.config["MAIL_SERVER"] = "smtp.gmail.com"
app.config["MAIL_PORT"] = 465
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = 'my_personal_email0#gmail.com'
app.config["MAIL_PASSWORD"] = 'my_personal_password'
mail.init_app(app)
However once my website will be hosted online in some server, whoever wants to contact me trhough the form will just have the option to insert his email in the form and of course no password. Here it is what it looks like:
                               
Would you be able to explain how this situation is handle once I host the website in some server? Is there something wrong with my logic?
You can do 2 things here
You need to store the details in the database and make an admin panel to view the details from the database
Create a fake Gmail and let that Gmail send you the users name, email subject, and message
I personally prefer the 1st option

How to create a JID from the Username

I've been running the echo.html example that comes with Strophe.js. When I start it up I sign in using a user I made called user1. When I click the connect button I get the following output:
Strophe is connecting.
Strophe is connected.
ECHOBOT: Send a message to 5ee09j8v8y#ubuntu/5ee09j8v8y to talk to me.
I am able to successfully test this example using the Gajim client. In Gajim I simply start a new chat using the above JID (5ee09j8v8y#ubuntu/5ee09j8v8y). When I send a message using Gajim it shows up on the echobot example and everything is hunky dory.
So here's my question, I see from this official site that the JID is in this format:
<JID> ::= [<node>"#"]<domain>["/"<resource>]
And I get that the resource is optional, and that the domain in my case above is simply my computer's name (my computer's name is ubuntu). BUT what I don't get is how the heck you get 5ee09j8v8y from the username user1.
The code inside echobot.js which prints the JID line above uses this command to get the information:
connection.jid
Which is just a Strophe.Connection Object retrieving it's JID.
So to sum all of this up, I cannot communicate from Gajim using user1#ubuntu/5ee09j8v8y the only way it works is when I use the JID 5ee09j8v8y#ubuntu/5ee09j8v8y. So what exactly is the node (5ee09j8v8y), how does it get mapped to the username (user1), how can I get Gajim to work with user1#ubuntu/5ee09j8v8y instead of using 5ee09j8v8y#ubuntu/5ee09j8v8y and at the very least can someone point me in the right direction to some documentation on this JID problem?
Note: This tutorial will explain my setup (and help others who are curious in how I set all of this up).

Apache Commons Email work with "normal gmail", but not "Gmail for work"?

Hi I'm using the following code to send email:
public static void sendEmail(String from, String to, String password) {
Email email = new SimpleEmail();
email.setHostName("smtp.googlemail.com");
email.setSmtpPort(465);
email.setAuthenticator(new DefaultAuthenticator(from, password));
email.setSSLOnConnect(true);
email.setSubject("Plain mail");
email.setMsg("test");
email.addTo(to);
email.send();
}
Now, it works when I'm calling this function with my "normal" gmail address:
sendMail("me#gmail.com","friend#gmail.com", "my-password");
So the above works. But when I'm trying to migrate to Gmail for Business, and create an email address "me#mycompany.com" (which is hooked to Gmail), I get an authentication error:
sendMail("me#mycompany.com","friend#gmail.com", "my-new-password");
Gives me this error:
javax.mail.AuthenticationFailedException:
<https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsb...ZlTLN2wQG4>
Please log in via your web browser and then try again.
I suspect I need to set something in my Google Apps console, but I'm not even sure where to start looking for the info.
Can anybody help?
Thanks.
This answer is coming from a similar SO question here.
The issue is due to allowing less secure apps to access your account. Click the following link https://www.google.com/settings/security/lesssecureapps and disable security setting. For more information you can read this here.
Good luck!

IMAP "Invalid Credentials" via GMail XOAUTH

I'm trying to get into the IMAP server with OAuth, using the PHP Sample Code provided by Google which uses the Zend Imap class but I am failing to authenticate. Zend is giving me the error:
Zend_Mail_Storage_Exception [ Error ]: cannot select INBOX, is this a valid transport?
Annoyingly this is a rather confusing error message, for what is essentially "Invalid Credentials". How did I know that? By debugging the actual commands being send to the IMAP socket I see this:
string(44) "NO Invalid credentials ey9if1544983wid.142
"
I have tried with telnet and a Ruby gmail_xoauth gem which suggests it is not a code issue, but something else.
Looking at the most basic level of all this, I am getting commands like this:
TAG1 AUTHENTICATE XOAUTH R0VUIGh0dHBzOi8vbWFpbC5nb29nbGUuY29tL21h......etc
This is where I get NO Invalid credentials then:
TAG2 SELECT "INBOX"
This returns BAD Unknown command and kicks me out.
I have tried searching around for people having the same problem but I find only questions and no answers. There are a few similar StackOverflow questions:
One post shows somebody having the exact same problem in Python.
This post shows somebody trying to be awkward and do it with OAuth 2, with no report of success.
There is a thread on the GMail Google Group that suggests an "Invalid Credentials" error can be resolved by going to https://accounts.google.com/DisplayUnlockCaptcha for GMail accounts and https://www.google.com/a/[YOURDOMAIN.COM]/UnlockCaptcha if you are using Google Apps, but the latter just said that my username and password were wrong when they clearly were not. Using this https://accounts.google.com/DisplayUnlockCaptcha worked fine - even though my account is a hosted App, not plain old GMail - however I still get the same errors when trying to log back in with the PHP sample code provided by Google.
I've tried with various hosted Google App accounts and a plain GMail account. I've tried switching the IMAP server from imap.gmail.com to imap.googlemail.com, nothing makes any difference.
/**
* Make the IMAP connection and send the auth request
*/
$imap = new Zend_Mail_Protocol_Imap('imap.googlemail.com', '993', true);
$authenticateParams = array('XOAUTH', $initClientRequestEncoded);
$imap->requestAndResponse('AUTHENTICATE', $authenticateParams);
/**
* Print the INBOX message count and the subject of all messages
* in the INBOX
*/
$storage = new Zend_Mail_Storage_Imap($imap);
echo '<h1>Total messages: ' . $storage->countMessages() . "</h1>\n";
For those with an interest, this is the specific PHP code that sets up the connection, all XOauth is handled by Google's PHP in the same file but I skipped it.
I had this exact same error, and eventually realised I was using the wrong scope when requesting the OAuth permissions.
You need to have...
scope=https://mail.google.com/
access_type=offline
And also IMAP enabled in your Gmail account obviously. All seems good now.
One problem you may have is that the third parameter of Zend_Mail_Protocol_Imap('imap.googlemail.com', '993', true); should not be true. It should be a string, as either "SSL" or "TLS". I believe you want "SSL" if going over port 993. It's only a boolean when it is FALSE.
Try replacing that first line with this:
$imap = new Zend_Mail_Protocol_Imap('imap.googlemail.com', '993', 'SSL');
When i had this same error message, it was because
$options['consumerSecret'] = $THREE_LEGGED_CONSUMER_SECRET_HMAC;
I was doing that in a function and variable $THREE_LEGGED... wasn't in the scope. Pretty stupid and i'm sure that you'd have spotted that but just in case somebody new is reading that.

Configurating JOOMLA's e-mail notification for new account

I'm using Joomla 1.5 to create a local site for my office. The site will be accessed locally via intranet, and my PC will be the localhost for the site.
I'm using a Login pluggin, so that anyone who wanted to enter the site should create an account.
In JOOMLA, all user who created their account for the first time will receive a notification e-mail like :
"Hello pras,
You have been added as a User to Information Center by an
Administrator.
This e-mail contains your username and password to log in to
http://localhost/yaddayadda/
Username: hadisuryo.prasetio Password: xxxx
Please do not respond to this message as it is automatically generated
and is for information purposes only."
but if the user click the URL in the mail, which is, "localhost/yaddayadda/" they will not be directed to my site, but to their own PC's localhost....
My question is : How can I Modified the e-mail or the site configuration so that the URL will not be "localhost/yaddayadda/" anymore, but will be "(My-IP address)/yaddayadda"
I'm not going to host my site to a web hosting service, just using my PC as a host.
I've been trying to trace on each config and .ini files...it seems that i have to do something with the "JURI" function or the "$mosConfig_live_site" on the backlink.php file
$mosConfig_absolute_path = JPATH_SITE;
$mosConfig_live_site = JURI :: base();
$url_array = explode('/', $_SERVER['REQUEST_URI']);
Can anyone give me assistance ?
actually what the joomla does it takes the value as $_SERVER for the host so what you have to do u just append "/yaddayadda" at the email template of the joomla
You could edit:
%SITE_ROOT%/administrator/language/en-GB.com_users.ini at around LINE 28, which reads
NEW_USER_MESSAGE=Hello %s,\n\n\nYou have been added as a User to %s by an Administrator.\n\nThis e-mail contains your username and password to log in to %s\n\nUsername: %s\nPassword: %s\n\n\nPlease do not respond to this message as it is automatically generated and is for information purposes only.
Be careful with the '%s' variable as it appears to insert different values in each instance. First instance renders their NAME, second SITE NAME, third one is the USER NAME, etc, etc.
-Dennis
You can find those values in root/components/com_users/models/registration.php on line 88. It appears it pulls it out of the array that is being created their.