PHP - Error When Sending Email With A $_session As Destinatary
Similar TutorialsI have been working a a program to send text messages using php but my headers containing the "From:" part of the text message keep on returning an error. Could someone please explain what i'm doing wrong. I have attached the php script and the html page I am using as a form. <?php $from = $_POST['from']; $to = $_POST['to']; $carrier = $_POST['carrier']; $carrierFrom = $_POST['carrierFrom'] $message = stripslashes($_POST['message']); //From Function if ($carrierFrom == "verizon") {$formatted_from = $from."@vtext.com";} if ($carrierFrom == "tmobile") {$formatted_from = $from."@tomomail.net";} if ($carrierFrom == "sprint") {$formatted_from = $from."@messaging.sprintpcs.com";} if ($carrierFrom == "att") { $formatted_from = $from."@txt.att.net"; if ($carrierFrom == "gmail") { $formatted_from = $from."@gmail.com"; } //To Function if ($carrierFrom == "verizon") {$formatted_number = $to."@vtext.com";} if ($carrier == "tmobile") {$formatted_number = $to."@tomomail.net";} if ($carrier == "sprint") {$formatted_number = $to."@messaging.sprintpcs.com";} if ($carrier == "att") {$formatted_number = $to."@txt.att.net";} if ($carrier == "gmail") {$formatted_number = $to."@gmail.com";} //Send $sent = mail($formatted_number,$message,$formattedFrom) ; if($sent) {print "Your text was sent successfully"; } else {print "We encountered an error sending your text"; } ?>
First let me explain my code. This is later included in project_status.php] . In project_status.php] , I have included another file project_status_app.php which contains a HTML form.
<?php include 'inc_fn_header_and_menu.php'; function includeFile($file,$variable) { $var = $variable; include($file); } if (isset($_GET['id']) && $_GET['id']!="") { $pid = $_GET['id']; $_SESSION['pidForApproval'] = $_GET['id']; $query = 'SELECT * FROM `profile` WHERE pid ='.'\''.$pid.'\''; $result=mysqli_query($db,$queryToRetrievePP) or die("There are no records to display ... \n" . mysqli_error()); foreach ($result as $row) { $status = $row['status']; } } ...........some PHP and HTML code....... <div id="customerPurchaseApprovalForm"> <?php echo '<p>APPROVAL FOR CUSTOMER PURCHASE</p>'; $discountApprovalStatus = "Granted"; if ($discountApprovalStatus == "Granted") { includeFile("project_status_app.php",$highestannualvalue); } else { //......... } In project_status_app.php I am attempting to retrieve pidForApproval from the $_SESSION array. <?php // put your code here UPDATE `pp` SET `customer_purchase_remarks` = 'hahaha' WHERE `pp`.`id` = 207; if ($_SERVER['REQUEST_METHOD'] == 'POST') { include '../../inc/fastlogin.php'; $sql = "UPDATE pp SET customer_purchase_remarks ='{$_POST['remarkstxt']}' WHERE pp.pid='{$_SESSION['pidForApproval']}'"; $result = mysqli_query ( $fastdb, $sql ) ; if (mysqli_affected_rows($fastdb) != 1) { $_SESSION['err_cpa_rmks'] = "<p>Error while updating WHERE id='{$_SESSION['pidForApproval']}'</p>"; //echo "<p>Error while updating WHERE id='{$_POST['pidForApproval']}'</p>".mysqli_error($fastdb); } else { $_SESSION['suc_cpa_rmks'] = "<p>Records was updated successfully.</p>"; //echo "Records was updated successfully."; } header ("location: project_status.php?id="$_SESSION['pidForApproval']); exit(); } ?> When I load project_status.php, project_status_app.php is supposed to display the form. Once the user fills in the form the and the submit button has been pressed, the UPDATE statement is supposed to run and then it is supposed to navigate back to project_status.php?id=FA142. But the update is failing and the when the project_status.php is loaded back, the url looks like this http://localhost/fast/project_status.php?id= . The id is empty. It is supposed to be something like this http://localhost/fast/project_status.php?id=FA142. With the id being populated at the header ("location: project_status.php?id=".$_SESSION['pidForApproval']);
Missing some information. From our website we are connecting to GMAIL to send our emails through SMTP. For some reason it is not sending the emails to the CC or BCC email address event though GMAIL shows it was included in the email. Am I missing something in the below code? Code: [Select] $currentTime = time(); $emailTo = "redbrad0@domain.com"; $emailCC = "brad@domain.com"; $emailBCC = "events@domain.com"; $emailSubject = "TEST Email at (" . $currentTime . ")"; $emailBody = "This is the body of the email"; $headers = array(); if (!empty($emailTo)) $headers['TO'] = $emailTo; if (!empty($emailCC)) $headers['CC'] = $emailCC; if (!empty($emailBCC)) $headers['BCC'] = $emailBCC; if (!empty($emailSubject)) $headers['Subject'] = $emailSubject; $headers['From'] = "events@domain.com"; $mime = new Mail_mime("\n"); $mime->setTXTBody($emailBody); $body = $mime->get(); $headers = $mime->headers($headers); $mail = Mail::factory('smtp', array ('host' => 'ssl://smtp.gmail.com', 'auth' => true, 'port' => 465, 'username' => 'events@domain.com', 'password' => 'thepasswordhere')); try { $result = $mail->send($emailTo, $headers, $emailBody); } catch (TixException $ex) { echo "<font color=red>Error:" . $ex->getCode() . "</font><br>"; } echo "Emailed at (" . $currentTime . ")<br>"; die; Everything about the email is sending except the message text does anyone know what the issue could be? here is the block of code that sends the email Thanks in advance Code: [Select] $image = "http://www.visualrealityink.com/dev/clients/arzan/snell_form/images/email.png"; echo "got to process form"; $target_path = "upload/"; $path = $target_path = $target_path . basename( $_FILES['file']['name']); $boundary = '-----=' . md5( uniqid ( rand() ) ); $message .= "Content-Type: application/msword; name=\"my attachment\"\n"; $message .= "Content-Transfer-Encoding: base64\n"; $message .= "Content-Disposition: attachment; filename=\"$path\"\n\n"; echo $path; $fp = fopen($path, 'r'); do //we loop until there is no data left { $data = fread($fp, 8192); if (strlen($data) == 0) break; $content .= $data; } while (true); $content_encode = chunk_split(base64_encode($content)); $message .= $content_encode . "\n"; $message .= "--" . $boundary . "\n"; $message .= $image . "<br />" . $_POST['name'] . "submitted a resume on our website. Please review the applications and contact the candidate if their resume is a fit for any open opportunities with the company. <br><br> Thank you. <br><br> SEI Team"; $headers = "From: \"Me\"<me@example.com>\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\""; mail('george@visualrealityink.com', 'Email with attachment from PHP', $headers, $message); Hi the user fill details and then the email his sent to me the only problem is that the emails keeps going to my spam, can someone help me out please I looked already php website and email format looks the same. This is the link to my form. http://www.people.eurico.co.uk/ here my form script Code: [Select] <?php // Set email variables $email_to = 'xxxxx@xxxxxxx.co.uk'; $email_subject = 'Call back form'; // Set required fields $required_fields = array('fullname','email','telephone','comment'); // set error messages $error_messages = array( 'fullname' => 'Please enter a Name to proceed.', 'email' => 'Please enter a valid Email.', 'telephone' => 'Please telephone.', 'comment' => 'Please enter your Message to continue.' ); // Set form status $form_complete = FALSE; // configure validation array $validation = array(); // check form submittal if(!empty($_POST)) { // Sanitise POST array foreach($_POST as $key => $value) $_POST[$key] = remove_email_injection(trim($value)); // Loop into required fields and make sure they match our needs foreach($required_fields as $field) { // the field has been submitted? if(!array_key_exists($field, $_POST)) array_push($validation, $field); // check there is information in the field? if($_POST[$field] == '') array_push($validation, $field); // validate the email address supplied if($field == 'email') if(!validate_email_address($_POST[$field])) array_push($validation, $field); } // basic validation result if(count($validation) == 0) { // Prepare our content string $email_content = 'peoplesmartlearning.co.uk: ' . "\n\n"; // simple email content foreach($_POST as $key => $value) { if($key != 'submit') $email_content .= $key . ': ' . $value . "\n"; } // if validation passed ok then send the email mail($email_to, $email_subject, $email_content); // Update form switch $form_complete = TRUE; } } function validate_email_address($email = FALSE) { return (preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i', $email))? TRUE : FALSE; } function remove_email_injection($field = FALSE) { return (str_ireplace(array("\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:"), '', $field)); } ?> The HTML Code: [Select] <div class="call_us_form"> <p class="title">WE'LL CALL YOU BACK</p> <?php if($form_complete === FALSE): ?> <form class="contact_form" id="fm-form" method="post" action="index.php" > <fieldset> <div class="fm-req"> <label for="fm-firstname">Name</label> <input type="text" id="fullname" class="detail" name="fullname" value="<?php echo isset($_POST['fullname'])? $_POST['fullname'] : ''; ?>" /> <?php if(in_array('fullname', $validation)): ?><script type="text/javascript">alert("Please enter a Name"); history.back();</script><?php endif; ?> </div> <div class="fm-req"> <label for="fm-firstname">Email</label> <input type="text" id="email" class="detail" name="email" value=" <?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>" /> <?php if(in_array('email', $validation)): ?><script type="text/javascript">alert("Please enter a valid Email Address"); history.back();</script><?php endif; ?> </div> <div class="fm-req"> <label for="fm-firstname">Number</label> <input type="text" id="telephone" class="detail" name="telephone" value="<?php echo isset($_POST['telephone'])? $_POST['telephone'] : ''; ?>" /> <?php if(in_array('telephone', $validation)): ?><script type="text/javascript">alert("Please enter telephone number"); history.back();</script><?php endif; ?> </div> <div class="fm-req"> <label for="fm-lastname">Message</label> <textarea cols="40" rows="5" id="comment" name="comment" class="mess"><?php echo isset($_POST['comment'])? $_POST['comment'] : ''; ?></textarea> <?php if(in_array('comment', $validation)): ?><script type="text/javascript">alert("Please enter your message"); history.back();</script><?php endif; ?> </div> <input class="submit_button" type="submit" value="Call us" /> </fieldset> </form> <?php else: ?> <p>Thank you for your Message!</p> <p>We will get back to you as soon as we can</p> <script type="text/javascript"> setTimeout ('ourRedirect()', 5000) function ourRedirect () { location.href='index.php' } </script> <?php endif; ?> Code: [Select] $sql="SELECT * FROM $tbl_name3 WHERE review_show='n'"; $result=mysql_query($sql); $num_results=mysql_num_rows($result); if($num_results > 1){ $message="You have ".$num_results." reviews unapproved."; mail('example@example.com','GHP Reviews', $message, 'From: example@example.com'); } $sql2="SELECT * FROM $tbl_name4 WHERE rma_issued='n'"; $result2=mysql_query($sql2); $num_results2=mysql_num_rows($result2); if($num_results2 > 1){ $message="You have ".$num_results2." RMA Numbers Requested."; mail('example@example.com','GHP RMA Number Requests', $message, 'From: example@example.com'); } The reviews email is being sent, however, the RMA email is not. EDIT: Nevermind, $num_results and $num_results2 should have been > 0 not > 1. Hi
I have below code :
<?php $_SERVER['SERVER_NAME']; $to = "info@domain.com"; $subject = "Test mail"; $body = $_SERVER['SERVER_NAME']; $from = "user@example.com"; $headers = "From:" . $from; mail($to, $subject, $body, $headers) ?>the email is sent correctly but without any body text . I use $_SERVER['SERVER_NAME']; but nothing show as body . I want to use this code load each day becuse I want to know which domain is used my script. but now the code not work. Can someone help me understand why an email isn't being sent after clicking submit? Code: [Select] <?php error_reporting(E_ALL); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php extract ($_POST); if(!isset($submit)) { ?> <form action=" " method="post" name="test"> Name: <input name="name " type="text" id="name " size="8" /><br /> phone <input name="phone" type="text" size="13" /><br /> email <input name="email" type="text" size="9" maxlength="30" /><br /> <input name="submit" type="submit" value="submit" /> </form> <?php $Recipient = "$email"; $MsgSubject = "message subject"; $MsgHeader = "From Auntie Vic's Treatery <auntievics@gmail.com>\r\n"; $MsgBody = "message body."; mail($Recipient, $MsgSubject, $MsgBody, $MsgHeader); } else { echo " thank you for your order. It is being processed. Thank you for your business."; } ?> </body> </html> Hey guys, Coding something for a survey as no solution exists for our needs. I have not finished the code as I still need to do error checks + making it spam proof. Anyway I am not reciving the email even though it says that I have been sent it. Any suggestions are appreciated, please ask if you need additional info to be able to help, and thank you in advanced. Code: [Select] <?php error_reporting(0); if(isset($_POST['submit'])){ //Check that all fields that are mandatory are filled in and that the $Email variable is real $Title = $_POST['Title']; $FirstName = $_POST['FirstName']; $LastName = $_POST['LastName']; $Email= $_POST['Email']; $Country= $_POST['Country']; $State= $_POST['State']; $List= $_POST['List']; $Nav= $_POST['Nav']; $IssuesYes= $_POST['IssuesCheck']; $IssuesList= $_POST['IssuesList']; $Satisfaction= $_POST['Satisfaction']; $Improvement= $_POST['Improvement']; $ValueSatisfaction= $_POST['Value']; $Recommendation= $_POST['Recommend']; $Knowledge= $_POST['Knowledge']; $Comments= $_POST['Comments']; $Gender= $_POST['Gender']; $Age= $_POST['Age']; $Source= $_POST['Source']; $ContactNumber= $_POST['Contact']; $Newsletter= $_POST['Newsletter']; $errors = array(); //Check that the fields above are not empty: $to = "email@email.com";//Obviously not real one that I am sending to. $subject = "Survey Form Submission"; $from = $to; $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $body = "$name submitted the survey form:\n". "This is what they responded with to each question: <br>". "Their Name: $Title $FirstName $LastName <br>"."Email: $Email <br>"."Country: $Country <br>"."State: $State<br>"."Bought: $List<br>"."Website Navigation: $Nav<br>"."Issues: $IssuesYes " ." $IssuesList"."Satisfaction: $Satisfaction<br>"."Improvement: $Improvement<br>"."Value Satisfaction: $ValueSatisfaction<br>"."Reccomend: $Recommendation<br>"."Knowledge: $Knowledge<br>"."Comments: $Comments <br>"."Gender: $Gender<br>"."Age: $Age <br>"."Source for Finding Us: $Source <br>"."Contact: $ContactNumber<br>"."Subscribe to Newsletter?: $Newsletter<br>"; $headers = "From: $from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; if( mail($to, $subject, $body,$headers)){ echo "Email Send!"; }else{ echo "Somethings wrong :\ "; } // header('Location: http://www.********/thank-you-for-survey'); } ?> this is my email.php file <?php $senderName =$_POST['userName']; $senderEmail =$_POST['userEmail.']; $senderMessage =$_POST['userMessage.']; //security $senderName=stripslashes($userName); $senderEmail=stripslashes($userEmail); $senderMsg=stripslashes($userMessage); $to = 'myName@mydomain.com'; $from = 'myName@mydomain.com'; $subject = 'Testing CONTACT PAGE'; $message = 'Message From your site: Their Name: $senderName Their Email: $senderEmail Their Message is below: $senderMsg'; // Build $headers Variable $headers = 'From: Company <mysite@mydomain.com.com>' . "\r\n"; $to = '$to'; // Send the email mail($to, $subject, $message, $headers); $my_msg='thanks your message has been sent.'; print $my_msg; ?> The error I'm getting is this: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampp\htdocs\PHP_Test\email.php on line 5 all I want to be able to do is verify my form works and that I can receive emails from users of mysite any help would be greatly appreciated. Also what should the send_mail in the PHP.INI file be set to? thansk I am creating a forgotten password button, it works but it just doesn't send me an email containing the reset link.
Here's the code for the email part:
<?php require("../config.php"); if($_GET['code']) { $get_username = $_GET['username']; $get_code = $_GET['code']; $query = mysql_query("SELECT * FROM users WHERE username='$get_username'"); while($row = mysql_fetch_assoc($query)) { $db_code = $row['passreset']; $db_username = $row['username']; } if($get_username == $db_username && $get_code == $db_code) { echo " <form action='pass_reset_complete.php?code=$get_code' method='POST'> Enter a new password<br><input type='password' name='newpass'><br> Re-enter your password<br><input type='password' name='newpass1'><p> <input type='hidden' name='username' value='$db_username'> <input type='submit' value='Update Password!'> </form> "; } } if(!$_GET['code']) { echo " <form action='forgot_pass.php' method='POST'> Enter your username<br><input type='text' name='username'><p> Enter your email<br><input type='text' name='email'><p> <input type='submit' value='Submit' name='submit'> </form> "; if(isset($_POST['submit'])) { $username = $_POST['username']; $email = $_POST['email']; $query = mysql_query("SELECT * FROM users WHERE username='$username'"); $numrow = mysql_num_rows($query); if($numrow!=0) { while($row = mysql_fetch_assoc($query)) { $db_email = $row['email']; } if($email == $db_email) { $code = rand(10000,1000000); $to = $db_email; $subject = "Password Reset"; $body = " This is an automated email. Please DO NOT reply to this email. Click the link below or paste it into your browser http:/www.***REMOVED***.com/second/forgot_pass.php?code=$code&username=$username "; mysql_query("UPDATE users SET passreset='$code' WHERE username='$username'"); mail($to,$subject,$body); echo "Check Your Email"; } else { echo "Email is incorrect"; } } else { echo "That username doesnt exist"; } } } ?> Hi, I want to send an email to my registered users so that when they click on the URL given in the message hey should come back to my site as confirmetion of their registration. I am able to send the mail but the mail body is not coming as expected. Here's my code Code: [Select] <?php public function email($id){ //get users info $this->userInfo = $this->model->listUser($id); $this->sendEmail($this->userInfo); } public function sendEmail($data){ $to =$data['email']; $this->msg ="<img src=\"ideas.kpjit.com/public/images/header-img.jpg\" /> <h1>KPJ Idea</h1> <p>Make a difference</p> <p>This is a Confirmation Mail.Please confirm your registration by clicking here <a href=\"http://ideas.kpjit.com\register\confirm\ <?php echo $this->data['id'];?></p>\" "; $subject = "Registration confirmation"; $message = $this->msg; $from ="narjisfatima@yahoo.com"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From:narjisfatima@yahoo.com' . "\r\n"; if(mail($to,$subject,$headers)){ $this->render2("register/message"); exit; } } Also I am unable to insert my site banner in the mail. How can I do It. Hi Guys I am creating a site which allows the registration of new users. I already have my user registration page up and running which is lnked to my database. I would now like to add a function which will send a 'welcome to...' email to the email address provided on the registration form provided by the new user. Could anybody please point me in the right direction i.e where to start? I am using dreamweaver and Cpanel. Thanksin advance this is a forgot password page and this email script will not send Code: [Select] <?php $emailcut = substr($email, 0, 4); // Takes first four characters from the user email address $randNum = rand(); $tempPass = "$emailcut$randNum"; $hashTempPass = md5($tempPass); @mysql_query("UPDATE myMembers SET password='$hashTempPass' where email='$email'") or die("cannot set your new password"); include('Mail.php'); include('Mail/mime.php'); // Constructing the email $sender = "Social network"; // Your email address $recipient = "$email"; // The Recipients name and email address $subject = "Reset Your Password"; // Subject for the email $text = 'This is a text message.'; // Text version of the email $html = "<html><body><div align=center><br>----------------------------- New Login Password --------------------------------<br><br><br> Your New Password for our site is: <font color=\"#006600\"><u>$tempPass</u></font><br><br /> </div></body></html>"; // HTML version of the email $crlf = "\n"; $headers = array( 'From' => $sender, 'Return-Path' => $sender, 'Subject' => $subject ); // Creating the Mime message $mime = new Mail_mime($crlf); // Setting the body of the email $mime->setTXTBody($text); $mime->setHTMLBody($html); // Add an attachment // Set body and headers ready for base mail class $body = $mime->get(); $headers = $mime->headers($headers); // SMTP authentication params $smtp_params["host"] = "smtp.gmail.com"; $smtp_params["port"] = "587"; $smtp_params["auth"] = true; $smtp_params["username"] = "activate.social@gmail.com"; $smtp_params["password"] = "pass"; // Sending the email using smtp $mail =& Mail::factory("smtp", $smtp_params); $result = $mail->send($recipient, $headers, $body); if (PEAR::isError($mail)) { $outputForUser = '<font color="#FF0000">Password Not Sent.<br /><br /> Please Contact Us...</font>'; } else { $outputForUser = "<font color=\"#006600\"><strong>Your New Login password has been emailed to you.</strong></font>"; } } } else { $outputForUser = 'Enter your email address into the field below.'; } ?> Hello Guys I just want to ask if I will send email using php syntax do I need to configure the php ini settings? Any ideas how to configure it? Your usual cooperation is highly appreaciated. God Bless.. I need some help over here. I want to send an email to my friends by checking the database and extract the id. After extracting the id from the database, i want to include a URL with the id. E.g. www.abc.php?35 (35 is the id) www.abc.php?40 (40 is the id) May I know how to send an email with multiple url? Is it using a for loop in the php email function? Your help is greatly appreciated. I just ran into grief while trying to store a DateTime object in the SESSION variable. When I tried to use the stored value I got the error message "The DateTime object has not been correctly initialized by its constructor." I initially assumed that objects can't be stored in SESSION because there's no way to serialize and deserialize them for storage between scripts. But I've found posts by other people who have done this with without problems. If it works for others, why isn't it working for me? Is there something special about the DateTime class that prevents the PHP engine from serializing it? Here's a little script that demonstrates the problem (in PHP 5.2.5 under Windows XP): Code: [Select] <?php session_start(); if ( key_exists( 'd', $_SESSION ) ) { $d = $_SESSION['d']; echo "<br/>The value of 'd' is " . $d->format('m/d/Y'); } else { echo "'d' has no value yet."; } $d = new DateTime('2011-08-01'); $_SESSION['d'] = $d; $e = $_SESSION['d']; echo "<br/>The value of 'd' has been set to " . $e->format('m/d/Y'); ?> The first time the script is run it does not display "The value of 'd' is..." because $_SESSION['d'] does not exist. It sets the value, then retrieves it intact and displays it. The second time the script is run it tries to retireve the value but apparently gets an invalid one and displays the error. Then it sets, retrieves, and displays the value again. Good afternoon everyone, probably just a quick one this one! I have a reg form, and once the user has been added to the database then it is meant to send them an email with their username and password. The email works fine, received as it should, however the place where I am trying to echo variables is blank. For instance Code: [Select] <style type='text/css'> h3 { font-family: Tahoma, Geneva, sans-serif; font-size: 24px; font-style: oblique; color: #00F; } </style> <body> <img src='https://www.buy2earn.co.uk/images/logo.png' width='240' height='100'> <hr> <h3>Welcome to buy2earn.co.uk!</h3> <p> Welcome <?php echo $username:?> just shows Welcome ................... How do I send the variables in the email? Cheers Hello, i am not good at php so need some help.I have a php page with check box from where i am trying to send mail to multiple recipient. i can send mail but with little problem. when i select eg. 3 check box to send email then 1st email recipient is ok but 2nd email goes with 1st and 2nd recipient and 3rd email goes 1st,2nd,3rd recipient. i guess having problem with 'foreach'. will someone pls help me to send individual email to individual recipient with my MySQL query's. Here is my code for mail.php page Code: [Select] <?php require_once('auth.php'); ?> <html> <head> <title>PHPMailer - SMTP basic test with authentication</title> </head> <body> <?php include("Connections/connection.php"); //error_reporting(E_ALL); error_reporting(E_STRICT); date_default_timezone_set('Europe/Dublin'); require_once('php_mailer/class.phpmailer.php'); //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded $mail = new PHPMailer(); //$body = file_get_contents('contents.php'); //$body = eregi_replace("[\]",'',$body); $sender_name = $_SESSION['sender_name']; $sender_email = $_SESSION['sender_email']; $sender_password = $_SESSION['sender_password']; $id_user = $_POST["id_user"]; foreach ($id_tariff as $idt) { $query = sprintf("SELECT From_Date, To_Date, first, last, city, country, Email_1, Email_2, account_name FROM user_info where id_user = $id_user"); $result = mysql_query($query) or die(mysql_error()); $body = " <table width='100%' border='1' cellspacing='0' cellpadding='3' bordercolor='#ffcccc'> <tr> <th bgcolor='#cc3333'>From</th> <th bgcolor='#cc3333'>To</th> <th bgcolor='#cc3333'>First Name</th> <th bgcolor='#cc3333'>Last Name</th> <th bgcolor='#cc3333'>City</th> <th bgcolor='#cc3333'>country</th> </tr> "; while($row = mysql_fetch_array($result)){ $body .="<tr>"; $body .="<td>".$row['From_Date']."</td>"; $body .="<td bgcolor='#FFE8E8'>".$row['To_Date']."</td>"; $body .="<td>".$row['first']."</td>"; $body .="<td bgcolor='#FFE8E8'>".$row['last']."</td>"; $body .="<td>".$row['city']."</td>"; $body .="<td bgcolor='#FFE8E8'>".$row['country']."</td>"; $body .="</tr>"; $to1 = $row['Email_1']; $to2 = $row['Email_2']; $account_name = $row['account_name']; } $body .="</table>"; $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "smtp.gmail.com"; // SMTP server $mail->SMTPDebug = 1; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "ssl"; $mail->Host = "smtp.gmail.com"; // sets the SMTP server $mail->Port = 465; // set the SMTP port for the GMAIL server $mail->Username = "$sender_email"; // SMTP account username $mail->Password = "$sender_password"; // SMTP account password $mail->SetFrom($sender_email,$sender_name); $mail->AddReplyTo("$sender_email","$sender_name"); $mail->Subject = "Hello Dear $account_name"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; $mail->MsgHTML($body); $mail->AddAddress($to1,$account_name); $mail->AddAddress($to2,$account_name); if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "YOUR E-MAIL HAS SENT"; } } ?> </body> </html> Thanks in advance. Hi, I'm new to PHP and servers and wonder if its possible to send email from a PHP application that I created in Eclipse running on a MAC using MAMP. This would be done while connected on WiFi, lets say in a coffee shop. Thanx |