PHP - Problem With Mail Not Getting Past My Server
Hi, I am having a problem with my Website mail. Basically the mail was working fine yesterday but last night I edited the PHP script slightly because for some reason the page that it was directed to had gone missing and was turning up an 404 error, which was just a newsuince as the email was still sent. So I just edited it so that it echo'ed a message saying thanks. but is seems today the mail is not getting to its destination. The PHP returns no errors and returns the success message fine but after saying its been sent it never appears.
I have tried different email addresses on different servers and that was no use and I have also changed the code back to how it was yesterday. and it still doesn't work. I have also put the page up on one of my other sites which I know everything is set up properly and it works fine, making me think that it is a mail setup issue. but as I did not set up the mail at all and quite frankly don't really understand it, I don't know how it is meant to be set up as I just use google apps for sites that I set up. So yeah I am trying to work out what could have gone wrong since yesterday but I don't really understand it, below is the code as it as now and as it was yesterday: Code: [Select] <?php $EmailFrom = "johnshale@hotmail.co.uk"; $EmailTo = "matthale.live@gmail.com"; $Subject = "Website enquiry"; $Name = Trim(stripslashes($_POST['Name'])); $Tel = Trim(stripslashes($_POST['Tel'])); $Email = Trim(stripslashes($_POST['Email'])); $Message = Trim(stripslashes($_POST['Message'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Tel: "; $Body .= $Tel; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Message: "; $Body .= $Message; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> and the page is at www.sullyco.co.uk/contactengine.php as you can see the page is redirecting to a page that does not exist(contactthanks.php) indicating that the message was sent successfully. it is also the part I edited as a quick fix last night I just got it to echo a success message. Thanks for any help on this, I have been trying to work it out all morning, Matt Similar TutorialsThis topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=347009.0 $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 m newbie to PHP. I am trying to host the website on my laptop but due to some configuration i cant send the emails through php script. I am trying send mail through mail() but not able to sent mail. heres the code: $to = "jwalant.baria@gmail.com"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; if (mail($to, $subject, $body)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } Output: Message delivery failed.. I read the previous post here. but I am not able to figure out what to do about it. Can anyone tell me what setting i do in my php.ini? or any other that necessary settings require for this. i don't have SMTP server on my laptop so is there any method from which i can setup the SMTP server on laptop.? I use apache HTTP 2.2 and PHP 5.3.4 Rest of the website working correctly but only mail not working. TY..!! Hello, im using a contact form which sends me an email with the data name.. comments .. Now im testing a new better server which use IMAP (old POP3) and my form is not working like it used to be.. Code: [Select] $emailTo = " $dbSentEmail"; //Put your own email address here $emailServer = "noreply@totalsports.com.cy"; //Put your own email address here $body = "Name: $name \n\nEmail: $email \n\nSubject: $subject \n\nComments:\n $comments"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/plain; charset=UTF-8' . "\r\n"; $headers .= 'From: Contact Form <'.$emailServer.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $subject, $body, $headers); Any idea what i have to do to work like before? Say I have an email info@website.com created in cPanel on a web hosting company. I want to send email notifications to users on my website. I am using PHP Mailer to send the emails. But all the emails go directly into their junk box/spam folder, unless they confirm that info@website.com is not junk. I am wondering if there is a work around for this? Hi, I want to read multipart messages. If i send a mail from Gmail or yahoo, the body of the message is not read properly. I also want to read all the messages properly. Can someone give me the code for it? I am developing an email application for the first time. Thanks Raja Hi, I have Code: [Select] $to = 'rberbe2002@msn.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: webmaster@example.com'; mail($to, $subject, $message, $headers); which works fine on a shared hosting website I have, but not on a website I have on my dedicated server. Any ideas or suggestions please? 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????? Hi. I am sending out email with a php script - about 5000 at a time by send 15 or so every 20 seconds which works fine. Sometimes I need to add an attachemnt. I then find that the script will keep stalling. Is there a way to test the server qmail/mail queue to see if it isready to send another message? - rather than send it and have the script stall? It may be enough to simply be able to check that the number of messages left to be sent in the queue? Have search a lot for help on this with no results. Any server/qmail experts out there? Thanks Paul I have a PHP web system that store in a windows server. In the system, there is a function for user to upload files to another server (Shared server in Unix). When i try to upload a file, it gives warning: Warning: move_uploaded_file(\\unixserver/sharedfolder/upload/test.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\wamp\www\upload\index.php on line 40 For your information, my username has been assigned in xxx's group that has access to read and write on that folder. Besides, i'm able to open,create and delete files on that folder's server manually (samba). The safe mode setting is off. Does anybody has any idea why this thing happen? 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); 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!"); } } 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 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 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 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 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 Okay, I have a healing spell that allows people to regain stats when it's cast. But, how do I limit it so that they can't go over their maxhp? Here's what I have so far: $db->execute("UPDATE `users` SET `hp`=?, `mp`=?, `energy`=? WHERE `id`=?", array($player->hp + $healspell, $player->mp - $spell['mp'], $player->energy - $spell['energy'], $player->id)); What do I need to do in this to tell it to limit it to the maxhp but never going over it? $healspell is a random number, so it is quite possible to go over the maxhp at the moment. Thank you! Hi, I have website: http://bazaro.org/ I want put ADS in this place: IMG is he I don't know where past code in my theme. ? I bought this website few day ago. thanks for help |