Jump to content

Search the Community

Showing results for tags 'smtp'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 14 results

  1. My developer has given me a class file (attached) to handle sending email, however sending email from within the app does not work (the developer is not available at the moment). My website host has said they support PEAR for sending email, and have provided the following code. which I have tested and it works (with the necessary variable values being defined before of course). $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } For the test email script that works with the above, there is a require_once to "Mail.php" and include_path=".;..\Pear" in a .user.ini file. The test email script is in the root of the website and so is the PEAR folder. I need help changing the cls.SendEmail.php file so that the app can send email. Thanks for the assistance. cls.SendEmail.php
  2. Hi Guys, I just write the code in php but mail function is not working rest everything is working fine.. i tried other script but that also not working.. Than i came to know that my hosting server only use SMTP.. So i need help to do that.. Code Below <?php class patient_mail { function mail_send($c) { global $db; $db->fun_db(); global $img_obj; $img=array(); $time=time(); $to = 'team@concepteurs.co.in'; $fromEmail = $_REQUEST['email']; $fromName = $_REQUEST['comment_name']; $subject = $_REQUEST['contactno']; $message = $_REQUEST['comment']; $message1 = $_REQUEST['comment']; //$message.="You have receive An request from $c Page From the user/Patient $fromName"; //var_dump($_FILES); $headers = "From: $fromName"; /* GET File Variables */ if($_FILES['report']['name'][0]!=''){ foreach( $_FILES['report']['name']as $k=>$value) { $time++; $tmpName = $_FILES['report']['tmp_name'][$k]; $fileType = $_FILES['report']['type'][$k]; /* Start of headers */ $filename = stripslashes($_FILES['report']['name'][$k]); $ext = explode(".",$value); $extension = strtolower(end($ext)); $tempname = $_FILES['report']['tmp_name'][$k]; $userimg = "mail_".$time.".".$extension; $folder = "../images/mail/"; $img[]=$userimg; $newwidth = ""; $newheight = "154"; if($ext!='exe'){ move_uploaded_file($tempname,$folder.$userimg); } if (file($tmpName)) { /* Reading file ('rb' = read binary) */ $file = fopen($tmpName,'rb'); $data = fread($file,filesize($tmpName)); fclose($file); } $randomVal = md5(time()); $mimeBoundary = "==Multipart_Boundary_x{$randomVal}x"; /* Header for File Attachment */ $headers .= "\nMIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed;\n" ; $headers .= " boundary=\"{$mimeBoundary}\""; /* Multipart Boundary above message */ $message = "This is a multi-part message in MIME format.\n\n" . "--{$mimeBoundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; /* Encoding file data */ $data = chunk_split(base64_encode($data)); /* Adding attchment-file to message*/ $message .= "--{$mimeBoundary}\n" . "Content-Type: {$fileType};\n" . " name=\"{$value}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mimeBoundary}--\n"; } $userimg=implode(',',$img); } $sql="insert into treatment_mail(comment_name,email,contactno,message,page_id,report1,mail_date)values('".$fromName."','".$fromEmail."','".$subject."','".$message1."','".$c."','".$userimg."','".time()."')"; mysql_query($sql); $flgchk = mail ("$to", "$subject", "$message", "$headers"); /* this code is not working*/ if($flgchk){ echo $msg="A email has been sent to: $to"; } else{ echo $msg= "Error in Email sending"; } return $msg; } } $obj_mail=new patient_mail(); ?>
  3. Hi- I've got a few simple forms on my site that get relayed over to our email server when the submit button is hit. The forms, in turn, get emailed to the predetermined recipients from that mail server. It's been working great for years, but we changed our mail server recently and didn't point the php.ini config to the new server and we've missed some form submissions for a few days (I know, I know). Looking at the PHP error log, I've got about 140 "PHP Warning: mail() [<a href='function.mail'>function.mail</a>]: SMTP server response: 530 5.7.1 Client was not authenticated in " entries, which tells me we missed 140 form submissions. My question is: is there any way to retrieve these form submissions? Are they sitting someplace on my site that I can extract them from? Do they literally just disappear if they can't get to the SMTP server? Many thanks in advance for any responses!
  4. Hi all, Can I know how can use SMTP configuration to send a mail in PHP , I tried using mail() class by changing php_ini configuration, but didn't work , I also tried installing php_smtp.dll file, still I get the same error as shown below : Warning: mail() [<a href='function.mail'>function.mail</a>]: Failed to connect to mailserver at "localhost" port 465, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() can I know how to resolve this issue, i even tried with port "25", all my changes gave me the same error. If anyone could share the working code , it would be of great help.. Thank you in advance...
  5. I am seeking for advise on setting up the SMTP for my websites. I have two servers. One is mail server and another one is web server. I have more than one website in the web server. All email accounts are stored in the mail server. On my website, I have many enquiry forms. Some on the same domain some on different, but same server. These forms will send an email to the site owner once user submit the form. My questions: 1) Should I configure my script to use the mail server as a relay to send out email via SMTP? Because as I know, if I use the sendmail program in the web server, email that goes out will categorized as spam. 2) If Q1) is YES, should I create one account for each domain? Because I have multiple domain hosted on both server. So each website will use the assigned account to relay email. 3) Is it possible to configure my mail server to whiltelist my webserver so that it allowed it to connect via SMTP without authentication and allowed to set the sender's email differently? If possible, which setting I should look into? EG: SPF. This is a conceptual question. So no hardware or software restriction. I just need some guide on where I should look into it. Thank you for reading!
  6. Hi, I managed to set up a simple smtp with sendmail and gmail in the PHP mail function. The thing is, is it possible to change the "from" email address to a different one, than the gmail account I'm using? No matter which $from I assign, the from address is always my gmail account, which I am using to send mails. Thanks
  7. I send EHLO command to gmail stmp. if response was success, it will send code 250. I try to catch the response code of gmail smtp. when my code like this $fp = fsockopen("ssl://smtp.gmail.com", 465, $errNo, $errStr, 15); if(empty($fp)){ echo $errNo.":".$errStr; }else{ fputs($fp, "EHLO"."\r\n"); $rp = get_lines($fp); $code = substr($rp,0,3); echo $code; fclose($fp); } function get_lines($fp){ while($str = fgets($fp)){ return $str; } } why it always produce code 220 ? but when I append the php code with echo fgets($fp); like this $fp = fsockopen("ssl://smtp.gmail.com", 465, $errNo, $errStr, 15); if(empty($fp)){ echo $errNo.":".$errStr; }else{ echo fgets($fp); //additional code fputs($fp, "EHLO"."\r\n"); $rp = get_lines($fp); $code = substr($rp,0,3); echo $code; fclose($fp); } function get_lines($fp){ while($str = fgets($fp)){ return $str; } } the output like this: 220 mx.google.com ESMTP vu10sm20075869pbc.27 - gsmtp <<don't need this 250 code 250 has caught. but how to produce code 250 without additional command like echo fgets($fp); ?
  8. how do send html format with gmail smtp ? I just know some commands of smtp gmail to manage email they are MAIL FROM and RCPT TO. does it can be combined with mail($to, $sbj, $msg, $hdrs) ?
  9. When I try send email with PHPMailer_v5.1, it works. But when I try make it self, I know that the result is possible to error or email not sent. My problem is the email not sent. this my code: <?php $fp = fsockopen("ssl://smtp.gmail.com", 465, $errNo, $errStr, 15); if(!$fp){ echo "not connected"; }else{ fputs($fp, "EHLO"."\r\n"); fputs($fp, "AUTH LOGIN"."\r\n"); fputs($fp, base64_encode("author@gmail.com")."\r\n"); fputs($fp, base64_encode("password")."\r\n"); fputs($fp, "MAIL FROM:<author@gmail.com>"."\r\n"); fputs($fp, "RCPT TO:<target@gmail.com>"."\r\n"); fputs($fp, "DATA"."\r\n"); fputs($fp, "Subject: This is subject"."\r\n"); fputs($fp, "This is body message"."\r\n"); fputs($fp, "."."\r\n"); fputs($fp, "QUIT"."\r\n"); fclose($fp); } ?> And I have enable extension=php_openssl.dll in php.ini
  10. Hello, I am using the latest version of PHPMailer to try and send mails. The SMTP server is configured to use the Gmail SMTP. Now the problem is that when I am sending mails to a person with a Gmail account there seems to be no problem but when I am sending my mail to someone with a non Gmail account for example Yahoo. The mail never reaches(I have checked the SPAM folder). My PHP Mailer setup is as follows-: <?php require_once('mailer/class.phpmailer.php');//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded $mail = new PHPMailer(); $body = "<html><head></head><body><strong>This is a System generated message. PLEASE DO NOT REPLY TO THIS MAIL.</strong><br />Click on the following link to activate your account-:<br /><a href='http://www.google.co.in'>Click Here !! </a><br />END OF MESSAGE.</body></html>"; $body = eregi_replace("[\]",'',$body); $mail->IsSMTP(); // telling the class to use SMTP$mail->Host = "smtp.gmail.com"; // SMTP server$mail->SMTPDebug = 2; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only$mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "tls"; // sets the prefix to the servier$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server$mail->Port = 587; // set the SMTP port for the GMAIL server $mail->Username = "foobar@gmail.com"; // GMAIL username $mail->Password = "foobar"; // GMAIL password $mail->SetFrom("foobar@gmail.com", "foo"); $mail->AddReplyTo("foobar@gmail.com", "foo"); $mail->Subject = "foo bar"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $address = $_GET['email']; $mail->AddAddress($address); if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo;} else { } ?> <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>domail</title></head> < body></body></html> My Questions are as follows-: Do I have to reconfigure my SMTP every time I send my mail to a different account ? For example if I have to send it to a Yahoo account do I have to use the Yahoo SMTP or when I send my mail to a Rediff account do I have to use the Rediff SMTP ??PHPMailer doesn't report any errors, it just says that it sent the message but the message never arrives. Can't I just use one SMTP and send mails to any account ? I am using WAMP server on my PC to run my Apache Web Server. Will this create problems in sending mails even if PHPMailer is configured correctly ? Is it necessary to add a name with the receiver address in the line-: $mail->AddAddress($address); Do I have to write it like this $mail->AddAddress($address,"Receiver Name"); Since my mail will be sent to anyone signing up specifying the correct receiver name every time will be a little difficult to do. I am getting an error on the line-: $body = eregi_replace("[\]",'',$body); The problem is that the function eregi_replace() has become deprecated. According to the php.net documentation I have to use preg_replace() with the " i " switch. But since I am beginner to PHP and regular expression I can't figure out how to do that. Can someone give the code which accomplishes the same task as the line above using preg_replace. Thank You.
  11. Hello, I don't know very good PHP, I have a problem with send email. My hosting working smtp support but i didn't add it. My function doing send recovery password. How can i add smtp support? function sendRecover($to, $title, $url, $from, $username, $salt) { $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: '.$title.' <'.$from.'>' . "\r\n"; $subject = 'Password Recovery - '.$title; $message = 'A password recover was requested, if you didn\'t make this action please ignore this email. <br /><br />Your Username: <strong>'.$username.'</strong><br />Your Reset Key: <strong>'.$salt.'</strong><br /><br />You can reset your password by accessing the following link: <a href="'.$url.'/index.php?a=recover&r=1" target="_blank">'.$url.'/index.php?a=recover&r=1</a>'; return @mail($to, $subject, $message, $headers); }
  12. Hey. I'm having some troubles with a php script I got a while ago for form to email on a website i'm currently working on. The client has recently switched to a different hosting server and they require SMTP authentication for the new cloudsites....I have about 5 different pretty detailed forms that i need to have the SMTP authentications placed into, but i have no idea what i'm doing. below is my current coding. i'm just not sure how to place the SMTP into the coding correctly. i've seen that i need to download swift or pear and i have no clue where to start. any help or direction would be greatly appreciated...thanks. the current PHP script for my form to email: <?php $my_email = "studio@roharikproductions.com"; /* Enter the continue link to offer the user after the form is sent. If you do not change this, your visitor will be given a continue link to your homepage. If you do change it, remove the "/" symbol below and replace with the name of the page to link to, eg: "mypage.htm" or "http://www.elsewhere.com/page.htm" */ $continue = "index.html"; /* Step 3: Save this file (FormToEmail.php) and upload it together with your webpage containing the form to your webspace. IMPORTANT - The file name is case sensitive! You must save it exactly as it is named above! Do not put this script in your cgi-bin directory (folder) it may not work from there. THAT'S IT, FINISHED! You do not need to make any changes below this line. */ $errors = array(); // Remove $_COOKIE elements from $_REQUEST. if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}} // Check all fields for an email header. function recursive_array_check_header($element_value) { global $set; if(!is_array($element_value)){if(preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i",$element_value)){$set = 1;}} else { foreach($element_value as $value){if($set){break;} recursive_array_check_header($value);} } } recursive_array_check_header($_REQUEST); if($set){$errors[] = "You cannot send an email header";} unset($set); // Validate email field. if(isset($_REQUEST['email']) && !empty($_REQUEST['email'])) { if (empty($_POST['email2']) || $_POST['email2'] != $_POST['email']){$errors[] = "Email addresses do not match.";} if(preg_match("/(%0A|%0D|\n+|\r+|:)/i",$_REQUEST['email'])){$errors[] = "Email address may not contain a new line or a colon";} $_REQUEST['email'] = trim($_REQUEST['email']); if(substr_count($_REQUEST['email'],"@") != 1 || stristr($_REQUEST['email']," ")){$errors[] = "Email address is invalid";}else{$exploded_email = explode("@",$_REQUEST['email']);if(empty($exploded_email[0]) || strlen($exploded_email[0]) > 64 || empty($exploded_email[1])){$errors[] = "Email address is invalid";}else{if(substr_count($exploded_email[1],".") == 0){$errors[] = "Email address is invalid";}else{$exploded_domain = explode(".",$exploded_email[1]);if(in_array("",$exploded_domain)){$errors[] = "Email address is invalid";}else{foreach($exploded_domain as $value){if(strlen($value) > 63 || !preg_match('/^[a-z0-9-]+$/i',$value)){$errors[] = "Email address is invalid"; break;}}}}}} } // Check referrer is from same site. if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";} // Check for a blank form. function recursive_array_check_blank($element_value) { global $set; if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}} else { foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);} } } recursive_array_check_blank($_REQUEST); if(!$set){$errors[] = "You cannot send a blank form";} unset($set); // Display any errors and exit if errors exist. if(count($errors)){foreach($errors as $value){print "$value<br>";} exit;} if(!defined("PHP_EOL")){define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");} // Build message. function build_message($request_input){if(!isset($message_output)){$message_output ="";}if(!is_array($request_input)){$message_output = $request_input;}else{foreach($request_input as $key => $value){if(!empty($value)){if(!is_numeric($key)){$message_output .= str_replace("_"," ",ucfirst($key)).": ".build_message($value).PHP_EOL.PHP_EOL;}else{$message_output .= build_message($value).", ";}}}}return rtrim($message_output,", ");} $message = build_message($_REQUEST); $message = $message . PHP_EOL.PHP_EOL."-- ".PHP_EOL.""; $message = stripslashes($message); $subject = "Business Headshot Booking Form"; $headers = "From: " . $_REQUEST['email']; mail($my_email,$subject,$message,$headers); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> body,td,th { color: #7F7F7F; font-family: inheirit; } a:link { color: #7F7F7F; text-decoration: none; } a:visited { text-decoration: none; color: #7F7F7F; } a:hover { text-decoration: underline; color: #7F7F7F; } a:active { text-decoration: none; color: #7F7F7F; } body p { font-size: 16px; } body p { font-size: 24px; } body p { text-align: center; } </style> </head> <body bgcolor="#e2e2e2" text="#7F7F7F" link="#7F7F7F" vlink="#7F7F7F" alink="#7F7F7F"> <div> <center> <b>Thank you <?php print stripslashes($_REQUEST['name']); ?></b> <br>Your message has been sent <p><a href="http://columbusbusinessheadshots.com/">Click here to continue</a></p> </center> </div> </body> </html> i tried to add this into the code in hopes of a quick fix but that made the form not work at all: $host = "host@host.com"; $username = "email@host.com"; $password = "emailpassword"; $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); i'm not sure if i add that just anywhere into the php script or if it needs to be in a certain area? also not sure what exactly i'll need to install or download onto the server as well. thanks.
  13. I have the following code to retrieve the password of a user from the database and email to him. I am successfully able to send a user his password if his email is present in the database. But in the event that the email doesn't exist, I want the code to echo that the email for the particular user doesn't exist in the database. My code gives me the below result if an invalid email is entered in the form: Failed to add recipient: @localhost [sMTP: Invalid response code received from server (code: 555, response: 5.5.2 Syntax error. v9sm2318990paz.6)] I have tried using the if-else statement for this purpose. Here's the code I wrote: <?php //Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); // email value sent from HTML form $email_to=$_POST['email']; // table name $tbl_name="registration"; if($mysql1 = "SELECT ID,Email,Password FROM $tbl_name WHERE Email='$email_to' ORDER BY ID DESC ") { $selectemail = mysql_query($mysql1); $shah = mysql_fetch_array($selectemail); $EMAIL = $shah['Email']; $UID = $shah['ID']; $password = $shah['Password']; require_once "/home/computat/php/Mail.php"; $from = "abhishekagrawal.988@gmail.com"; $to = $EMAIL; $subject = "Your password for www.computationalphotography.in"; $body = "Your password for logging on to our website www.computationalphotography.in is:\n$password\r\nIf you have any additional queries, kindly write to us at abhishekagrawal.988@gmail.com\r\n\nThanks & Regards\nThe Computational Photography Team\n"; $host = "ssl://smtp.gmail.com"; $port = "465"; $username = "abhishekagrawal.988@gmail.com"; // $password = "*********"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'port' => $port, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p></p>"); } } else{ echo "<b><center>Email not found in the database</center></b>"; } /*
  14. I'm having an issue using fsockopen to connect to smtp.gmail.com in which I always receive the error "Failed to connect to server: Connection timed out". The issue seems very similar to an old bug fixed in late 2010: https://bugs.php.net/bug.php?id=50953 I'm using the following script to test: // connect to the smtp server $smtp_conn = @fsockopen("ssl://smtp.gmail.com", // the host of the server 465, // the port to use: 25, 465, 587 $errno, // error number if any $errstr, // error message if any 5); // give up after ? secs // verify we connected properly if(empty($smtp_conn)) { $error = array("error" => "Failed to connect to server", "errno" => $errno, "errstr" => $errstr); echo "SMTP -> ERROR: " . $error["error"] . ": $errstr ($errno)\n"; } else { fclose($smtp_conn); echo "Connected!\n"; } Replacing the host argument with tsl://smtp.gmail.com or simply smtp.gmail.com and any combination of ports 25, 465, 587 also fails. Yet other smtps connect fine (e.g. smtp.live.com:587, smtp.mail.yahoo.com:465). A firewall or other blocking is not the issue. This is on a VPS with the firewall disabled and, furthermore, I can successfully connect to smtp.gmail.com (and send an email) via openssl s_client. So basic access to the server/port is not the prob. Is there any possibility this old bug (id=50953) is still lingering around in a fairly recent 5.3 version of PHP? Or any suggestions on other possible causes? I am using 5.3.17-1~dotdeb.0 and same code works fine on a different VPS with PHP 5.2.17-1.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.