PHP - Smtp -> Error: Failed To Connect To Server:
Have actually tried this mailer on localhost and it worked perfectly. Now am trying to use it on online but it's giving this error
SMTP-> ERROR: Failed to connect to server: Connection timed out (110)
SMTP -> ERROR: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP Host.
please how do i fix this?
include "classes/class.phpmailer.php"; // include the class name
$mail = new PHPMailer(); // create a new object $mail->IsSMTP(); // enable SMTP $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only $mail->SMTPAuth = true; // authentication enabled $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail $mail->Host = "smtp.gmail.com"; $mail->Port = 465; // or 587 $mail->IsHTML(true); $mail->Username = "hypropsict@gmail.com"; $mail->Password = "hyprops123"; $mail->SetFrom("hypropsict@gmail.com"); $mail->Subject = "Requisition Processed"; $mail->Body = "<b>Hello $firstname, your requisition has been processed and Approved.. <br/><br/>Come to the Account department to recieve your $text . <br/> Thank You </b>"; $mail->AddAddress($email); if(!$mail->Send()){ echo "Mailer Error: " . $mail->ErrorInfo; } Similar TutorialsFirstly I'd like to say a hello to everyone. OK, I'm having a problem with my PHPMailer setup. My aim is to have a registration email sent to a user upon sign up from (admin@mydomain.com). I have set up my mail servers set up correctly. so I can send/recieve mail from (admin@mydomain.com). I am using PHPMailer_v5.1, and am using the following code Code: [Select] <?php error_reporting(E_ALL); ini_set('display_errors', 1); require_once('../class.phpmailer.php'); $mail = new PHPMailer(); $body = file_get_contents('contents.html'); $body = eregi_replace("[\]",'',$body); $mail->IsSMTP(); $mail->Host = "admin@mydomain.com"; $mail->SMTPDebug = 1; $mail->SMTPAuth = true; $mail->SMTPSecure = "ssl"; $mail->Host = "admin@mydomain.com"; $mail->Port = 25; $mail->Username = "admin@mydomain.com"; $mail->Password = "*****"; $mail->SetFrom('admin@mydomain.com","My Domain'); $mail->AddReplyTo("admin@mydomain.com","My Domain"); $mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; $mail->MsgHTML($body); $address = "test@test.com"; $mail->AddAddress($address, "Test"); if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } ?> I set up a PHP document to test this mail feature, but every time I load it, it displays this SMTP -> ERROR: Failed to connect to server: (0) SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host. The PHPMailer is running on Elastiks (CentOS Linux 5.6). I cross checked the php.ini file and the OpenSSL is enabled. openssl OpenSSL support enabled OpenSSL Version OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008 Please help me out from these issue. Thanks for your time guys, hope someone can get back to me soon! Hi I am trying to send email through following php code to may gmail account but it givrs me SMTP Error: Could not connect to SMTP host.
*******************************************************************************************************************************************************
<?phpif(isset($_POST['submit'])){ $message='Full Name: '.$_POST['fullname'].'<br />Subject: '.$_POST['subject'].'<br />Phone: '.$_POST['phone'].'<br />Email: '.$_POST['emailid'].'<br />Comments: '.$_POST['comments'].''; require "phpmailer/class.phpmailer.php"; //include phpmailer class // Instantiate Class $mail = new PHPMailer(); // Set up SMTP $mail->IsSMTP(); // Sets up a SMTP connection $mail->SMTPAuth = true; // Connection with the SMTP does require authorization $mail->SMTPSecure = "ssl"; // Connect using a TLS connection $mail->Host = "smtp.gmail.com"; //Gmail SMTP server address $mail->Port = 465; //Gmail SMTP port $mail->Encoding = '7bit'; // Authentication $mail->Username = "myemail@gmail.com"; // Your full Gmail address $mail->Password = "mypassword"; // Your Gmail password // Compose $mail->SetFrom($_POST['emailid'], $_POST['fullname']); $mail->AddReplyTo($_POST['emailid'], $_POST['fullname']); $mail->Subject = "New Contact Form Enquiry"; // Subject (which isn't required) $mail->MsgHTML($message); // Send To $mail->AddAddress("myemail@gmail.com", "Recipient Name"); // Where to send it - Recipient $result = $mail->Send(); // Send! $message = $result ? 'Successfully Sent!' : 'Sending Failed!'; unset($mail); }?><html><head> <title>Contact Form</title></head><body> <div style="margin: 100px auto 0;width: 300px;"> <h3>Contact Form</h3> <form name="form1" id="form1" action="" method="post"> <fieldset> <input type="text" name="fullname" placeholder="Full Name" /> <br /> <input type="text" name="subject" placeholder="Subject" /> <br /> <input type="text" name="phone" placeholder="Phone" /> <br /> <input type="text" name="emailid" placeholder="Email" /> <br /> <textarea rows="4" cols="20" name="comments" placeholder="Comments"></textarea> <br /> <input type="submit" name="submit" value="Send" /> </fieldset> </form> <p><?php if(!empty($message)) echo $message; ?></p> </div> </body></html> Hi guys I am a newbie with PHP and I have been trying to solve this problem for 3 days.. Ive set up a booking form on my website to be sent directly to my email once the client clicked on the send button.. The problem I am having while checking these pages on wamp is that the booking form is ok but when I click on the send button the following message error appears "Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\fluffy_paws\booking_form2.php on line 27" When I check online I have this message "500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed." Are my codes wrong??? My webhosting is Blacknight.com , Im on Windows Vista, my internet is a dongle with O2 ireland Thanks for your help! I'm having a rough time getting an AS3 application working with a PHP script. The PHP script takes POST variables and then sends an email using SMTP. When running it through a standard HTML form, the PHP side works perfectly. However, when I send the exact same POST variables through AS3 to the script, I get this error. Failed to set sender: phpemailtesting@gmail.com [SMTP: Failed to write to socket: not connected (code: -1, response: )] So, I'm not really sure what the issue is here... Here's some code that might help. //print_r($_POST); require_once('Mail-1.2.0/Mail.php'); $from = isset($_POST['emailfrom']) ? $_POST['emailfrom'] : ''; $to = isset($_POST['emailsubject']) ? $_POST['emailto'] : ''; $bcc = isset($_POST['bcc'])? $_POST['bcc'] : ''; $subject = isset($_POST['emailsubject']) ? $_POST['emailsubject'] : ''; $body = isset($_POST['emailbody']) ? $_POST['emailbody'] : ''; $ssl = isset($_POST['ssl']) ? $_POST['ssl'].'://' : ''; $smtp_server = isset($_POST['smtpserver']) ? $_POST['smtpserver'] : ''; $password = isset($_POST['emailpassword']) ? $_POST['emailpassword'] : ''; $port = isset($_POST['port']) ? $_POST['port'] : ''; $success_counter = 0; $fail_counter = 0; $bigerror; if($from!='' && $to!='' && $subject!='' && $body!='' && $smtp_server!='' && $password!='' && $port!='') { if($bcc!='') { $bcc_array = explode(',',$bcc); } $host = $ssl . $smtp_server; $smtp = Mail::factory('smtp', array('host'=>$host, 'port'=>$port, 'auth'=>true, 'username'=>$from, 'password'=>$password)); $header = array('From'=>$from, 'To'=>$to, 'Subject'=>$subject); $mail = $smtp->send($to, $header, $body); if (PEAR::isError($mail)) { $bigerror = $mail->getMessage(); $fail_counter++; //echo("<p>Message failed".$to." :<br />" . $mail->getMessage() . "</p>"); } else { $success_counter++; //echo("<p>Message successfully sent to <b>". $to ."</b>!</p>"); } for($counter=0; $counter<count($bcc_array) && $counter<=99; $counter++) { $header = array('From'=>$from, 'To'=>$bcc_array[$counter], 'Subject'=>$subject); $mail = $smtp->send($bcc_array[$counter], $header, $body); if (PEAR::isError($mail)) { $bigerror = $mail->getMessage(); //echo("<p>Message failed".$bcc_array[$counter]." :<br />" . $mail->getMessage() . "</p>"); $fail_counter++; } else { //echo("<p>Message successfully sent to <b>". $bcc_array[$counter] ."</b>!</p>"); $success_counter++; } } //echo "<br /><br />Successful emails: " . $success_counter; //echo "<br />Failed emails: " . $fail_counter; echo $success_counter.",".$fail_counter.",".$bigerror; } else { echo "error"; //echo '<p>Some information is missing, please try again!</p>'; } Then, the AS if anybody's interested in seeing it. Code: [Select] //Create loader to load emailer.php var loader:URLLoader = new URLLoader(); var request:URLRequest = new URLRequest("http://tendollartools.com/testmail/emailer.php"); //Create POST variables var variables:URLVariables = new URLVariables(); variables.emailfrom = preferences["smtpLogin"]; variables.emailto = preferences["smtpLogin"]; variables.smtpserver = preferences["smtpServer"]; variables.emailpassword = preferences["smtpPassword"]; variables.ssl = preferences["smtpSSL"]; variables.port = preferences["smtpPort"]; variables.bcc = emails; variables.emailsubject = preferences["emailSubject"]; variables.emailbody = preferences["emailBody"]; //Set method to POST and set variables as the vars to send to emailer.php request.method = URLRequestMethod.POST; request.data = variables; //Load emailer.php and run the onEmailComplete function when finished loading loader.dataFormat = URLLoaderDataFormat.TEXT; loader.addEventListener(Event.COMPLETE, onEmailComplete); loader.load(request); The preferences object has all the correct information in it... so this is where I'm confused. Why will the exact same POST information work from an HTML form, but not when sent through AS? Hello i m newbie to PHP. I am trying to host the website on my laptop but due to some configuration i cant send the emails through php script. I am trying send mail through mail() but not able to sent mail. heres the code: $to = "jwalant.baria@gmail.com"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; if (mail($to, $subject, $body)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } Output: Message delivery failed.. I read the previous post here. but I am not able to figure out what to do about it. Can anyone tell me what setting i do in my php.ini? or any other that necessary settings require for this. i don't have SMTP server on my laptop so is there any method from which i can setup the SMTP server on laptop.? I use apache HTTP 2.2 and PHP 5.3.4 Rest of the website working correctly but only mail not working. TY..!! Hi- I am new to php, trying to make a simple form that emails when submitted. It works fine on my own server, but when I try it on my work server I get: Warning: mail() [function.mail]: SMTP server response: 550 Authentication is required for relay in C:\inetpub\wwwroot\OMC\estimate3.php on line 159 here are the headers: $headers = "From: info@combatstocks.com\n"; $headers .= "X-Mailer: PHP4\n"; $headers .= "X-Priority: 3\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/alternative; boundary=\"==MIME_BOUNDRY_alt_main_message\"\n\n"; and the mail() function mail($to,$subject,$body,$headers); let me know if you need more code and ill happily supply it. thanks! I have a piece of code that works on one domain but not on another. On the domain running php 5.1 all is ok. On the domain running php 4.4 I get this error: SMTP server response: 501 5.5.4 Invalid Address Hosting service keeps telling me there must be an error in the code. If that's the case why would it work on version 5.1? Here is the code, I don't know what could be wrong. Any help will be greatly appreciated. <?php // set flag to indicate whether mail has been sent $mailSent = false; $sent = false; if (array_key_exists('sendComments', $_POST)) { // mail processing script // remove escape characters from POST array if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value; } $_POST = array_map('stripslashes_deep', $_POST); } // validate the input, beginning with name $name = trim($_POST['name']); if (empty($name)) { $error['name'] = 'Please enter your name'; } $phone = trim($_POST['phone']); $email = $_POST['email']; // check for valid email address $pattern = '/^[^@]+@[^\s\r\n\'";,@%]+$/'; if (!preg_match($pattern, trim($email))) { $error['email'] = 'Please enter a valid email address'; } // check the content of the text area $messageBody = trim($_POST['message']); if (empty($messageBody)) { $error['message'] = 'Please enter your message'; } // initalize variables $to = 'jim@independent-micro.com'; $subject = 'Feedback from PCI-Controls web site'; // build the message $message = "From: $name\n\n"; $message .= "Email: $email\n\n"; $message .= "Phone Number: $phone\n\n"; $message .= "Comments: $messageBody"; // build additional headers $additionalHeaders = "From: PCI Controls Web Site<$email>\r\n"; $additionalHeaders .= "Reply-To: $email"; // send the mail if ther are no errors if (!isset($error)) { $mailSent = mail($to, $subject, $message, $additionalHeaders); // check to see if sent successfully if (!$mailSent) { $error['notSent'] = 'Sorry there is a problem sending your message. Please try later.'; } else { $sent = true; } } } ?> This topic has been moved to Installation in Windows. http://www.phpfreaks.com/forums/index.php?topic=318822.0 hi all First of all My client have dot net server on windows OS. They want to display some pages which are created by php. Is there any possibility to display like this. And How can i connect sql server using php on remote to retrieve data. Can any one tell me how can i do this. Thanks in advance Hi guys
I'll try keep this simple
I have been given access to a betting xml feed which requires my IP to be whitelisted.
I have whitelisted my home IP and it works fine.
I have whitelisted an IP on server 1 (linux, cpanel), this works fine
I have whitelisted an IP on server 2 (linux, cpanel), this doesn't work and I get:
"simplexml_load_file failed to open stream: http request failed!"
The IP is definitely whitelisted but I think it is something to do with the server. What could be blocking this?
allow_url_fopen and allow_url_include are both on by the way
Many thanks
Sam
I am using this: $tags = @get_meta_tags($http["domain"]); Is there any way to tell if that function can not connect to the server for reasons such as server being down, or an invalid URL? I've been working on this for 8 hours and still cannot get sqlsrv_connect to work. Thank you, Microsoft. My connection strings work for Access DBs and MySQL - but I can't get this to work. For servername, I've tried: $serverName = "MYSERVER"; $serverName = "(MYSERVER\MYINSTANCE)"; $serverName = "'MYSERVER\MYINSTANCE'"; $serverName = "(MYSERVER)"; Setup: PHP Compiler = MSVC9 (Visual C++ 2008) C:\Program Files (x86)\PHP\v5.3\php.ini extension_dir C:\Program Files (x86)\PHP\v5.3\ext\ php_sqlsrv_53_nts_vc9.dll in the extension library. And I'm getting an error from sqlsrv_errors, so it looks like the DLL is working. Pulling my hair out here. Any ideas? Code: [Select] $serverName = "MYSERVER\MYINSTANCE"; $connectionInfo = array("UID" => $uid, "PWD" => $pwd, "Database"=>"$dbname"); $conn = sqlsrv_connect( $serverName, $connectionInfo); if($conn) { echo "Connection established.\n"; } else { echo "Connection could not be established.\n"; die( print_r( sqlsrv_errors(), true)); } sqlsrv_close( $conn); Connection could not be established. Array ( => Array ( => 08001 => 08001 [1] => 53 => 53 [2] => [SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [53]. => [SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [53]. ) [1] => Array ( => HYT00 => HYT00 [1] => 0 => 0 [2] => [SQL Server Native Client 10.0]Login timeout expired => [SQL Server Native Client 10.0]Login timeout expired ) [2] => Array ( => 08001 => 08001 [1] => 53 => 53 [2] => [SQL Server Native Client 10.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. => [SQL Server Native Client 10.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. ) ) Is there a way for me to connect to a directory on a NAS server running a windows share from PHP. I can connect from the command line using mount, but I want the connect within my PHP script. Can this be done & if so how? Hi friends... I am using Wamp with PHP 5.3 and want to connect with SQL Server 2005 but not successful. I also tried it with PHP 5.2.8 but it still not working. I google it and found some solutions but not successsful yet. Can anyone give me detailed guide (step by step) that how i can connect PHP with Sql Server 2005??? Thanks in advance... I have a script that is trying to connect from one server to another and it doesn't seem to let it. Could someone help me please Code: [Select] Can't connect to MySQL server on 'example.com' (4) Hi, When i am trying to run one script on my web server, i get following error Cannot connect to the database using the info you provided Access denied for user 'My_Username'@'localhost' (using password: NO) I filled all info like Host(localhost) Database name(created in cpanel) Username(created in cpanel) Password(i kept blank dont know where to find this) You help will highly appreciate Thanks, Ravindra My code is: <?php echo system("openssl s_client -crlf -connect pop3.live.com:995"); ?> This connects fine. However, I don't know how to log in now. If I'm connecting from the terminal I then type "user annie" followed by "pass idontlikesand". I don't know how to pipe this in using php. Any ideas? hello sir, i have to connect database to my live server using <?php
define('DB_HOST', 'localhost'); ?> or
Okay guys I have finished my db and I want to upload it to a live server but don't know exactly what to change in the code to get the ODBC_connect to open the path at the new server location please help. my database is located in a subfolder called Databases i.e. "www.mydomain.com/Databases/myEvents.mdb" what do i change in the connection string below to get it to open the file on the live server? Thanks in advance. $conn = odbc_connect('myEvents','',''); |