PHP - E-mail Script Problem
So, I'm trying to make a script that will send emails from apparently anyone.
Code: [Select] <?php $email = $_REQUEST['email'] $target = $_REQUEST['target'] $message = $_REQUEST['message'] $subject = $_REQUEST['subject'] mail( $target, $subject, $message, "From: $email" ); echo "Mail sent." ; ?> Here's the HTML, if it matters. Code: [Select] <html> <head> <title>EMAIL SPOOFER</title> </head> <body> <p>This program can make emails appear as if they came from any email address, real or fake!</p> <form method="post" action="mailspoof.php"> Apparent sender: <input name="email" type="text" /><br /> Subject: <input name="subject" type="text" /><br /> Recipient: <input name="target" type="text" /><br /> Message:<br /> <textarea name="message" rows="15" cols="40"> </textarea><br /> <input type="submit" /> </form> </body> </html> Here's the error I'm getting from my webhost: Parse error: syntax error, unexpected T_VARIABLE in /home/a5938041/public_html/mailspoof.php on line 3 If I know me, it's probably the most stupid mistake in the universe, so please point it out. ::) Similar TutorialsHello to all out there! this is my first post,so my question may sound a bit simple. :] I am studying PHP and MySQL and I tried to make a mailing form based on a mysql database. My problem occured when I tried to use the PEAR mail object. Here is my code: // THE INCLUDED FILES require_once ("attach_file.php" ); require_once ("Mail.php" ); require_once ("Mail\mime.php" ); //THE VARIABLES TAKEN FROM THE HTML FORM OR JUST CREATED FOR THE CONSTRUCTION OF THE EMAIL $my_email = "something@gmail.com"; $email_subject = mysql_real_escape_string(trim( $_POST['email_subject']),$server_connect ); $email_body = mysql_real_escape_string(trim( $_POST['email_body'] ),$server_connect ); $attached_file = $destination ; // the $destination variable comes from the copy() function in attach_file.php $username = "the_username@gmail.com"; $password = "the_password"; $host = "smtp.gmail.com"; $attach = new Mail_mime(); $attach -> addAttachment($attached_file); $email_body = $attach->get(); $extraheaders = array('from'=>$my_email,'to'=>$email_etaireias,'subject'=>$email_subject,'Bcc'=>$email_etaireias); $headers = $attach -> $headers($extraheaders); // HERE GIVES ME AN ERROR!!! -->Fatal error: Method name must be a string $smtp_info = array('host'=>$host,'auth'=>TRUE,'username'=>$username,'password'=>$password); $smtp = Mail::factory('smtp',$smtp_info); //loop through every single line of the database until there are no more lines with data //and store each line in 3 different variables that i can use while ( $row = mysql_fetch_array($result) ) { $onoma_etaireias = $row['onoma_etaireias']; $email_etaireias = $row['email_etaireias']; $website_etaireias = $row['website_etaireias']; } //construct the mail function . The @ is supressing the errors created .remove it and they will be shown. $mail = @$smtp->send($email_etaireias,$headers,$email_body); As i searched here and there for a solution, i found that it has something to do with the way the mail-mime object creates the body of the email . I also tried to find a solution from the PEAR documentation. do i create the headers someway wrong????? I have a notification system that notifies users of new comments, inside the email I have images, some of the logo, some of different people, everything shows up fine on my computer (yahoo email), however in the iPhones email application no images show up, there are just the blue squares with the question marks in them. I'm not sure what I'm missing. Code: [Select] $from = "Kithell <notifications@kithell.com>"; $headers = "From:" . $from ."\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $subject = name($from_id, 'fl').$action; $message = '<html><body> <style>@charset "utf-8"; /* CSS Document */ .e-container { background-color: #FFF;position: relative;width: 90%;min-height:1px;margin-right: auto;margin-left: auto; } .e-container .e-m-header { padding: 2px; background-image: url(http://www.kithell.com/assets/tall-grey-header.png); background-repeat: repeat-x; border: 1px solid #CCC; background-position: bottom; display: block; text-align: center; } .e-container p { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; color: #666; vertical-align: text-top; display: inline-block; } .e-container .e-usr-photo { display: inline-block; margin: 10px; float: left; background-color: #F4F4F4; } .e-container p a { font-weight: bold; color: #3F60A3; text-decoration: underline; padding: 0px; float: left; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 0px; } .e-container .e-quotes { font-size: 20px; font-weight: bold; color: #999; font-family: Tahoma, Geneva, sans-serif; display: block; padding: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 75px; margin-top:10px; } .e-container .e-message { font-size: 13px; color: #333; padding: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 10px; clear: none; display: inline; }</style> <div class="e-container"><div class="e-m-header"><img src="http://www.kithell.com/assets/kithell-logo.png" /></div><img class="e-usr-photo" src="http://www.kithell.com/'.photo($from_id, 55).'" /><br /><p><a target="_blank" href="http://www.kithell.com/#/profile&id='.$from_id.'">'.name($from_id, "fl").' </a> '.$action.'<div class="e-quotes">"<p class="e-message">'.nl2br(htmlentities(stripslashes($message))).'</p>"</div></p></div></body></html>'; mail($to,$subject,$message,$headers); This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=347009.0 Hello, so I have input form for feedback with php mail send but i also want to send a sms message to user. This is html: <div class="fs-form-wrap" id="fs-form-wrap"> <form id="form" class="fs-form fs-form-full" action="#" method="post" autocomplete="off"> <ol class="fs-fields"> <li> <label class="fs-field-label fs-anim-upper" for=Name?</label> <input class="fs-anim-lower" id="q1" name="q1" type="text" placeholder="Name" required/> </li> <li> <label class="fs-field-label fs-anim-upper" for="q2" data-info="Vaild eamil....?</label> <input class="fs-anim-lower" id="q2" name="q2" type="email" placeholder="email@email.com" required/> </li> <li> <label class="fs-field-label fs-anim-upper" for="q3" data-info="Valid phone number">Phone number...?</label> <input onkeypress='return event.charCode >= 48 && event.charCode <= 57' class="fs-anim-lower" id="q3" name="q3" type="text" maxlength="10" placeholder="09x-xxx-xxxx" required/> </li> <li> <label class="fs-field-label fs-anim-upper" for="q4" data-info="What do you think about our servise?">Feedback</label> <textarea class="fs-anim-lower" id="q4" name="q4" placeholder="Feedback.."></textarea> </li> </ol><!-- /fs-fields --> <button class="fs-submit" type="submit" name="submit" id="send" >Send</button> </form> </div> This is php mail: <?php if(isset($_POST["submit"])){ //Checking for blank Fields.. if($_POST["q1"]==""||$_POST["q2"]==""||$_POST["q3"]==""||$_POST["q4"]==""){ echo "Fill everything.."; }else{ // Check if the "Sender's Email" input field is filled out $email=$_POST['q2']; // Sanitize e-mail address $email =filter_var($email, FILTER_SANITIZE_EMAIL); // Validate e-mail address $email= filter_var($email, FILTER_VALIDATE_EMAIL); if (!$email){ echo "Invalid Sender's Email"; } else{ $subject = $_POST['q3']; $message = 'Name: ' . $_POST['q1'] . ' Email: ' . $_POST['q2'] . ' Phone Number: ' . $_POST['q3'] . ' Feedback: ' . $_POST['q4']; $headers = 'From:'. $email . "\r\n"; // Sender's Email // message lines should not exceed 70 characters (PHP rule), so wrap it $message = wordwrap($message, 70); // Send mail by PHP Mail Function mail("myemail@mydomain.com", $subject, $message, $headers); echo "Thank you for feedback"; } } } ?> I have public sms getaway on my computer so when user input his phone script make link like this "http://mysmsgetaway....message-from-us" and it goes to my getaway.. Thank you 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..? Code: [Select] <?php $ip = $_POST['ip']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; $visitor = $_POST['visitor']; $visitormail = $_POST['visitormail']; $notes = $_POST['notes']; $attn = $_POST['attn']; #================================================================================================== #this looks for email if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) #================================================================================================== { echo "<h2>Use Back - Enter valid e-mail</h2>\n"; $badinput = "<h2>Feedback was NOT submitted</h2>\n"; echo $badinput; die ("Go back! ! "); } #================================================================================================== #this making sure all fields have been filled if(empty($visitor) || empty($visitormail) || empty($notes )) { #================================================================================================== echo "<h2>Use Back - Please fill in all fields</h2>\n"; die ("Use back! ! "); } #================================================================================================== #This is looking for captcha ====================================================================== session_start(); if ($_POST['captcha'] == $_SESSION['captcha']) #==================================================================================================== { $todayis = date("l, F j, Y, g:i a") ; $attn = $attn ; $subject = $attn; $notes = stripcslashes($notes); $message = " $todayis [EST] \n Attention: $attn \n Message: $notes \n From: $visitor ($visitormail)\n Additional Info : IP = $ip \n Browser Info: $httpagent \n Referral : $httpref \n "; $from = "From: $visitormail\r\n"; if ($attn == "Chairperson") mail("emailhere", $subject, $message, $from); if ($attn == "Securtary") mail("email here", $subject, $message, $from); if ($attn == "Treausure") mail("email here", $subject, $message, $from); if ($attn == "Training") mail("email here", $subject, $message, $from); if ($attn == "Expeditions") mail("email here", $subject, $message, $from); if ($attn == "Webmaster") mail("email here", $subject, $message, $from); ?> ok the thing is that it sends a email to Chairperson email but it will not send to the rest shuld i be useing "elseif"? Hi everyone, I have been asked to look into the below E-mail validation script due to a number of people not being able to register their E-mail address on a website of mine. For example, people who's E-mail address begins with a.bcde@fghij.com cannot register and receives an e-mail validation error message. TBH, I pinched the code from somewhere else and do not understand how it works exactly. Could someone help identify which part of the code needs changing? I have highlighted the area of code I believe needs changing, but would appreciate some help. Thanks, function checkemail() { var str = document.getElementById('register-email').value; if ((str.indexOf(".") > 2) && (str.indexOf("@") > 0)) { document.getElementById('emailcheck1').style.backgroundPosition = "top left"; return true; } else { document.getElementById('emailcheck1').style.backgroundPosition = "bottom left"; return false; } } I have the need for a script that will "bounce" and email to a set number of users. I was told that this is possible with PHP but am not sure how to implement something like this. Here's a scenario: I have an email, "all_users@example.com". When an email is sent to this address, "it" checks for all users and then sends that same email to all users. Now if I have a role called "Super User", and an email address called super_users@example.com, it would do the same as above except would send to only the addresses with role, "Super User". I have no clue where to start researching this and if it's even possible. Hi All, I am attaching the code of my php script, the script needs to send mail , but is unable to do so.Your help will be greatly appreciated. Thanks Tanu My first post! Im sorry it has to be a question.. But im also sharing! I found a great php to mail script with attachment. I added it as a text file for if ur intrested in the whole code. Its really easy for adding to your form and has a great way of posting errors. Now my question: The script works great with 1 attachment but how do i add a second attachment? I tried so many things but how hard can it be? Lets say this is a part of your html to upload your files: <html> <body> <form method="post" class="appnitro" action="<?php echo basename($_SERVER["PHP_SELF"]); ?>" enctype="multipart/form-data"> <li id="li_8" > <label class="description" for="element_8">Upload your logo </label> <div> <input name="probe" class="element file" type="file"/> <?php if (isset($_POST['probe'])) echo htmlentities(stripslashes($_POST['probe'])); else echo ""; ?> </div> <p class="guidelines" id="guide_8"><small>Upload your logo here. there is a max of 1 mb</small></p> </li> <li id="li_9" > <label class="description" for="element_9">Upload foto 1 </label> <div> <input name="probe2" class="element file" type="file"/> <?php if (isset($_POST['probe2'])) echo htmlentities(stripslashes($_POST['probe2'])); else echo ""; ?> </div> <p class="guidelines" id="guide_9"><small>Upload your logo here. there is a max of 1 mb</small></p> </li> </form> </body> </html> Heres a part of the php processing // if attachment, MIME-Mail: if (isset($_FILES['probe']['name']) && trim($_FILES['probe']['name']) != "") { // read and encode file: $datei_content = fread(fopen($_FILES['probe']['tmp_name'],"r"),filesize($_FILES['probe']['tmp_name'])); $datei_content = chunk_split(base64_encode($datei_content),76,"\n"); //? encode a second file here? // Boundary: $boundary = md5(uniqid(rand())); // Attachment: $mail_header .= "\n--".$boundary; $mail_header .= "\nContent-Type: ".$_FILES['probe']['type']."; name=\"".$_FILES['probe']['name']."\""; $mail_header .= "\nContent-Transfer-Encoding: base64"; $mail_header .= "\nContent-Disposition: attachment; filename=\"".$_FILES['probe']['name']."\""; $mail_header .= "\n\n".$datei_content; //? attach a second file here? // End: $mail_header .= "\n--".$boundary."--"; Cant i duplicate the encoding and attaching and rename? what am i missing here? Can someone please help me out here? Tnx. Hello Everyone, I've successfully created a form script to check to make sure all my fields are filled out. However, I wanted to create an if statement to check and see if the email address is valid and it contains both and "@", "." symbols. If not then echo '' This is not a Valid email address " if its not correct. Could someone tell me the proper way to write this and incorporate this into my existing script below. Thank you all Again for your Help thanks mrjap1 Code: [Select] // Confirm All feild were filled out when submit button was pressed if($name && $email && $username && $password && $confirm_password) { // Confirm that the NAME that you used is NOT greater than 30 characters if(strlen($name)>24) { echo "<h2><center>YOUR NAME IS TOO LONG!!!!</center></h2><br>"; } // Confirm that the EMAIL that you used is NOT greater than 25 characters if(strlen($email)>25) { echo "<h2><center>YOUR EMAIL IS TOO LONG!!!!</center></h2><br>"; } // Confirm that the USERNAME that you used is NOT greater than 10 characters if(strlen($username)>10) { echo "<h2><center>YOUR USERNAME IS TOO LONG!!!!</center></h2><br>"; } else { // Confirm that the PASSWORD that you used MATCH & Between 6 and 15 characters if(strlen($password)>10 || strlen($password)<6) { echo "<h2><center>YOUR PASSWORD MUST BE BETWEEN 6 and 15 CHARACTERS!!!!</center></h2><br>"; } if($password == $confirm_password) { This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=347725.0 Forbidden You don't have permission to access /cgi-bin/sendmail.php on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. I have a basic mail script (with the standard mail function: mal() ) that I use for a confirmation email (in a users sign up form). The form and the mail is almost always successfully submitted. Although every once in a while, I get the following error : 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() BTW, the users input is succesfully inserted into the database; but he never recieves the confirmation mail.... i'm running php 5.3 in wamp server with windows xp sp3 <?php $Name = "my name"; //senders name $email = "mymail@gmail.com"; //senders e-mail adress $recipient = "some_mail@hotmail.com"; //recipient $mail_body = "The text for the mail..."; //mail body $subject = "Subject for reviever"; //subject $header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields ini_set('sendmail_from', 'mymail@gmail.com'); //Suggested by "Some Guy" ini_set('SMTP', 'smtp.gmail.com'); //Suggested by "Some Guy" ini_set('smtp_port', 465); //Suggested by "Some Guy" $result = mail($recipient, $subject, $mail_body, $header); //mail command return $result; ?> some one help me please I am trying to get the PHP mail function to work. I am using a WAMP server and php.ini is set to: [mail function] ; For Win32 only. SMTP = localhost smtp_port = 25 ; For Win32 only. ;sendmail_from = ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ;sendmail_path = ; Force the addition of the specified parameters to be passed as extra parameters ; to the sendmail binary. These parameters will always replace the value of ; the 5th parameter to mail(), even in safe mode. ;mail.force_extra_parameters = My PHP script looks like this: <php? $to = "djbouch@comcast.net"; $subject = "Test mail"; $message = "Hello! This is a simple email message."; $from = "djbouch@comcast.net"; $headers = "From:" . $from; mail($to,$subject,$message,$headers); echo "Mail Sent."; ?> For some reason the mail won't send and I am getting the following message: 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() Thanks for your help with this. Daniel Hello! Dear all, I'm having this problem with PHP Mail From Name, it took me entire day, and still haven't figure out the issue...that is... In "From: ", if I have it in simple email format, such as "From: name@server.com" it works...but when I have it with a From Name, eg. "From: Name <name@server.com>", then it just wouldn't send... I heard that some of the servers just won't parse "Name <name@server.com>", if it is the case...would there be any work around to get that From Name appeared? The code is attached below, any help is deeply appreciated! <?php //For Captcha include("settings.php"); header("Content-Type: text/html; charset=utf-8"); @session_start(); $string = strtoupper($_SESSION['string']); $userstring = strtoupper($_POST['userstring']); @session_destroy(); if (($string != $userstring) || (strlen($string) <= 4)) { header("location:contact_us.php"); exit(); } //PHP Mail starts here $form_name = $_POST["name"]; $form_company = $_POST["company"]; $form_email = $_POST["email"]; $form_phone = $_POST["phone"]; $form_mobile = $_POST["mobile"]; $form_msg = $_POST["msg"]; $form_date = date(Y)."-".date(m)."-".date(d); $form_ip = $_SERVER["REMOTE_ADDR"]; $form_lang = "en"; $fromname = "Name"; $frommail = "name@server.com"; @require("../default_timezone.php"); $con = mysql_connect("host","user","pass"); mysql_query("SET NAMES 'utf8'"); if (!$con) { die("Could not connect: " . mysql_error()); } mysql_select_db("dbname", $con); mysql_query("INSERT INTO tablename (CU_Name, CU_Company, CU_Email, CU_Tel, CU_Mobile, CU_Content, CU_CreateDate, CU_IP, lang) VALUES ('$form_name', '$form_company', '$form_email', '$form_phone', '$form_mobile', '$form_msg', '$form_date', '$form_ip', '$form_lang')"); $message = (" <table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\"> <tr> <td colspan=\"2\" align=\"left\"><img src=\"contact_logo.gif\" /></td> </tr> <tr> <td colspan=\"2\" align=\"left\"><font style=\"font-size: 12px; color: #000;\">Your email is recceived, a representative will be contacting you soon.</font></td> </tr> <tr> <td width=\"70\" align=\"left\"><font style=\"font-size: 12px; color: #000;\"><b>Name:</b></font></td> <td width=\"430\" align=\"left\"><font style=\"font-size: 12px; color: #000;\">{$form_name}</font></td> </tr> <tr> <td align=\"left\"><font style=\"font-size: 12px; color: #000;\"><b>Company:</b></font></td> <td align=\"left\"><font style=\"font-size: 12px; color: #000;\">{$form_company}</font></td> </tr> <tr> <td align=\"left\"><font style=\"font-size: 12px; color: #000;\"><b>Email:</b></font></td> <td align=\"left\"><font style=\"font-size: 12px; color: #000;\">{$form_email}</font></td> </tr> <tr> <td align=\"left\"><font style=\"font-size: 12px; color: #000;\"><b>Phone:</b></font></td> <td align=\"left\"><font style=\"font-size: 12px; color: #000;\">{$form_phone}</font></td> </tr> <tr> <td align=\"left\"><font style=\"font-size: 12px; color: #000;\"><b>Mobile:</b></font></td> <td align=\"left\"><font style=\"font-size: 12px; color: #000;\">{$form_mobile}</font></td> </tr> <tr> <td align=\"left\" valign=\"top\"><font style=\"font-size: 12px; color: #000;\"><b>Message:</b></font></td> <td align=\"left\" valign=\"top\"><font style=\"font-size: 12px; color: #000;\">{$form_msg}</font></td> </tr> </table> "); $subject = "Email Subject"; $mime_boundary = md5(uniqid(mt_rand(), TRUE)); $header = "From: ".$fromname." <".$frommail.">\r\n"; $header.= "To: " . $to . "\r\n"; $header.= "MIME-Version: 1.0\r\n"; $header.= "Content-Type: multipart/mixed; \r\n"; $header.= " boundary=". $mime_boundary . "\r\n"; $content = "This is a multi-part message in MIME format.\r\n"; $content .= "--" . $mime_boundary . "\r\n"; $content .= "Content-Type: text/html; charset=utf-8\r\n"; $content .= "Content-Transfer-Encoding: 8bit\r\n\r\n"; $content .= $message. "\r\n"; $to=$form_email; @mail($to, $subject, $content, $header); $to2="my@server.com"; @mail($to2, $subject, $content, $header); echo "<html>"; echo "<head>"; echo "<META HTTP-EQUIV='Content-Type' content='text/html; charset=utf-8'>"; echo "<META HTTP-EQUIV='Refresh' CONTENT='3; URL=http://www.server.com/'>"; echo "</head>"; echo "<body>"; echo "Thank you for contacting us!"; echo "<br />"; echo "Your message is sent."; echo "</body>"; echo "</html>"; ?> I have this code in borrow.php Whenever they click the button 'sendMail' an email is sent to that user who tries to borrow that specific book (the book details are left out cuz we don't need them here) Code: [Select] <?php global $interface; global $user; if (isset($_POST['sendMail'])){ $to = $partner->email; $subject = "ILB Request"; if(!isset($user->id)){ $lastname = $_POST['lastname']; $firstname = $_POST['firstname']; $email = $_POST['email']; $telephone = $_POST['telephone']; $fax = $_POST['fax']; }else{ $lastname = $user->lastname; $firstname = $user->firstname; $email = $user->email; $telephone = $user->telephone; $fax = $user->fax; } $message = " <html> <body> <h2>Loaner Details</h2> <table> <tr> <td>Name: </td> <td>" . $lastname . "</td> </tr> <tr> <td>First Name: </td> <td>" . $firstname . "</td> </tr> <tr> <td>Email: </td> <td>" . $email . "</td> </tr> <tr> <td>Telephone: </td> <td>" . $telephone . "</td> </tr> <tr> <td>Fax: </td> <td>" . $fax . "</td> </tr> </table> </body> </html> "; // Always set content-type when sending HTML email $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; // More headers if(!isset($user->id)){ $headers .= 'From: <' . $_POST['email'] . '>' . "\r\n"; }else{ $headers .= 'From: <' . $user->email . '>' . "\r\n"; } if(!empty($email)){ if(mail($to,$subject,$message,$headers)){ $interface->assign('success', "Your IBL request has been sent succesfully!"); }else{ $interface->assign('success', "Your IBL request has failed!"); } }else{ $interface->assign('success', "Email address has to be filled in!"); } } And then there is this code in Edit.php: Whenever a person changes someone elses profile (like an admin), the person whos profile is being changed needs to be notified by email. It's the same function as before though it gives this error: "Warning: 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:\vufind\web\services\MyResearch\Edit.php on line 182" But the php.ini file hasn't been changed, and it doesn't give error the the previous code above (+ I receive the email) So I add to the file below: Code: [Select] <?php ini_set("SMTP","mySMTPserver."); ini_set("smtp_port","25"); ?> and now i get this msg... "Warning: mail(): SMTP server response: 503 5.5.2 Need Rcpt command." Code: [Select] <?php global $interface; global $user; if (isset($_POST['submit'])) { if(isset($_GET['userID'])){ $updateUser = new User(); if($user->id != $_GET['userID']){ $to = $updateUser->email; $subject = "Profile has been changed by " . $user->firstname . " " . $user->lastname; $message = " <html> <body> <h2>Notification</h2> <br /><br /> Hi, <br /><br /> This is an email notification you receive when your profile has been changed! </body> </html>"; // Always set content-type when sending HTML email $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; // More headers $headers .= 'From: admin@felnet.be' . "\r\n"; echo $to . " " . $subject . " " . $message . " " . $headers; if(mail($to,$subject,$message,$headers)){ $interface->assign('sent', "Success!"); }else{ $interface->assign('sent', "Fail!"); } } I really need help with this I have a php script that queries the database and then sends a separate email but I was just recently told they would like each query to to be put in an email so we only send one like the way i made it below (sorry if it's sloppy) if anyone can help I would greatly appreciate it. Thanks in advance ___________________________________ Name | Date | Address | State | _______|_____|______________|______ | John | 3/18 | 215 5th Street | NY | ______ |____ |______________|______ | Bob | 4/15 | 505 North Street | NY | ______ |____ |_____________ |______ | Jane | 5/9 | 6 main Street | MD | ______ |____|_______________ | ______| Ann | 1/12 | 9 West Ave | CA | ______ |____ |_______________|______ | I have a messaging system that I'm trying to send a notification by email to a specific person when a new message is entered. Everything is working fine except how the message is displayed in the email. Here's the problem: When the message reads: "This is a test. This should be two lines down. This is on the next line!" this is what is displayed in the email: "This is a test.\r\n\r\nThis should be two lines down.\r\nThis is on the next line!" How I'm displaying the message is by inserting it into a database first. Then I do a query to pull it back from the database on another page using the variable $message. I have tried using just $message and using nl2br("$message") and they both display as shown above. Does anyone have any ideas on how to get the message to display properly in the email? Here's the code that I'm using to send it in if it will help: Code: [Select] <?php $message2 = nl2br("$message"); $sendto2 = "$email"; $emailsubject2 = "New Message"; $emailmessage2 = "<html> <body> <table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td> $prefix $lname, <p> This message is to notify you that a new message has been sent. A copy of the message has been included below.<br> <hr width=\"500\"><br> <strong>Subject: \"$subject\"</strong> <p>$message2</p> Thank you! </td> </tr> </table> </body> </html>"; // To send HTML mail, the Content-type header must be set $headers2 = 'MIME-Version: 1.0' . "\r\n"; $headers2 .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers2 .= 'From: Admin <support@domain.us>' . "\r\n"; // Mail it mail($sendto2, $emailsubject2, $emailmessage2, $headers2); ?> |