How can we register user in openfire via strophe? I am using registration plugin in openfire.it is working fine.I am using "test" username.
But When i tried connect with openfire fron custom.js like.
var BOSH_SERVICE = '/xmpp-httpbind'
connection = new Strophe.Connection(BOSH_SERVICE);
log(connection);
connection.rawInput = rawInput;
connection.rawOutput = rawOutput;
connection.connect('admin','admin',onConnect);
Response
Object { service="/xmpp-httpbind", rid=4209744652, do_session=false, more...} gab.js (line 6)
Strophe is connecting. gab.js (line 6)
SENT: <body rid='4209744652' xmlns='http://jabber.org/protocol/httpbind' to='admin' xml:lang='en' wait='60' hold='1' content='text/xml; charset=utf-8' ver='1.6' xmpp:version='1.0' xmlns:xmpp='urn:xmpp:xbosh'/>gab.js (line 6)
"NetworkError: 500 Internal Server Error - http://localhost/xmpp-httpbind"
Error: 16, ioError, An error occured preventing completion of the request.....throwUnhandledError=function(O){throw new B.Error(O)};G.error=function(R,P,Q,O)...
Related
I am trying to send a custom IQ to ejabberd server from android app and I have this following class
public class IQCustom extends IQ {
public final static String childElementName = "query";
public final static String childElementNamespace = "jabber:iq:conversations";
public IQCustom(String userFrom, String server)
{
super( childElementName, childElementNamespace );
this.setType(Type.get);
setTo( server );
setFrom( userFrom );
}
#Override
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
xml.rightAngleBracket();
xml.halfOpenElement("abc");
xml.attribute("op","sum");
xml.rightAngleBracket();
xml.closeElement("abc");
return xml;
}
}
and these are the IQ logs I am getting:
D/SMACK: SENT (1): <iq to=‘example.com' id='BQ8wt-16' type='get'><query xmlns='jabber:iq:conversations'><abc op='sum'></abc></query></iq>
D/SMACK: RECV (1): <iq to='testing7#example.com/Smack' from='example.com' type='get' id='BQ8wt-16'><query xmlns='jabber:iq:conversations'><abc op='sum'/></query></iq>
D/SMACK: RECV (1): <r xmlns='urn:xmpp:sm:3'/>
D/SMACK: SENT (1): <iq to='example.com' id='BQ8wt-16' type='error'><error type='cancel'><feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>
D/SMACK: SENT (1): <r xmlns='urn:xmpp:sm:3'/>
D/SMACK: SENT (1): <a xmlns='urn:xmpp:sm:3' h='4'/>
D/SMACK: RECV (1): <a h='5' xmlns='urn:xmpp:sm:3'/>
I understood the reason of first receive iq that I getting but I didn’t understand the reason for the iq:
D/SMACK: SENT (1): <iq to='example.com' id='BQ8wt-16' type='error'><error type='cancel'><feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>
EDIT
This is the module which is supposed to act when I send the above query:
-module(mod_conversations).
-behaviour(gen_mod).
%% ====================================================================
%% API functions
%% ====================================================================
-export([start/2, stop/1, process_local_iq/3]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").
-define(NS_IQ_CUSTOM, <<"jabber:iq:conversations">>).
start(Host, _) ->
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_IQ_CUSTOM, ?MODULE, process_local_iq, one_queue),
?INFO_MSG("Inside mod_conversation",[]),
ok.
stop(Host) ->
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_IQ_CUSTOM),
ok.
process_local_iq(From,_ ,IQ) ->
From,
?INFO_MSG("Inside mod_conversation, IQ is ~p~n ",[IQ]),
Sum = 2+2,
IQ.
And Inside gen_iq_handler() I saw that handler were already registered, So I am confused now that what does implementing the feature mean.
I only want to send the value of Sum in a responding iq to the client, for that how exactly should I register this feature and how can i send a iq response from this module to the client/user without any error iq's?
Have you implemented the feature with ns xmpp-stanzas?
I've tried a bunch of alterations to my code but with no effect. The code itself does not return any errors but instead gives a success message. I am using gmail as my relay.
P.S, I commented out $mail->IsSMTP(); because I saw a similar question here that used it as a fix, I was getting an "smtp failed to connect" error.
I am using PHPmailer 6.0.
Here is my code:
<?php
require_once('vendor/autoload.php');
define('GUSER', 'example#gmail.com'); // GMail username
define('GPWD', '*********'); // GMail password
function smtpmailer($to, $from, $from_name, $subject, $body) {
global $error;
$mail = new PHPMailer\PHPMailer\PHPMailer(true); // create a new object
//$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 4; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'tls'; // secure transfer enabled REQUIRED for GMail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = GUSER;
$mail->Password = GPWD;
$mail->SetFrom($from, $from_name);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to);
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
return false;
} else {
$error = 'Message sent!';
return true;
}
}
smtpmailer('to#mail.com', 'from#mail.com', 'yourName', 'test mail message', 'Hello World!');
if (smtpmailer('to#mail.com', 'from#mail.com', 'yourName', 'test mail message', 'Hello World!')) {
// do something
}
if (!empty($error)) echo $error;
?>
If I uncomment $mail->IsSMTP(); I get this error log:
2017-12-27 07:58:54 Connection: opening to smtp.gmail.com:465, timeout=300, options=array()
2017-12-27 07:58:54 Connection failed. Error #2: stream_socket_client(): unable to connect to smtp.gmail.com:465 (Network is unreachable) [/srv/disk2/2564570/www/consorttest.dx.am/vendor/phpmailer/phpmailer/src/SMTP.php line 325]
2017-12-27 07:58:54 SMTP ERROR: Failed to connect to server: Network is unreachable (101)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Fatal error: Uncaught PHPMailer\PHPMailer\Exception: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting in /srv/disk2/2564570/www/consorttest.dx.am/vendor/phpmailer/phpmailer/src/PHPMailer.php:1726 Stack trace: #0 /srv/disk2/2564570/www/consorttest.dx.am/vendor/phpmailer/phpmailer/src/PHPMailer.php(1481): PHPMailer\PHPMailer\PHPMailer->smtpSend('Date: Wed, 27 D...', 'Hello World!\r\n') #1 /srv/disk2/2564570/www/consorttest.dx.am/vendor/phpmailer/phpmailer/src/PHPMailer.php(1320): PHPMailer\PHPMailer\PHPMailer->postSend() #2 /srv/disk2/2564570/www/consorttest.dx.am/mailtest.php(23): PHPMailer\PHPMailer\PHPMailer->send() #3 /srv/disk2/2564570/www/consorttest.dx.am/mailtest.php(32): smtpmailer('to#mail.com', 'from#mail.com', 'yourName', 'test mail messa...', 'Hello World!') #4 {main} thrown in /srv/disk2/2564570/www/consorttest.dx.am/vendor/phpmailer/phpmailer/src/PHPMailer.php on line 1726
You're not "using gmail as your relay" if you comment out isSMTP() because then it's not using SMTP at all, and will ignore all your SMTP settings. You're sending via your local mail server using PHP's built-in mail function.
When sending through gmail, you can't use arbitrary from addresses, though you can preset aliases in your gmail account.
You've based your code on a very old and obsolete example - use the gmail one provided with PHPMailer.
The most important part of the error output is: Network is unreachable - that probably means your ISP blocks outbound SMTP - are you by any chance using GoDaddy?
Next up, you have a basic misconfiguration: you're connecting to port 465 using SMTPSecure = 'tls', which means it will try to use SMTP+STARTTLS explicit TLS encryption, and that just won't work on port 465. This is a key reason to use the provided examples - they don't make basic errors like this.
Every one of these things is covered in the troubleshooting guide the error links to.
I am trying to send mail using PHPMailer but when i try i get error like
MEssage Could not be sent. SMTP connect() failed
When i debug the code, I got following message:
CLIENT -> SERVER: EHLO 127.0.0.1
CLIENT -> SERVER: AUTH LOGIN
CLIENT -> SERVER: dGFsYWFzaDIwMTdAc29jZXQuZWR1Lmlu
CLIENT -> SERVER: c29jZXRAMTIz
SMTP ERROR: Password command failed: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbt5534-5.7.14 V4dQliEGa4GCkfkxZoZVAX296_Q1jP9UHhiGXQShhTqxshYg2snLu2nKW4UIhB3k4X6Kqt534-5.7.14 Q6rvXHk5aNrXU22BwfYC_VVWeFwr8-216IZQmLpq0AA9NXNaQGQHeW1ZJNQGrvUBs6f8HQ534-5.7.14 OLspMG5dlPjNzvsAGG6lHHJ7eVYFFv8sZEYvxaAkvJR1zHk27qNpB1Gc5Ld32Fbs1SpC2H534-5.7.14 981OqnvjQrzYQCbcwIwVrqfjoVQPk> Please log in via your web browser and534-5.7.14 then try again.534-5.7.14 Learn more at534 5.7.14 https://support.google.com/mail/answer/78754 n79sm9364629pfj.31 - gsmtp
SMTP Error: Could not authenticate.
CLIENT -> SERVER: QUIT
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Below is the code which i have tried:
require '../phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP();
$mail->SMTPDebug = 1;
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->SMTPSecure = 'ssl';
$mail->SMTPAuth = true;
$mail->Username = 'mymail#gmail.com'; // SMTP username
$mail->Password = 'mypass';
$mail->setFrom('mymail#gmail.com', 'Mailer');
$mail->addAddress($user_email, $user_name);
$mail->Subject = 'Registration acknowledgment GTU Techfest Zone - 1';
$mail->Body = '<b>You have registerd for following events:</b>'."\r\n";
if(!$mail->send())
{
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
}
else
{
echo "unsuccessfull".mysql_error();
}
I have tried several solutions but its not working. I am working on localhost.I have also changed my xampp settings to send mail
From my localhost, i cannot send email using gmail account. I've Used php 7.0.9 and codeigniter. I wrote the code in controller is-
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = '25';
$config['smtp_user'] = 'xxx#gmail.com';
$config['smtp_pass'] = 'password';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['mailtype'] = 'html';
$config['wordwrap'] = TRUE;
$this->email->initialize($config);
$this->email->from('xxx#gmail.com');
$this->email->to('aaaa#yahoo.com');
$this->email->subject("Welcome to xx.");
$this->email->message('message body.....');
if ($this->email->send()) {
$data['success'] = 1;
} else {
$data['success'] = 0;
$data['error'] = $this->email->print_debugger(array('headers'));
}
echo "<pre>";
print_r($data);
echo "</pre>";
But I got the error
Array
(
[success] => 0
[error] => The following SMTP error was encountered: 0
Unable to send data: AUTH LOGIN
Failed to send AUTH LOGIN command. Error:
Unable to send data: MAIL FROM:
from:
The following SMTP error was encountered:
Unable to send data: RCPT TO:
to:
The following SMTP error was encountered:
Unable to send data: DATA
data:
The following SMTP error was encountered:
Unable to send data: User-Agent: CodeIgniter
Date: Wed, 26 Oct 2016 12:10:08 +0200
Anyone please give me suggestion about it.
i'm trying to send an email using phpmailer, it works fine on my laptop using xampp localhost server but when i tried to run the php class on my windows server 2008 with wamp installed on it it didn't work.
i already checked if the ssl is enabled from the php.ini
i'm getting this error:
2016-09-06 10:01:22 Connection: opening to smtp.mail.yahoo.com:587, timeout=300, options=array ( ) 2016-09-06 10:01:44 SMTP ERROR: Failed to connect to server: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060) 2016-09-06 10:01:44 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
here's my code:
SendOutlook();
function SendOutlook(){
//$recipient = 'alghomlas.dk#pg.com';
require 'PHPMailer/PHPMailerAutoload.php';
$Emp_recipient = "alghomlas.dk#pg.com";
$mail = new PHPMailer;
$mail->SMTPDebug = 4; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = "smtp.mail.yahoo.com"; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'xxxxxxxxx'; // SMTP username (server username)
$mail->Password = 'xxxxx'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('alghomlas.dk#yahoo.com', 'One');
$mail->addAddress($Emp_recipient,"dalal alghomlas"); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'test';
$mail->Body = "scheduled on your outlook calender";
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit();
}else {
echo '<p>Message has been sent</p>';
}
echo !extension_loaded('openssl')?"Not Available":"Available";
AddOutlookEvent($Mng_recipient, $Emp_recipient, $Mng_Name, $Emp_Name, $Date, $Time);
}