I write the following code in test.php
<?php
require_once 'Zend/Mail.php';
require_once 'Zend/Mail/Transport/Smtp.php';
$subject="send my email from qq to 163";
$mailbody='stay hungry stay foolish';
$envelope='2546606474#qq.com';
$config = array('auth' => 'login',
'username' => '2546606474',
'password' => 'XXXXXXXXXXX');
$transport = new Zend_Mail_Transport_Smtp('smtp.qq.com',$config);
$mail = new Zend_Mail('GBK');
$mail->setBodyHtml($mailbody);
$mail->setFrom($envelope, '2546606474');
$mail->addTo('kanonwind#163.com','kanonwind');
$mail->setSubject('we create future with our hands');
$mail->send($transport);
?>
I test in localhost and I successfully get an email from 2546606474#qq.com
then I upload the files to my to my web to test,mistakes occur:
Fatal error: Uncaught exception 'Zend_Mail_Protocol_Exception' with message 'Connection timed
out' in /home/u629656826/public_html/mr2/Zend/Mail/Protocol/Abstract.php:277
Stack trace:
#0 /home/u629656826/public_html/mr2/Zend/Mail/Protocol/Smtp.php(167):
Zend_Mail_Protocol_Abstract->_connect('tcp://smtp.qq.c...')
#1 /home/u629656826/public_html/mr2/Zend/Mail/Transport/Smtp.php(199): Zend_Mail_Protocol_Smtp- >connect()
#2 /home/u629656826/public_html/mr2/Zend/Mail/Transport/Abstract.php(348):
Zend_Mail_Transport_Smtp->_sendMail()
#3 /home/u629656826/public_html/mr2/Zend/Mail.php(1194): Zend_Mail_Transport_Abstract->sen
(Object(Zend_Mail))
#4 /home/u629656826/public_html/mr2/test.php(21): Zend_Mail->send(Object
(Zend_Mail_Transport_Smtp))
#5 {main} thrown in /home/u629656826/public_html/mr2/Zend/Mail/Protocol/Abstract.php on line 277
I do not know how to solve the problems.
Related
Does anyone have any code about both getting and setting users OOF messages using Garethp/php-ews library by any chance?
(https://learn.microsoft.com/en-us/previous-versions/office/developer/exchange-server-2010/aa563465(v=exchg.140))
(https://learn.microsoft.com/en-us/previous-versions/office/developer/exchange-server-2010/aa493825(v=exchg.140))
I have tried the following
use garethp\ews\API\Type;
use garethp\ews\MailAPI;
use garethp\ews\API\Enumeration\DistinguishedFolderIdNameType;
use garethp\ews\API\Enumeration\UserConfigurationPropertyType;
use garethp\ews\API\Enumeration\GetUserOofSettingsRequestType;
$email = 'me#mycompany.com';
$host = 'myexchserver'; $username = 'myusername'; $password = 'mypassword';
$api = MailAPI::withUsernameAndPassword($host,$username,$password,["version" => 'Exchange2010_SP1', 'impersonation' => $email]);
$response = $api->getClient()->GetUserOofSettingsRequest(['Address' => 'someuser#mycompany.com']);
But get the following error.
Fatal error: Uncaught SoapFault exception: [Client] Function ("GetUserOofSettingsRequest") is not a valid method for this service in /Scripts/vendor/garethp/php-ews/src/API/NTLMSoapClient.php:119 Stack trace: #0 /Scripts/vendor/garethp/php-ews/src/API/NTLMSoapClient.php(119): SoapClient->__call() #1 /Scripts/vendor/garethp/php-ews/src/API/ExchangeWebServices/MiddlewareFactory.php(18): garethp\ews\API\NTLMSoapClient->__call() #2 /Scripts/vendor/garethp/php-ews/src/API/ExchangeWebServices.php(510): garethp\ews\API\ExchangeWebServices->garethp\ews\API\ExchangeWebServices\{closure}() #3 /Scripts/vendor/garethp/php-ews/src/API/ExchangeWebServices/MiddlewareFactory.php(32): garethp\ews\API\ExchangeWebServices->garethp\ews\API\{closure}() #4 /Scripts/vendor/garethp/php-ews/src/API/ExchangeWebServices.php(510): garethp\ews\API\ExchangeWebServices->garethp\ews\API\ExchangeWebServices\{closure}() #5 /Scripts/vendor/garethp/php-ews/src/API/ExchangeWebServices/MiddlewareFactory.php(48): garethp\ews\API\ExchangeWebServices->garethp\ew in /Scripts/vendor/garethp/php-ews/src/API/NTLMSoapClient.php on line 119
Thanks
i have some problems with the soap client and soap server.
server.php on server side
class Server {
public function hello($someone) {
return "Hello ". $someone;
}
}
$options= array('uri'=>'http://localhost/');
$server=new SoapServer(NULL, $options);
$server->setClass('Server');
$server->handle();
index.php on client side
<?php
$options = array('location' => 'http://localhost/server.php',
'uri' =>'http://localhost/');
$client = new SoapClient(NULL, $options);
echo $client->hello('Greg');
I'm testing this local on xampp and get the Error:
What do i make wrong ? Can i test it localy or do i have to set up a server for this. If yes, is it possible to run this on IIS ?
Fatal error: Uncaught SoapFault exception: [HTTP] Not Found in
C:\xampp\htdocs\SOAP\index.php:8 Stack trace: #0 [internal function]:
SoapClient->__doRequest('http://localhos...',
'http://localhos...', 1, 0) #1 C:\xampp\htdocs\SOAP\index.php(8):
SoapClient->__call('hello', Array) #2
C:\xampp\htdocs\SOAP\index.php(8): SoapClient->hello('Greg') #3 {main}
thrown in C:\xampp\htdocs\SOAP\index.php on line 8
I am trying to utilize in php uploading a file using box view api. I am using the library from box-view-api GitHub
Here is my code:
<?php
require_once('repository_fns.php');
require 'lib/box-view-api.php';
require 'lib/box-view-document.php';
session_start();
$objid=$_GET['objid'];
$object_general=get_obj_general($objid);
$object_rights=get_obj_rights($objid);
$object_lifecycle=get_obj_lifecycle($objid);
$object_tech=get_obj_tech($objid);
do_html_header('', 'browse.css');
display_object_metadata($object_general, $object_rights, $object_lifecycle, $object_tech);
$api_key = 'MY_KEY';
$box = new Box_View_API($api_key);
$doc = new Box_View_Document(array(
'name' => 'Geology of Canada',
'file_path' => '/uploads/Geology of Canada.docx',
));
$box->upload($doc);
display_file_page();
do_html_footer();
?>
But why am I getting an error message:
Fatal error: Uncaught exception 'Box_View_Exception' with message 'couldn't open file "/uploads/Geology of Canada.docx"' in /home/ychenlucs15/public_html/lib/box-view-api.php:241 Stack trace: #0 /home/ychenlucs15/public_html/lib/box-view-api.php(456): Box_View_API->httpRequest(Array) #1 /home/ychenlucs15/public_html/show_object.php(28): Box_View_API->upload(Object(Box_View_Document)) #2 {main} thrown in /home/ychenlucs15/public_html/lib/box-view-api.php on line 241
Can someone show me how to implement it correctly with php? Thank you in advance.
I have been struggling to write a PHP script that will reboot a server using the 1.6.0 version of the Rackspace API (I can't install Composer on my server needed for 1.7.0). Unfortunately it does not want to recognize my credentials and keeps throwing this error:
Fatal error: Uncaught exception 'OpenCloud\Common\Exceptions\CredentialError' with message 'Unrecognized credential secret' in /home/sandbox/public_html/rackspaceapi/lib/OpenCloud/OpenStack.php:694 Stack trace: #0 /home/sandbox/public_html/rackspaceapi/lib/OpenCloud/Rackspace.php(66): OpenCloud\OpenStack->credentials() #1 /home/sandbox/public_html/rackspaceapi/lib/OpenCloud/OpenStack.php(714): OpenCloud\Rackspace->Credentials() #2 /home/sandbox/public_html/rackspaceapi/lib/OpenCloud/OpenStack.php(591): OpenCloud\OpenStack->authenticate() #3 /home/sandbox/public_html/rackspaceapi/lib/OpenCloud/OpenStack.php(652): OpenCloud\OpenStack->checkExpiration() #4 /home/sandbox/public_html/rackspaceapi/lib/OpenCloud/Common/Service.php(337): OpenCloud\OpenStack->serviceCatalog() #5 /home/sandbox/public_html/rackspaceapi/lib/OpenCloud/Common/Service.php(68): OpenCloud\Common\Service->getEndpoint('compute', 'cloudServersOpe...', 'ORD', 'publicURL') #6 /home/sandbox/public_html/rackspaceapi/lib/OpenCloud/ in /home/sandbox/public_html/rackspaceapi/lib/OpenCloud/OpenStack.php on line 694
Here is my PHP script (I did not include my credentials)
require_once "php-opencloud.php";
// The AUTHURL used for the US was: https://identity.api.rackspacecloud.com/v2.0/
putenv("RAX_USERNAME=$username");
putenv("RAX_API_KEY=$apikey");
putenv("RAX_TENANT_NAME=$tenantname");
putenv("RAX_AUTH_URL=$authurl");
define('USERNAME', $_ENV['RAX_USERNAME']);
define('APIKEY', $_ENV['RAX_API_KEY']);
define('TENANT', $_ENV['RAX_TENANT_NAME']);
define('AUTHURL', 'RAX_AUTH_URL');
$rackspace = new \OpenCloud\Rackspace(AUTHURL,
array( 'username' => USERNAME,
'apiKey' => APIKEY ));
$cservers = $rackspace->Compute('cloudServersOpenStack', 'ORD');
$list = $cservers->ServerList();
while($server = $list->Next()) {
if ($server->name == 'My_Server')
$server->Reboot('hard');
}
echo "Reboot sequence complete.";
Any help anyone can offer would be greatly appreciated.
<?php
require_once '../plugin/swift/lib/swift_required.php';
// Create the Transport
$transport = Swift_SmtpTransport::newInstance('pod51003.outlook.com',587,'tls')
->setUsername('user#connect.polyu.hk')
->setPassword('pw')
;
// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
// Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('john#doe.com' => 'John Doe'))
->setTo(array('foodil#hotmail.com', 'foodil#yahoo.com.hk' => 'A name'))
->setBody('Here is the message itself')
;
// Send the message
$result = $mailer->send($message);
printf("Sent %d messages\n", $result);
?>
It turned out:
Fatal error: Uncaught exception 'Swift_TransportException'
with message 'Expected response code 250 but got code "501", with message "501 5.5.4 Invalid domain name "'
in C:\xampp\htdocs\fyp\plugin\swift\lib\classes\Swift\Transport\AbstractSmtpTransport.php:422
Stack trace:
#0 C:\xampp\htdocs\fyp\plugin\swift\lib\classes\Swift\Transport\AbstractSmtpTransport.php(306): Swift_Transport_AbstractSmtpTransport->_assertResponseCode('501 5.5.4 Inval...', Array)
#1 C:\xampp\htdocs\fyp\plugin\swift\lib\classes\Swift\Transport\EsmtpTransport.php(224): Swift_Transport_AbstractSmtpTransport->executeCommand('HELO [::1]??', Array, Array)
#2 C:\xampp\htdocs\fyp\plugin\swift\lib\classes\Swift\Transport\AbstractSmtpTransport.php(323): Swift_Transport_EsmtpTransport->executeCommand('HELO [::1]??', Array)
#3 C:\xampp\htdocs\fyp\plugin\swift\lib\classes\Swift\Transport\EsmtpTransport.php(272): Swift_Transport_AbstractSmtpTransport->_doHeloCommand()
#4 C:\xampp\htdocs\fyp\plugin\swift\lib\classes\Swift\Transport\AbstractSmtpTransport.php(124) in C:\xampp\htdocs\fyp\plugin\swift\lib\classes\Swift\Transport\AbstractSmtpTransport.php on line 422
Actually I follow the tutorial straightly, so is that any thing I omitted in my code? The SMTP server information is valid.
External SMTP setting:
Server name: pod51003.outlook.com - you can also see the note below on how to determine the server name
Port: 587
Encryption method: TLS
after adding the line: there is another error:
Warning: stream_socket_enable_crypto() [streams.crypto]: this stream does not support SSL/crypto in C:\xampp\htdocs\fyp\plugin\swift\lib\classes\Swift\Transport\StreamBuffer.php on line 102
Fatal error: Uncaught exception 'Swift_TransportException'
with message 'Unable to connect with TLS encryption'
in C:\xampp\htdocs\fyp\plugin\swift\lib\classes\Swift\Transport\EsmtpTransport.php:283
Stack trace:
#0 C:\xampp\htdocs\fyp\plugin\swift\lib\classes\Swift\Transport\AbstractSmtpTransport.php(124): Swift_Transport_EsmtpTransport->_doHeloCommand()
#1 C:\xampp\htdocs\fyp\plugin\swift\lib\classes\Swift\Mailer.php(79): Swift_Transport_AbstractSmtpTransport->start()
#2 C:\xampp\htdocs\fyp\mail\send.php(26): Swift_Mailer->send(Object(Swift_Message))
#3 {main} thrown in C:\xampp\htdocs\fyp\plugin\swift\lib\classes\Swift\Transport\EsmtpTransport.php on line 283
Try adding this line here as shown:
// Create the Transport
$transport = Swift_SmtpTransport::newInstance('pod51003.outlook.com',587,'tls')
->setUsername('user#connect.polyu.hk')
->setPassword('pw')
;
// ADD THIS LINE
$transport->setLocalDomain('[127.0.0.1]');
// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
I'm guessing your SMTP server doesn't like/understand IPv6, based on the response you are getting to the HELO command.