Jump to content

Search the Community

Showing results for tags 'mail'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hey guys, I've run into a problem on my website. I need to send two emails when a form is processed. One is to me, one is to the person submitting the form. I've been using mail() but its performance is sketchy at best. Sometimes the email sends, sometimes is doesn't. Any suggestions on how to reliably send emails? I want to be sure I get the information I need, and they get a confirmation email.
  2. For some reason, the PHP mail function causes my Visual Studio local testing environment to crash ("VS web server quit unexpectedly, starting new instance.") No email is sent or received either. mail('myemail@yahoo.com', 'message', "Hello World"); Help much appreciated ^^
  3. I want to create a form where you can upload a file and that can be sent as an attachment of an e-mail. I've have two alternatives, one using PHPMailer, and the other not using PHPMailer. My problems are as listed: 1. When using PHPMailer, I'm getting the `SMTP:Could Not Connect()` error even though all the SMTP credentials are right. 2. When not using PHPMailer, I'm getting an error in the `fopen()` function. Even then, I'm receiving the file, but its empty. I'm really a starter with PHP, so need help on this one. I'm posting both the codes here. 1. Using PHPMailer: <?php require('PHPMailer/class.phpmailer.php'); if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED //$email_to = "email"; //$email_subject = "Request for Portfolio check up from ".$first_name." ".$last_name; $title = array('Title', 'Mr.', 'Ms.', 'Mrs.'); $selected_key = $_POST['title']; $selected_val = $title[$_POST['title']]; $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // not required $comments = $_POST['comments']; // required if(($selected_key==0)) echo "<script> alert('Please enter your title')</script>"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message = ""; $email_message .="Title: ".$selected_val."\n"; $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; $allowedExts = array("doc", "docx", "xls", "xlsx", "pdf"); $temp = explode(".", $_FILES["file"]["name"]); $extension = end($temp); if ((($_FILES["file"]["type"] == "application/pdf") || ($_FILES["file"]["type"] == "application/msword") || ($_FILES["file"]["type"] == "application/excel") || ($_FILES["file"]["type"] == "application/vnd.ms-excel") || ($_FILES["file"]["type"] == "application/x-excel") || ($_FILES["file"]["type"] == "application/x-msexcel") || ($_FILES["file"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document") || ($_FILES["file"]["type"] == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0) { echo "<script>alert('Error: " . $_FILES["file"]["error"] ."')</script>"; } else { if(move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"])) $file=fopen("upload/".$_FILES["file"]["name"], 'r'); } } else { echo "<script>alert('Invalid file')</script>"; } // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); //Create a new PHPMailer instance $mail = new PHPMailer(); //Tell PHPMailer to use SMTP $mail->IsSMTP(); //Enable SMTP debugging // 0 = off (for production use) // 1 = client messages // 2 = client and server messages $mail->SMTPDebug = 2; //Ask for HTML-friendly debug output $mail->Debugoutput = 'html'; //Set the hostname of the mail server $mail->Host = "hostname"; //Set the SMTP port number - likely to be 25, 465 or 587 $mail->Port = 465; //Whether to use SMTP authentication $mail->SMTPAuth = true; //Username to use for SMTP authentication $mail->Username = "email"; //Password to use for SMTP authentication $mail->Password = "password"; //Set who the message is to be sent from $mail->SetFrom($email_from, 'First Last'); //Set an alternative reply-to address //$mail->AddReplyTo('replyto@example.com','First Last'); //Set who the message is to be sent to $mail->AddAddress('email', 'name'); //Set the subject line $mail->Subject = 'Request for Profile Check up'; //Read an HTML message body from an external file, convert referenced images to embedded, convert HTML into a basic plain-text alternative body $mail->MsgHTML($email_message); //Replace the plain text body with one created manually $mail->AltBody = 'This is a plain-text message body'; //Attach an image file $mail->AddAttachment($file); //Send the message, check for errors if(!$mail->Send()) { echo "<script>alert('Mailer Error: " . $mail->ErrorInfo."')</script>"; } else { echo "<script>alert('Your request has been submitted. We will contact you soon.')</script>"; } } ?> 2. No PHPMailer: <?php $title = array('Title', 'Mr.', 'Ms.', 'Mrs.'); $selected_key = $_POST['title']; $selected_val = $title[$_POST['title']]; $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // not required $comments = $_POST['comments']; // required if(($selected_key==0)) echo "<script> alert('Please enter your title')</script>"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message = ""; $email_message .="Title: ".$selected_val."\n"; $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; $email_to = "email"; // The email you are sending to (example) //$email_from = "sendfrom@email.com"; // The email you are sending from (example) $email_subject = "subject line"; // The Subject of the email //$email_txt = "text body of message"; // Message that the email has in it $destination=$_FILES["file"]["name"]; move_uploaded_file($_FILES["file"]["name"], $destination); $fileatt = fopen($_FILES['file']['name'],'r'); // Path to the file (example) $fileatt_type = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; // File Type $fileatt_name = "Details.docx"; // Filename that will be used for the file as the attachment $file = fopen($fileatt,'r'); $data = fread($file,filesize($fileatt)); fclose($file); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers="From: $email_from"; // Who the email is from (example) $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_txt; $email_message .= "\n\n"; $data = chunk_split(base64_encode($data)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; mail($email_to,$email_subject,$email_message,$headers); ?> And the form, with corresponding action: <form name="contactform" method="post" action="send2.php" enctype="multipart/form-data"> <table width="100%" border="0" align="center"> <tr> <td valign="middle" id="ta"> <label for="title">Title *</label> </td> <td valign="middle" id="ta"> <select name="title"> <option value="0">Title</option> <option value="1">Mr.</option> <option value="2">Ms.</option> <option value="3">Mrs.</option> </select></td></tr><tr><td id="ta"> <label for="first_name">First Name *</label> </td> <td valign="middle" id="ta"> <input type="text" name="first_name" maxlength="50" size="30" required="required"> </td> </tr> <tr> <td valign="middle" id="ta"> <label for="last_name">Last Name *</label> </td> <td valign="middle" id="ta"> <input type="text" name="last_name" maxlength="50" size="30" required="required"> </td> </tr> <tr> <td valign="middle" id="ta"> <label for="email">Email Address *</label> </td> <td valign="middle" id="ta"> <input type="text" name="email" maxlength="80" size="30" required="required"> </td> </tr> <tr> <td valign="middle" id="ta"> <label for="telephone">Telephone Number *</label> </td> <td valign="middle" id="ta"> <input type="text" name="telephone" maxlength="30" size="30" required="required"> </td> </tr> <tr> <td valign="middle" id="ta"> <label for="comments">Details</label> </td> <td valign="middle" id="ta"> <textarea name="comments" maxlength="100000" cols="25" rows="6"></textarea> </td> </tr> <tr> <td valign="middle" id="ta"> <label for="file">Or upload a file (only word, excel or pdf)</label> </td> <td valign="middle" id="ta"> <input type="file" name="file"> </td> </tr> <tr> <td colspan="2" style="text-align:center" id="ta"> <input type="submit" value="Submit"> </td> </tr> </table> </form> For reference, you may go to http://rsadvisories.com
  4. Hi, I have use the below link to make a contact form; http://www.websitecodetutorials.com/cod ... dation.php When I submit the form I get an error '22527'. Cant work out what it is and having searched I can't make sense of other answers mainly because I am only just starting out in PHP. The Form <form method="post" action="bookingform1.php"> <ul> <li class='field'><input class="xwide text input" id='iyc-form-width' type="text" placeholder="First Name" name="firstname" maxlength="25"></input></li> <li class='field'><input class="xwide text input" id='iyc-form-width' type="text" placeholder="Last Name" name="lastname" maxlength="25"></input></li> <li class='field'><input class="xwide text input" id='iyc-form-width' type="text" placeholder="Nationality" name="nationality" maxlength="25"></input></li> <li class='field'><input class="xwide text input" id='iyc-form-width' type="text" placeholder="Date Of Birth" name="dob" maxlength="25"></input></li> <li class='field'><input class="xwide text input" id='iyc-form-width' type="text" placeholder="Gender" name="gender" maxlength="15"></input></li> <li class='field'><input class="xwide text input" id='iyc-form-width' type="text" placeholder="Occupation" name="occupation" maxlength="40"></input></li> <li class='field'><input class="xwide text input" id='iyc-form-width' type="text" placeholder="Home Address" name="address" maxlength="80"></input></li> <li class='field'><input class="xwide text input" id='iyc-form-width' type="text" placeholder="E-mail Address" name="email" maxlength="80"></input></li> <li class='field'><input class="xwide text input" id='iyc-form-width' type="text" placeholder="Telephone Number" name="telephone" maxlength="25"></input></li> <p id='iyc-bold'>Your preferred choice of programme date</p> <li class="field" id='text_align_left'> <div class="picker" id='iyc-picker-width'> <select name="first"> <option>October 12-19th 2013</option> <option>November 16-23rd 2013</option> <option>January 18-25th 2014</option> <option>February 15-22nd 2014</option> <option>March 15-22nd 2014</option> </select> </div> </li> <p id='iyc-bold'>Your second choice, (should your preferred date be unavailable)</p> <li class="field" id='text_align_left'> <div class="picker" id='iyc-picker-width'> <select name="second"> <option>October 12-19th 2013</option> <option>November 16-23rd 2013</option> <option>January 18-25th 2014</option> <option>February 15-22nd 2014</option> <option>March 15-22nd 2014</option> </select> </div> </li> <p id='iyc-bold'>What experience do you have of the english language (self-taught/lessons/on-line programmes/immersion programmes)</p> <li class='field'><textarea class="input textarea" rows="6" placeholder="Background & experience" name="experience" maxlength="600"></textarea></li> <p id='iyc-bold'>Why do you want to attend the programme? (practice the language/to get a job/promotion/expand career opportunities/social)</p> <li class='field'><textarea class="input textarea" rows="6" placeholder="What do you want to get out?" name="why" maxlength="600"></textarea></li> <p id='iyc-bold'>How did you hear about the A.B.C. Experience Programme?</p> <li class='field'><textarea class="input textarea" rows="6" placeholder="How did you find us?" name="how" maxlength="600"></textarea></li> <p id='iyc-bold'>Additional information (include any dietary or other special needs you may require.)</p> <li class='field'><textarea class="input textarea" rows="6" placeholder="Additional information" name="info" maxlength="600"></textarea></li> <li class="field"><label class="checkbox" for="checkbox1" id='text_align_left'><input name="checkbox1" type="checkbox" id="checkbox1" name="terms" value="0"><span></span> *By ticking this box you accept our terms and conditions as per the below</label></li> <div class="pretty warning danger btn icon-left info-circled" id='iyc-btn'><a href="termsandconditions.pdf" target="_blank">Terms & Conditions</a></div> </ul> <div align="center"> <!-- <h4>For e-mail security purposes please enter in the words above and then click submit below.</h4> --> </div> <div class="pretty medium default btn" style='margin-top:20px;'><input type="submit" value="Submit"></input></div> </form> <?php // Input Your Personal Information Here $mailto = 'oliver@edwardsltd.co.uk' ; $from = "ABC Experience England Website - Participants" ; $formurl = "http://www.dev.abcexperienceengland.co.uk/bookingform1.php" ; $errorurl = "http://www.dev.abcexperienceengland.co.uk/formmailerror.php" ; $thankyouurl = "http://www.dev.abcexperienceengland.co.uk/thankyou.php" ; // End Edit // prevent browser cache header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); function remove_headers($string) { $headers = array( "/to\:/i", "/from\:/i", "/bcc\:/i", "/cc\:/i", "/Content\-Transfer\-Encoding\:/i", "/Content\-Type\:/i", "/Mime\-Version\:/i" ); if (preg_replace($headers, '', $string) == $string) { return $string; } else { die('You think Im spammy? Spammy how? Spammy like a clown, spammy?'); } } $uself = 0; $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ; if (!isset($_POST['email'])) { header( "Location: $errorurl" ); exit ; } // Input Your Personal Information Here $firstname = remove_headers($_POST['firstname']); $lastname = remove_headers($_POST['lastname']); $nationality = remove_headers($_POST['nationality']); $dob = remove_headers($_POST['dob']); $gender = remove_headers($_POST['gender']); $occupation = remove_headers($_POST['occupation']); $homeaddress = remove_headers($_POST['homeaddress']); $email = remove_headers($_POST['email']); $telephone = remove_headers($_POST['telephone']); $first = remove_headers($_POST['first']); $second = remove_headers($_POST['second']); $experience = remove_headers($_POST['experience']); $why = remove_headers($_POST['why']); $how = remove_headers($_POST['how']); $info = remove_headers($_POST['info']); $terms = remove_headers($_POST['terms']); $http_referrer = getenv( "HTTP_REFERER" ); // End Edit if (!preg_match("/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i",$email)) { header( "Location: $errorurl" ); exit ; } // Input Your Personal Information Here if (empty($firstname) || empty($lastname) || empty($nationality) || empty($dob) || empty($gender) || empty($occupation) || empty($homeaddress) || empty($email) || empty($telephone) || empty($first) || empty($second) || empty($experience) || empty($why) || empty($how) || empty($info) || empty($terms)) { header( "Location: $errorurl" ); exit ; } // End Edit if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) { header( "Location: $errorurl" ); exit ; } if (get_magic_quotes_gpc()) { $comments = stripslashes( $comments ); } // sets max amount of characters in comments area (edit as nesesary) if (strlen($comments) > 1250) { $comments=substr($comments, 0, 1250).'...'; } // End Edit $message = "This message was sent from:\n" . "$http_referrer\n\n" . // Input Your Personal Information Here "First Name: $firstname\n\n" . "Last Name: $lastname\n\n" . "Nationality: $nationality\n\n" . "DOB: $dob\n\n" . "Gender: $gender\n\n" . "occupation: $occupation\n\n" . "homeaddress: $homeaddress\n\n" . "E-mail: $email\n\n" . "Telephone: $telephone\n\n" . "first: $first\n\n" . "second: $second\n\n" . "What experience do you have: $experience\n\n" . "Why do you want: $why\n\n" . "How did you hear about us: $how\n\n" . "Other Information: $info\n\n" . "Agree to the terms: $terms\n\n" . "\n\n------------------------------------------------------------\n" ; // End Edit mail($mailto, $from, $message, "From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep ); header( "Location: $thankyouurl" ); exit ; ?> http://www.dev.abcexperienceengland.co.uk/ I am using GUMBY as the CSS framework. As mentioned I am a newbie to PHP so apologise in advance for any stupid mistakes. Any help to get this working would be much appreciated. Thanks in advance Olly Edwards
  5. Hi, I managed to set up a simple smtp with sendmail and gmail in the PHP mail function. The thing is, is it possible to change the "from" email address to a different one, than the gmail account I'm using? No matter which $from I assign, the from address is always my gmail account, which I am using to send mails. Thanks
  6. I have been working on an application where I need to send a zip file to my registered users. I'm not worried about speed to get the emails out, I just need to be sure I can send out the files to everyone. I am using phpmailer right now and it works for about 7 minutes, sends out 40 emails and than I get a 500 error and it quits, I am using an SMTP relay server my company uses and its not working out. Anyone have suggestions on a better way of getting this done? Here is a snippet of code: $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $phpMailer->SMTPKeepAlive = true; $mail->Host = "relay.appriver.com"; // SMTP server //$mail->SMTPDebug = 2; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = "relay.appriver.com"; // sets the SMTP server $mail->Port = 2525; // set the SMTP port for the GMAIL server $mail->Username = "username"; // SMTP account username $mail->Password = "password"; // SMTP account password $mail->From = "donotreply@domain.com" ; $mail->FromName = "ReEntry Website"; $mail->AddAddress("someone@domain.com"); $mail->WordWrap = 50; // set word wrap to 50 characters $mail->AddAttachment("../Placards/placards.zip"); // add attachments //$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name $mail->IsHTML(true); // set email format to HTML $mail->Subject = 'ReEntry Request '; $mail->Body = "Parish Placards"; $mail->AltBody = "Parish Placards"; if(!$mail->Send()) { echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; }else{ $stringData = "<p align=\"left\">Placards have been sent to " . $email . "</p>"; fwrite($fh, $stringData); }
  7. When sending email using the mail function in PHP, I can't get the from field to show what I want it to. In the header, I set the from email to be webmaster@mysiteExample.com, but it comes out with somemailboxcode123@mysiteExample.com. How can I fix this? Here's a slightly modified version of my code function email($from, $name, $subject, $body){ $emailFrom="webmaster@mysite.com"; $headers = 'From: Web Form <' . $emailFrom . '>' . "\r\n" . 'Reply-To: ' . $aDifferentEmailAddress . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $send = mail($emailTo, $subject, $body, $headers); }
  8. Good Day All, I am very new to the php arena. I would please like some step by step assistance to setup a mailer for my local intranet(not hosted for internal use). If anyone has some advice I would appreciate it. I have searched the net, tried to load other code but get to the point where the feedback form will take me back to the home page but doesn't send the mail with no errors or warnings. Thanks in advance,
  9. Hi there I am trying to use the php mail function, but I am receiving this error: The requested URL /mailform.php was not found on this server. PHP <?php if (isset($_REQUEST['email'])) //if "email" is filled out, send email { //send email $email = $_REQUEST['email'] ; $subject = $_REQUEST['subject'] ; $message = $_REQUEST['message'] ; mail("myemail@yahoo.com", $subject, $message, "From:" . $email); echo "Thank you for using our mail form"; } else //if "email" is not filled out, display the form { echo "<form method='post' action='mailform.php'> Email: <input name='email' type='text'><br> Subject: <input name='subject' type='text'><br> Message:<br> <textarea name='message' rows='15' cols='40'> </textarea><br> <input type='submit'> </form>"; } ?> ( I replaced my email address with "myemail@yahoo.com" just for the forum... Thank you
  10. If I put this piece of code anywhere in my script it does NOT send out the mail but it DOES say that it was successful. I can't figure it out. <p><font color='red' size='2'>You are receiving this message because you have previously signed up to do so. If you would no longer like to be an exercise participant volunteer, click <a href='http://www.blah.com/participate/yes.php?id=" . $id . "&email=" . $to . "'> here</a> to remove yourself.</font></p> Here's the entire code: <? if (isset($_POST['Submit'])){ $sfname = $_POST["fname"]; $slname = $_POST["lname"]; $cname = $sfname . " " . $slname; $email = $_POST["email"]; $tele = $_POST["tele"]; $info = $_POST["editor1"]; if ($pword == $pword2){ $sql="SELECT * FROM participants2"; $result=mysql_query($sql); while($row = mysql_fetch_array($result)) { $id = $row['id']; $to = $row['email']; $fname = $row['pfname']; $message = "Hello " . $fname . ", <p> Below is a request for volunteer exercise participants. Follow the instructions accordingly, as they will all differ. Please direct any questions you have to the contact listed below.</p> <center> <p><font color='green'><b>If you volunteer for this event, PLEASE inform the Contact listed below that you heard about this opportunity through the Participant Database!!!</b></font></p> </center> <p>------------------- MESSAGE FOLLOWS --------------------</p> <p><b> Contact Name: </b>" . $cname . " <br><b> Contact E-mail: </b>" . $email . " <br><b> Contact Telephone: </b>" . $tele . " </p> <p>" . $info . "</p>"; $subject = "Call for Participants - EXERCISE REQUEST"; $headers = 'From: '. $cname .' <'. $email .'>' . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $response = mail($to,$subject,$message,$headers); if($response) {echo "Your Message Has Been Sent!<br>";} else {echo "Oh No, you screwed it up!";} }} else { ?> You have entered an incorrect password. Go back and try again. <? }} else { ?> There was an error processing this page. Error Code: 347 - Does Not Exist <? } ?> Any ideas?
  11. I think I need a second set of eyes. I've done mail functions before in php with no problems but I can't get this one to work for anything. My success message populates after I hit send so it doesn't appear there are any errors. Any advice would be appreciated.   <? php //If the form is submitted if(isset($_POST['submitted'])) { //Check to see if the honeypot captcha field was filled in if(trim($_POST['checking']) !== '') { $captchaError = true; } else { //Check to make sure that the name field is not empty if(trim($_POST['yourName']) === '') { $nameError = 'You forgot to enter your first name.'; $hasError = true; } else { $name = trim($_POST['yourName']); } //Check to make sure sure that a valid email address is submitted if(trim($_POST['email']) === '') { $emailError = 'You forgot to enter your email address.'; $hasError = true; } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) { $emailError = 'You entered an invalid email address.'; $hasError = true; } else { $email = trim($_POST['email']); } //Check to make sure comments were entered if(trim($_POST['comments']) === '') { $commentError = 'You forgot to enter your comments.'; $hasError = true; } else { if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['comments'])); } else { $comments = trim($_POST['comments']); } } //If there is no error, send the email if(!isset($hasError)) { $emailTo = 'territindle@hotmail.com'; $subject = 'Benefit Request from '.$name; $sendCopy = trim($_POST['sendCopy']); $body = "Name: $name \n\nEmail: $email \n\nComments: $comments"; $headers = 'From: The Website <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $subject, $body, $headers); if($sendCopy == true) { $subject = 'You emailed Your Name'; $headers = 'From: Your Name <territindle@hotmail.com>'; mail($email, $subject, $body, $headers); } $emailSent = true; } } } ?>
  12. Hi all, I'm sending an email with php as a part of my user registration process, and for some reason the mail script begins to fail when I use my full desired email in my headers. I use the standard PHP Manual headers for email: // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'To: Jake M*** <**********@gmail.com>' . "\r\n"; $headers .= "From: CFS <noreply@crossfitst.com>" . "\r\n"; Now, if I make my last header: $headers .= "From: CFS <noreply@crossfitstmarys.com>"."\r\n"; It fails! As soon as I put the m in on CrossfitStMarys it fails the whole script. Any ideas? Cheers. P.S. I have real data in for my Jake M, just censored it out because I don't want everyone having my email haha.
  13. I'm trying to have a form on my website where people can fill it out to request a quote. It will enter the quote request into a database and then send me an email with the details. My code below enters all the information into the database fine. However, the emails are not looking too good. Here is an example of what an email looks like when the visitor uses line breaks and ' in the fields: This is just a simple test. Nothing but a test.\r\n\r\nYep, this is just a test.\r\nAin\'t that cool? $name="$_POST[name]"; $email="$_POST[email]"; $phone="$_POST[phone]"; $message="$_POST[service]"; $ip=$_SERVER['REMOTE_ADDR']; $name = stripslashes($name); $email = stripslashes($email); $phone = stripslashes($phone); $message = stripslashes($message); $name = mysql_real_escape_string($name); $email = mysql_real_escape_string($email); $phone = mysql_real_escape_string($phone); $message = mysql_real_escape_string($message); // Make sure all required fields are used if(!$name){ die("Please go back and tell us your name"); } if(!$email){ die("Please go back and tell us your email address"); } if(!$message){ die("Please go back and tell us what type of service you are looking for"); } // Now send the email here $message = wordwrap($message, 90); $to = 'Name <email@email.com>'; $subject = 'Subject Here'; $message2 = "$name\n$email\n$phone\n\n$message\n\n======================================\nThis quote request was sent from:\n$_SERVER[HTTP_REFERER]"; 'Reply-To: $email' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $headers .= 'Content-type: text/html' . "\r\n"; mail( "$to", "$subject", $message2, "From: $name <$email>", $headers );
  14. I am having trouble learning how to a send an attachment using a PHP script. Any help is greatly appreciated. Below is my script followed by a snippet of my HTML: <?php $to = "jsmith@yahoo.com"; $subject = "Purchase Received!"; $email = $_REQUEST['email']; $mar_stat = $_REQUEST['mar_stat']; $client_name = $_REQUEST['client_name']; $spouse_name = $_REQUEST['spouse_name']; $client_dob_month = $_REQUEST['client_dob_month']; $client_dob_day = $_REQUEST['client_dob_day']; $client_dob_year = $_REQUEST['client_dob_year']; $spouse_dob_month = $_REQUEST['spouse_dob_month']; $spouse_dob_day = $_REQUEST['spouse_dob_day']; $spouse_dob_year = $_REQUEST['spouse_dob_year']; $client_income = $_REQUEST['client_income']; $spouse_income = $_REQUEST['spouse_income']; $address = $_REQUEST['address']; $city = $_REQUEST['city']; $state = $_REQUEST['state']; $zip = $_REQUEST['zip']; $email = $_REQUEST['email']; $area = $_REQUEST['area']; $prefix = $_REQUEST['prefix']; $phone = $_REQUEST['phone']; $contact_method = $_REQUEST['contact_method']; $client_ret_age = $_REQUEST['client_ret_age']; $spouse_ret_age = $_REQUEST['spouse_ret_age']; $desired_gross_inc = $_REQUEST['desired_gross_inc']; $apprx_ret_invest = $_REQUEST['apprx_ret_invest']; $apprx_nonret_invest = $_REQUEST['apprx_nonret_invest']; $pension = $_REQUEST['pension']; $pension_comments = $_REQUEST['pension_comments']; $life_expect = $_REQUEST['life_expect']; $spouse_life_expect = $_REQUEST['spouse_life_expect']; $life_expect_comments = $_REQUEST['life_expect_comments']; $work_ret = $_REQUEST['work_ret']; $spouse_work_ret = $_REQUEST['spouse_work_ret']; $work_ret_comments = $_REQUEST['work_ret_comments']; $inheritance = $_REQUEST['inheritance']; $inheritance_comments = $_REQUEST['inheritance_comments']; $headers = "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: $email"; $message = "<b>Purchase Received! Customer Infromation Form</b><br><br><b>Married?:</b> $mar_stat<br><b>Client Name:</b> $client_name<br><b>Spouse_Name:</b> $spouse_name<br><b>Client DOB:</b> $client_dob_month-$client_dob_day-$client_dob_day<br><b>Spouse DOB:</b> $spouse_dob_month-$spouse_dob_day-spouse_dob_day<br><b>Client Income:</b> $client_income<br><b>Spouse Income:</b> $spouse_income<br><br><b>Address:</b> $address<br><b>City:</b> $city<br><b>State:</b> $state<br><b>Zip:</b> $zip<br><b>Email:</b> $email<br><b>Phone:</b> $area-$prefix-$phone<br><b>Best Contact Method:</b> $contact_method<br><br><b>Desired Client Retirement Age:</b> $client_ret_age<br><b>Desired Spouse Retirement Age:</b> $spouse_ret_age<br><b>Desired Gross Income:</b> $desired_gross_inc<br><b>Approximate Retirement Investments:</b> $apprx_ret_invest<br><b>Approximate Non-Retirement Investments:</b> $apprx_nonret_invest<br><br><b>Pension:</b> $pension<br><b>Pension Comments:</b> $pension_comments<br><br><b>Client Life Expectancy:</b> $life_expect<br><b>Spouse Life Expectancy:</b> $spouse_life_expect<br><b>Life Expectancy Comments:</b> $life_expect_comments<br><br><b>Client Working in Retirement:</b> $work_ret<br><b>Spouse Working in Retirement:</b> $spouse_work_ret<br><b>Working in Retirement Comments:</b> $work_ret_comments<br><br><b>Inheritance Expected:</b> $inheritance<br><b>Inheritance Comments:</b> $inheritance_comments"; $sent = mail($to, $subject, $message, $headers); if($sent) header( "Location: http://www.sspla.com/thankyou_purchase.html" ); else header( "Location: http://www.sspla.com/sorry_purchase.html" ); ?> Here is the HTML snippet: <!-- ATTACH DOCUMENTATION --> <fieldset> <legend> <b>Attach Statement</b> </legend> <table border="0" cellpadding="2" cellspacing="3"> <tr> <td align="left" valign="top"> <input type="file" name='statement' maxlength="275" /> <span style="font-size: .95em;"><i>NOTE: Failure to Attach Your Statement May Result in a Delay Proccessing Your Purchase</i></span> </td> </tr> </table> </fieldset> THANKS!
  15. Hi PHP Freaks, I have written a php email form and then this code behind it. When I run it comes up with the error page however all inputs are filled in and valid. Here is my code: <?php //variables from form $firstname = ucwords(strtolower($_POST['firstname'])); $lastname = ucwords(strtolower($_POST['lastname'])); $client_email_address = $_POST['email_address']; $subject = $_POST['subject']; $message = wordwrap($_POST['message'], 150, '<br />'); $fullname = $firstname.' '.$lastname; //error pages $email_successful_page = 'mail_successful.php'; //create mail_successful.php; $email_failed_page = 'delivery_failed.php'; //create delivery_failed.php; //create emailform.php (and in it the ability to read the error from this script and tell the user //set date date_default_timezone_set('Australia/NSW'); //email 1 is sent to the scd admin email $email_1_recipient_address = 'joshua.paduch@gmail.com'; //'systemadministrator@shellharbourcitydental.com.au'; $email_1_subject = 'Email sent to '.$dentist_name.' from '.$client_email.' regarding '.$subject; $email_1_message = '<html>\n\t<body>\n\t\t<img src=\"emailheader.jpg\" width="" height="" style="float:center;"/>\n\t\t'; $email_1_message .= '\n\t\t<h1>Hi System Administrator, </h1>'; $email_1_message .= '\n\t\t<br /><p>For records, </p>'; //$email_1_message .= ''; //$email_1_message .= ''; $email_1_headers = "From: autoresponder@shellharbourcitydental.com.au \r\n"; $email_1_headers .= "Reply-To: donotreply@shellharbourcitydental.com.au \r\n"; $email_1_headers .= "X-Mailer: PHP/".phpversion()." \r\n"; $email_1_headers .= "To: joshua.paduch@gmail.com \r\n"; $email_1_headers .= "Content-type: text/html; charset=UTF-8 \r\n"; $email_1_headers .= "MIME-Version: 1.0 \r\n"; //$email_1_headers .= " \r\n"; //email 2 is sent to the intended dentist / practitioner $email_2_recipient_address = 'joshua.paduch@gmail.com'; //'info@shellharbourcitydental.com.au'; $email_2_subject = $subject; $email_2_message = 'message'; //$email_2_message .= ''; //$email_2_message .= ''; $email_2_headers = "From: autoresponder@shellharbourcitydental.com.au \r\n"; $email_2_headers .= "Reply-To: donotreply@shellharbourcitydental.com.au \r\n"; $email_2_headers .= "X-Mailer: PHP/".phpversion()." \r\n"; $email_2_headers .= "To: joshua.paduch@gmail.com \r\n"; $email_2_headers .= "Content-type: text/html; charset=UTF-8 \r\n"; $email_2_headers .= "MIME-Version: 1.0 \r\n"; //$email_2_headers .= " \r\n"; //email 3 is a confirmation email sent to the client $email_3_recipient_address = $client_email_address; $email_3_subject = 'Confirmation Email Regarding: '.$subject; $email_3_message = 'message'; //$email_3_message .= ''; //$email_3_message .= ''; $email_3_headers = "From: autoresponder@shellharbourcitydental.com.au \r\n"; $email_3_headers .= "Reply-To: donotreply@shellharbourcitydental.com.au \r\n"; $email_3_headers .= "X-Mailer: PHP/".phpversion()." \r\n"; $email_3_headers .= "To: ".$client_email." \r\n"; $email_3_headers .= "Content-type: text/html; charset=UTF-8 \r\n"; $email_3_headers .= "MIME-Version: 1.0 \r\n"; //$email_3_headers .= " \r\n"; //form validation function function form_validation($var1,$var2,$var3,$var4,$var5){ if(isset($_POST['firstname']) && isset($_POST['lastname']) && isset($_POST['email_address']) && isset($_POST['subject']) && isset($_POST['message'])){ if(strlen($var1) < 1){ return false; $error = "firstname"; } elseif(strlen($var2) < 1){ return false; $error = "lastname"; } elseif(!filter_var($var3, FILTER_VALIDATE_EMAIL)){ return false; $error = "invalid email address"; } elseif(strlen($var4) < 1){ return false; $error = "subject"; } elseif(strlen($var5) < 1){ return false; $error = "message"; } else{ return true; } } else{ return false; } } //emailing function function email($email_1_var_1,$email_1_var_2,$email_1_var_3,$email_1_var_4,$email_2_var_1,$email_2_var_2,$email_2_var_3,$email_2_var_4,$email_3_var_1,$email_3_var_2,$email_3_var_3,$email_3_var_4){ if(!mail($email_1_var_1,$email_1_var_2,$email_1_var_3,$email_1_var_4)){ $email_error = "email 1 error"; } if(!mail($email_2_var_1,$email_2_var_2,$email_2_var_3,$email_2_var_4)){ $email_error = "email 2 error"; } if(!mail($email_3_var_1,$email_3_var_2,$email_3_var_3,$email_3_var_4)){ $email_error = "email 3 error"; } } //if form validation fails - redirect to error page - mail if(!form_validation($firstname,$lastname,$email_address,$subject,$message)){ header('Location: '.$email_failed_page.'?error='.$error); } else{ if(!email($email_1_recipient_address,$email_1_subject,$email_1_message,$email_1_headers,$email_2_recipient_address,$email_2_subject,$email_2_message,$email_2_headers,$email_3_recipient_address,$email_3_subject,$email_3_message,$email_3_headers)){ header('Location: '.$email_failed_page.'?email_error='.$email_error); } else{ header('Location: '.$email_succesful_page); } } Any advice is welcome. Thanks everyone, Timothy
  16. Hi PHP Freaks, I am currently having trouble with my mailing script. When I load it in the browser it comes up with the following error: 500 Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, webmaster@domain-name.com and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. There is no errors in the error_log and in the email failure email sent to my webmaster email it says it contained no recipient address but I have set that in the code. Here is the Code HTML Form: <form method="post" action="mail.php"> <label for="firstname">Firstname:</label> <input type="text" name="firstname" id="firstname" value="" /> <label for="lastname">Lastname:</label> <input type="text" name="lastname" id="lastname" value="" /> <label for="email_address">Email Address:</label> <input type="text" name="email_address" id="email_address" value="" /> <label for="subject">Subject:</label> <select name="subject" id="subject"> <option name="request_appointment" id="request_appointment" value="Request an Appointment">Request an Appointment</option> <option name="request_callback" id="request_callback" value="Request a Call-Back">Request a Call-Back</option> <option name="question" id="question" value="I Have a Question">I Have a Question</option> <option name="emergency" id="emergency" value="Emergency">Emergency (Call 0422 036 768)</option> <option name="other" id="other" value="Other">Other</option> </select><br /> <label for="message">Message:</label> <textarea name="message" id="message" cols="45" rows="10"></textarea> <button type="submit" value="submit"><span>Submit</span></button> </form> PHP Scripting <?php //declare variables $email_successful_page = 'mail_successful.php'; //create mail_successful.php; $email_failed_page = 'delivery_failed.php'; //create delivery_failed.php; //create emailform.php (and in it the ability to read the error from this script and tell the user //declare email variables $firstname = ucwords(strtolower($_REQUEST['firstname'])); $lastname = ucwords(strtolower($_REQUEST['lastname'])); $subject = $_POST['subject']; $message = wordwrap($_POST['message'], 150, '<br />'); $client_name = $firstname." ".$lastname; $dentist_name = $_REQUEST['dentist']; $dentist_email = $dentist_name.'@domain-name.com.au'; $client_email = $_POST['email_address']; //date date_default_timezone_set('Australia/NSW'); global $email_1_recipient_address, $email_1_subject, $email_1_message, $email_1_headers, $email_2_recipient_address, $email_2_subject, $email_2_message, $email_2_headers, $email_3_recipient_address, $email_3_subject, $email_3_message, $email_3_headers; //email 1 is sent to the scd admin email $email_1_recipient_address = 'systemadministrator@domain-name.com.au'; $email_1_subject = 'Email sent to '.$dentist_name.' from '.$client_email.' regarding '.$subject; $email_1_message = '<html>\n\t<body>\n\t\t<img src=\"emailheader.jpg\" width="" height="" style="float:center;"/>\n\t\t'; $email_1_message .= '\n\t\t<h1>Hi System Administrator, </h1>'; $email_1_message .= '\n\t\t<br /><p>For records, </p>'; $email_1_message .= ''; $email_1_message .= ''; $email_1_headers = "From: autoresponder@domain-name.com.au \r\n"; $email_1_headers .= "Reply-To: donotreply@domain-name.com.au \r\n"; $email_1_headers .= "X-Mailer: PHP/".phpversion()." \r\n"; $email_1_headers .= "To: joshua.paduch@gmail.com \r\n"; $email_1_headers .= "Content-type: text/html; charset=UTF-8 \r\n"; $email_1_headers .= "MIME-Version: 1.0 \r\n"; //$email_1_headers .= " \r\n"; //email 2 is sent to the intended dentist / practitioner $email_2_recipient_address = 'info@domain-name.com.au'; $email_2_subject = $subject; $email_2_message = 'message'; $email_2_message .= ''; $email_2_message .= ''; $email_2_headers = "From: autoresponder@domain-name.com.au \r\n"; $email_2_headers .= "Reply-To: donotreply@domain-name.com.au \r\n"; $email_2_headers .= "X-Mailer: PHP/".phpversion()." \r\n"; $email_2_headers .= "To: joshua.paduch@gmail.com \r\n"; $email_2_headers .= "Content-type: text/html; charset=UTF-8 \r\n"; $email_2_headers .= "MIME-Version: 1.0 \r\n"; //$email_2_headers .= " \r\n"; //email 3 is a confirmation email sent to the client $email_3_recipient_address = $client_email; $email_3_subject = 'Confirmation Email Regarding: '.$subject; $email_3_message = 'message'; $email_3_message .= ''; $email_3_message .= ''; $email_3_headers = "From: autoresponder@domain-name.com.au \r\n"; $email_3_headers .= "Reply-To: donotreply@domain-name.com.au \r\n"; $email_3_headers .= "X-Mailer: PHP/".phpversion()." \r\n"; $email_3_headers .= "To: ".$client_email." \r\n"; $email_3_headers .= "Content-type: text/html; charset=UTF-8 \r\n"; $email_3_headers .= "MIME-Version: 1.0 \r\n"; //$email_3_headers .= " \r\n"; //validate inputs function form_validation(){ function email_address_validation(){ //Validates & Sanitizes the email address if(!filter_var($client_email, FILTER_VALIDATE_EMAIL) && strlen($client_email) < 1){ global $error; global $error_page; $error = "Email Address was empty or had a invalid value."; $error_page = "email address error"; return true; } else{ return false; } } function firstname_validation(){ if(strlen($firstname) > 0){ global $error; global $error_page; $error = "Firstname was empty or had a invalid value."; $error_page = "firstname error"; return true; } else{ return false; } } function lastname_validation(){ if(strlen($lastname) > 0){ global $error; global $error_page; $error = "Lastname was empty or had a invalid value."; $error_page = "lastname error"; return true; } else{ return false; } } function subject_validation(){ if(!isset($subject)){ global $error; global $error_page; $error = "Subject was empty or had a invalid value."; $error_page = "subject error"; return true; } else{ return false; } } function message_validation(){ if(!isset($message)){ global $error; global $error_page; $error = "Message was empty or had a invalid value."; $error_page = "message content error"; return true; } else{ return false; } } //call to above validation function to be executed when form_validation is called global $email_address_validation, $firstname_validation, $lastname_validation, $subject_validation, $message_validation; $email_address_validation = email_address_validation(); $firstname_validation = firstname_validation(); $lastname_validation = lastname_validation(); $subject_validation = subject_validation(); $message_validation = message_validation(); if(!isset($error) || $email_address_validation == false || $firstname_validation == false || $lastname_validation == false || $subject_validation == false || $message_validation == false){ return true; } else{ return false; } } $form_validation = form_validation(); //if the form validation returns false - break the code - write the error and contact form to page if($form_validation != true){ header($email_failed_page); break; //check to see this breaks the entire script not just the if loop } //declare email functions function send_emails(){ /* mail($email_1_recipient_address, $email_1_subject, $email_1_message, $email_1_headers); mail($email_2_recipient_address, $email_2_subject, $email_2_message, $email_2_headers); mail($email_3_recipient_address, $email_3_subject, $email_3_message, $email_3_headers); */ if(mail($email_1_recipient_address, $email_1_subject, $email_1_message, $email_1_headers) && mail($email_2_recipient_address, $email_2_subject, $email_2_message, $email_2_headers) && mail($email_3_recipient_address, $email_3_subject, $email_3_message, $email_3_headers)){ header($email_sucessful_page); } else{ header($email_failed_page.'?error='.urlencode(htmlentities($error_page))); //add in read error from $_GET } } $send_emails = send_emails(); if(!$send_emails){ header($email_failed_page.'?error='.urlencode(htmlentities($error_page))); } else{ header($email_sucessful_page); } ?> Any ideas or comments are welcome. Thanks in advance guys, Timothy Call Send SMS Add to Skype You'll need Skype CreditFree via Skype
  17. hackalive

    Imap

    Hi guys, I am using PHP's IMAP functions to create a basic web-mail client to go with a dashboard I have. I am using imap_fetch_overview which it listing the emails nice and quick - but not in order of date recieved (newest first). How can I rectify this? Simply adding in an imap_sort before imap_fetch_overview seems to break the code and stop it from running the IMAP quiries. Any help is much appreciated - cheers.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.