PHP - Php Mail Error 500
Hiya guys,
Have just developed a new mass mailing system for a client, they are getting some emails sent back to them saying that this error has occured: returning message to sender 500 Line too long I've googled this and found some information on it relating to a certain amount of characters have been passed in one line, and this is something to stop hacking attempts. What command can I use on the code to stop this? The content contains HTML and CSS. Hope someone can help me on this! Thanks alot! Glen Similar TutorialsWarning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\wahab_gl\register.php on line 65 i am getting the above error on running the following code.. i am using the local host at the moment $password=md5($password); $repeatpassword=md5($repeatpassword); //generate random number for activation process $random = rand(23456789,98765432); $query = mysql_query(" INSERT INTO users VALUES ('','$fullname','$username','$password','$email','$date','$random','0') "); $to = $email; $subject = "Activate your account!"; $headers = "From: ayaz.haneef@gmail.com"; $server = "mailhost.sheffield.co.uk"; ini_set("SMTP",$server); $body = " Hello $fullname, \n\n You need to activate your account with the link below: http://localhost/register.php?id=$lastid&code=$random\n\n Thanks! "; $lastid = mysql_insert_id(); mail($to, $subject, $body, $headers); die("You have been registered! Check your email to activate your account!"); help please 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 This code is to active an account by email, but whei i register any user, this message appears: Warning: mail() [function.mail]: Failed to connect to mailserver at "miniRelay" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\RegisterByEmailActivation\register.php on line 42. Code: [Select] <?php include 'global.php'; if (@$_POST['register']) { include 'connect.php'; //get form data $username = addslashes (strip_tags($_POST['username'])); $password = addslashes (strip_tags($_POST['password'])); $email = addslashes (strip_tags($_POST['email'])); if (!$username||!$password||!$email) { echo "Please fill out all the fields!"; } else { //encrypt password $password = md5($password); //check if username already taken $check = mysql_query ("SELECT * FROM users WHERE username ='$username'") or die(mysql_error()); if (mysql_num_rows($check)>=1) { echo "Username already taken"; } else { // generate random code $code = rand (11111111,99999999); // send activation email $to = $email; $subject = "Activate your account"; $body = "Hello $username,\n\nYou registered and need to activate your account, click the link below or paste it into the URL var of your browser\n\n http://localhost/RegisterByEmailActivation/activate.php?code=$code\n\nThanks!"; if (!mail($to, $subject, $body)) { echo"We could not sing up at this time, please try again later!"; } else { //register into database $register = mysql_query("INSERT INTO users VALUES ('','$username','$password','$email','$code','0')"); echo "You have been registered successfully! please check your email ($email) to activate your account"; } } } } ?> <html> <form action='register.php' method='POST'> Choose your username:<br /> <input type='text' name='username'><p /> Choose password:<br /> <input type='password' name='password'><p /> Email:<br /> <input type='text' name='email'><p /> <input type='submit' name='register' value='register'> </form> </html> This is my "php.ini" configuration for mail function: [mail function] ; For Win32 only. ; http://php.net/smtp SMTP = localhost ; http://php.net/smtp-port smtp_port = 25 ; For Win32 only. ; http://php.net/sendmail-from sendmail_from = ilovelinkinpark@live.com.ar Quote ilovelinkinpark@live.com.ar is my email I'm getting the following error: Quote Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in (file path) I'm sure this error has been posted before, but I've searched and can't find a solution. I'm running XAMPP 1.7.3 with the Mercury/32 mail server v.4.72, which IS set to permit SMTP relaying of non-local mail. Is there anything I can change in php.ini, or anywhere else for that matter, to solve this? I'm tearing my hair out with this... If I can just get it to send out this email, my project is finished, but I've been wrestling with this mail() function for about 3 hours. Any help would be appreciated. Hi guys please i need your help . i created a HTML/PHP form . The PHP form handles posting to my mail while the HTML is the front face / webpage . Anyway i created a form that has fields such as name (textbox), email(textbox) , inquiry(textarea) , state (textbox) country (dropdown list ) , how did you find us (dropdown list). However whenever i test the form all it posts to my mailbox is name , email , inquiry . Please how do i make the other fields get recognized / how do i get the details in the other fields to be posted to my mailbox. the following isnt sending mail() Code: [Select] $to=$_POST['CustomerEmail']; $from = "s@xaa.com"; $Cc = "s@xaa.com"; $headers = "From:" . $from; $headers = "Cc:" . $Cc; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; i believe it's the dot before the equal sign Hi, I'm getting the below error while sending mail. Error: Code: [Select] Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for cys@kdkd.com in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mail.php on line 39 Code: Code: [Select] if (isset($_POST["submit"])) { $to = strip_tags($_POST["to"]); $sub = strip_tags($_POST["sub"]); $feedback = strip_tags($_POST["feedback"]); $from = strip_tags($_POST["from"]); $to= "xyz@gmail.com"; $sendto = $to; $subject = $sub; $message = $feedback; $headers ="MIME-Version:1.0\r\n"; $headers .="content-type:text/html; Charset=iso-8859-1\r\n"; $headers .="From: <" . "$from" . ">\r\n"; $headers .="X-Sender: <" . "$sendto" . ">\r\n"; $headers .="Return-Path: <" . "$sendto" . ">\r\n"; $headers .="Error-To: <" . "$sendto" . ">\r\n"; $sendto = trim($sendto); $themail= mail($sendto, $subject, $message, $headers) ; } Kindly help. Thanks, Ramki I get this error message and no email when I test this form Warning: mail() [function.mail]: Failed to connect to mailserver at "127.0.0.1" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() ini_set() in \\boswinfs02\home\users\web\b1835\ez.srcfresnocom\PCHSubscomplete.php on line 28 Line 28 is the $send = and the web address is assigned by the webhosting service. Is the problem with my mail function code? Code: [Select] <?php $to = 'survey@srcfresno.com'; $subject = 'PCH subs'; if (get_magic_quotes_gpc()) { $_POST = array_map('stripslashes',$_POST); } $fields = array( 'firstname' => 'First Name', 'lastname' => 'Last Name', 'email' => 'Email', 'phone' => 'Phone', 'muchspend' => 'How much did you spend on your purchase today?' ); $body = "PCH subs:\n\n"; foreach($fields as $a => $b) { if(array_key_exists($a,$_POST)) { $body .= sprintf("%s: %s\n",$b,$_POST[$a]); } } $send = mail($to, $subject, $body); if($send) {print ""; } else {print "We encountered an error sending your mail, please notify webmaster@srcfresno.com"; } ?> Hopefully there is a simple solution to this. I have a form that when submitted sends a message to an email address from the form. A customer fills it out, so there is no single one email address. However, half of the time, the retards that use this form dont know their own email address and dont bother to put the .net at the end of it. or they misspell it. The other half of the time they dont even bother to put the @ and the domain. They still think this is AOL for some god unknown reason. And I cant account for all the ways that they can not figure out how to fuck up their email address, so an email-validator doesnt work because they can even beat that and still manage to break it. For example, one guy named Mike continues to put the first half of his email in as Miek or Mik or just spelled completely wrong, and the 550 error that comes up when he puts that garbage in, which is most of the time (I think the guy is blind or something) is because his email address doesnt exist on the mail server because he cant spell it right, when on the off chance he actually does get the @domain.com in the end. I really hate my retard customers. So my simple little form blows up on them. But what I am trying to do is to have something like this if(@mail(args)) { //success, I'll call them back shortly } else { //youre a retard, please put in your email address correctly } However, the error handling isnt working. mail() is supposed to return FALSE if it encounters an error, an error that I'd rather put in an error log and not display to the customer, however, the error suppressor doesnt work. Any Suggestions? Hi Experts, When I try to send email from my web page (using PHP) I get the following error in my code. I am using Dreamweaver CS3. My php code : <?php $name = $_POST['name']; $address = $_POST['address']; $email = $_POST['email']; $message = $_POST['message']; $message1 = " Somaone has contacted through the website . \n Name : $name \n Address : $address \n Email : $email \n Message : $massage \n " ; $from = " From : $email "; mail('mail1@yahoo.com','Contact from our website', $message1, $from); ?> Error : Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\sendmail.php on line 17 [ line 17 -> mail('mail1@yahoo.com','Contact from our website', $message1, $from); ] Thanks in advance for all your suggestions. 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. Created a simple html form. Upon submission, it's suppose to email the information entered in the form to the designated recipient. Instead, I get the error "The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access. " -------------------------------------------------------------------------------- Code: [Select] <!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" xml:lang="en" lang="en"> <head> <title>Mail Function</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <?php $recipient = "me@yahoo.com"; $subject = "Registration Submission"; $body = "<h2>Registration Information:</h2>"; $body .= "\r\nName: ($_POST['name'])"; $body .= "\r\nEmail: ($_POST['email']"; $body .= "\r\nQuestion: ($_POST['question']"; if (mail($recipient, $subject, $body)) { print("Email successfully sent!"); } else { print("The email could not be sent."); } ?> <form method="post"> <h2 align="center">Week 2 Project--Sending Email</h2> <br /> <div> <p>Enter your name and email address, a question, and click "Submit":</p><br /> <p>Name:<input type="text" name="name" size="20"></p> <p>Email:<input type="text" name="email" size="20"></p> <p>Question:<input type="text" name="question" size="20"></p> </div> <br /> <div><input type="submit" name="submit" value="Submit" /></div> <br /> <div> <input type="reset" name="Reset" value="Start Over" /> </div> </form> </body> </html> Using simple mail.php script. Yet I am getting the dreaded Fatal error: Call to undefined method Mail::AddAttachment() in ... error
"Fatal error: Call to undefined method Mail::AddAttachment() in \\...\www\mail.php on line 59"
This is mail.php
<?php class Mail { var $parts; var $to; var $cc; var $bcc; var $from; var $headers; var $subject; var $body; var $html; var $host; var $port; function __construct() { $this->parts = array(); $this->to = ""; $this->cc = ""; $this->bcc = ""; $this->from = ""; $this->subject = ""; $this->body = ""; $this->headers = ""; $this->html = true; } function buildMultipart() { $boundry = "HKC".md5(uniqid(time())); $multipart = "Content-Type: multipart/mixed; boundary = \"$boundry\"\n\n"; $multipart .= "This is a MIME encoded message.\n\n--$boundry"; for($i = sizeof($this->parts)-1; $i >= 0; $i--) { $multipart .= "\n".$this->buildMessage($this->parts[$i])."--$boundry"; } return $multipart .= "--\n"; } function getMail($complete = true) { $mime = ""; if(!empty($this->from)) { $mime .= "From: ".$this->from."\n"; } if(!empty($this->headers)) { $mime .= $this->headers."\n"; } if($complete) { if(!empty($this->cc)) { $mime .= "Cc: ".$this->cc."\n"; } if(!empty($this->bcc)) { $mime .= "Bcc: ".$this->bcc."\n"; } if(!empty($this->subject)) { $mime .= "Subject: ".$this->subject."\n"; } } if(!empty($this->body)) { $this->AddAttachment($this->body,"",($this->html?"text/html":"text/plain")); } $mime .= "MIME-Version: 1.0\n".$this->buildMultipart(); return $mime; } function send() { if(!empty($this->cc)) { $mime = $this->getMail(true); } else { $mime = $this->getMail(false); } if(!empty($this->host)) { ini_set("SMTP",$this->host); } return mail($this->to,$this->subject,$this->body,$mime); } } ?>And this is the program that makes the call: <?php if (isset($_POST["email"])) { $email = $_POST["email"]; $email= str_replace("'", "''", $email); require_once('../database.php'); $sql="select fa_id,name from freeagents where email='".$email."'"; $emailSearch = mssqlquery($sql); if (!mssqlhasrows($emailSearch)) { mssqlclose(); header("Location: http://www.baltimorebeach.com"); exit(); } $row = mssqlfetchassoc($emailSearch); mssqlclose(); $salt=$row["fa_id"].".baltimorebeach."; $check=hash('ripemd160', $salt.$email); $strMailBody = <<<MAILBODY Hi $row[name], <br><br> A request was made to change your Baltimore beach volleyball free agent registration information. <br><br> If you want to update your registration information click on this link: http://www.baltimorebeach.com/FreeAgents/registerfreeagent.php?email=$email&check=$check <br><br> To remove your name from the Free Agent list deselect all the checkboxes when you update your information. MAILBODY; require_once('../mail.php'); $message = new Mail(); $message->from = "noreply@baltimorebeach.com"; $message->to = $email; $message->subject = "Baltimore Beach Volleyball Free Agent Registration Update Link"; $message->body = $strMailBody; $message->html = true; $message->send(); } ?> <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script> <style type="text/css"> label.error { color:red; } input.error { border:1px solid red; } </style> <script type="text/javascript"> $().ready(function () { // validate registration form on keyup and submit $("#emailform").validate({ rules: { email: { required: true, email: true } }, messages: { email: { required: "Please enter an email address", email: "Please enter a valid email address" } } }); }); </script> </head> <body> To update your free agent registration information enter your email to send yourself a baltimorebeach.com url link that will allow you to access your own registration details. <br> To remove yourself from the free agent list just deselect all the leagues you have previously selected when updating your information. <br> <br> <?php if (!isset($_POST["email"])) { ?> <form id="emailform" action="sendlink.php" method="post"> E-Mail: <input type="text" id="email" name="email" value=""/> <br> <input type="submit" id="sumbit" value="Send"> </form> <?php } else { echo "E-Mail Sent. "."You will receive an email with the update link at the email address your requested shortly"; } ?> </body> </html>I did not write this code, however the person who did is no longer available to me. I can't seem to figure out how to remove this error. Thanks so much! $to=sammieave@ave.com,samuel@ave.com; $subject = "New Event Logged"; $message = "Test"; $headers = "From: Samuel<sammieave@ave.com>;\r\n"; $headers .= "Content-Type: text/html"; mail($to,$subject,$message,$headers); I am having the above code but unfortunately the error I am getting is: Warning: mail() [function.mail]: SMTP server response: 550 Requested action not taken: mailbox unavailable or not local in C:\xampp\htdocs\CRM\support\mailer.php on line 139 Hello! I have the following php code: Code: [Select] <?php // The message $message = "[request("Id_From")]\n [request("ID")]\n [request("CUT")]\n [request("MAKE")]\n [request("CARAT")]\n [request("PRICE_PC")]\n [request("CLARITY")]\n [request("LOCATION")]\n [request("CERTIFICATE")]\n [request("SUP_STOCK_REF")]\n [request("Measurements")]\n [request("Total_Depth")]\n [request("Polish")]\n [request("Table_Width")]\n [request("Symmetry")]\n [request("Crown_Height")]\n [request("Culet")]\n [request("Parillion_Depth")]\n [request("Graining")]\n [request("Girdle")]\n [request("Remarks")]\n [request("TotalPrice")]"; // In case any of our lines are larger than 70 characters, we should use wordwrap() $message = wordwrap($message, 70); // Send mail('gary.impact@gmail.com', 'HIGH PRIORITY DIAMOND ORDER!', $message); ?> where I am trying to send an email to myself which will send me the listed 'requested' values. These values are to the script in the form of: Code: [Select] http://www.somedomain.com/somepage.html?Id_From=123&ID=50250430&CUT=Round&MAKE=VG+-+G++++&CARAT=.5&PRICE_PC=5719&COLOR=D&CLARITY=VVS1&LOCATION=California+%28U.S.A.%29&CERTIFICATE=GIA&SUP_STOCK_REF=3540-6&Measurements=5.03x5.08x3.17&Total_Depth=62.7%25&Polish=V.good&Table_Width=60%25&Symmetry=Good&Crown_Height=&Culet=None&Parillion_Depth=&Graining=&Girdle=&Fluorescence=None&Remarks=&TotalPrice=2860 I am getting the error: Code: [Select] Parse error: syntax error, unexpected T_STRING Which starts on the first line of my requested data ("[request("Id_From")]\n). Any help on this would be truely appreciated! Thank you! I'm setting up a newsletter thing for my website. I have a newsletter table in MySQL: Quote +----------------+------+--------+ | email | mens | womens | +----------------+------+--------+ | test2@test.com | 1 | 1 | | test1@test.com | 1 | 0 | +----------------+------+--------+ I am using a HTML form and this PHP code I learn't from the manual, which sends out e-mail's. PHP: if ($_POST['newsletter'] == 'Mens') { $to = ''; $subject = $_POST['subject']; $body = $_POST['body']; $header = 'From: Me Someone <me@someone.com>'; mail($to, $subject, $body, $header); } What I want to do with the above code is send out an e-mail to all the e-mails in my MySQL database that are tagged '1' under mens. How would I go about doing this? I'm guessing I will have to use a MySQL query in the $to = ''; that goes something like this: $to = '$query (select from `newsletters` where `email` = 1'); ? I am using magento for sending mail with condition, My code: <?php class Gta_MerchantNotification_Model_Observer { public function merchantremainder($Observer) { $order = $Observer->getEvent()->getOrder(); $order_details = $order->getAllVisibleItems(); $itemData = array(); foreach ($order_details as $list) { $incrementid = $order->getIncrementId(); $sku = $list->getsku(); $name = $list->getName(); $price = $list->getPrice(); $Qty = $list->getQtyOrdered(); $extra = $order->getIncrementId(); $message = " <tr> <!-- <td>$incrementid</td> --> <td>$sku</td> <td>$name</td> <td>$price</td> <td>$Qty</td> </tr>"; $itemData[$list->getId()] = $message; } $finalMessage = " <p>Order Id : $incrementid</p> <table border='1'> <tr> <!-- <th>Id</th> --> <th>Sku</th> <th>Product name</th> <th>Price</th> <th>Qty Ordered</th> </tr>"; if (!empty($itemData)) { foreach ($itemData as $data) { $finalMessage .= $data; } $finalMessage .= "</table>"; $this->sendMail($finalMessage); } } public function sendMail($message) { $body ="$message"; $emailTemplate = Mage::getModel('core/email'); $emailTemplate->setFromName('abc'); $emailTemplate->setBody($body); $emailTemplate->setSubject("Custom Email from observer"); $emailTemplate->setType('html'); $emailTemplate->setToEmail('abc@gmail.com'); $emailTemplate->send(); } } ?>
Output :
If order placed mail send to abc@gmail.com. I want :
1) If SKU starts with 2, email should go to the mail id abc@gmail.com,
2) If SKU starts with 3, email should go to the mail id xyz@gmail.com,
3) If SKU starts with 4, email should go to the mail id qwe@gmail.com,
FYI - If an order contains 10 items email should go separately based on SKU. But an order id the same must include all the emails.
Hello 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????? |