Jump to content

Search the Community

Showing results for tags 'email'.

  • 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. So for this project im working on I have a newsletter subscription for the website, when a user submits their email address it is sent to the database and as well a "eMail" is sent to the user with a activation link. I wanted this activation link to limit emails being sent to bots, spiders and all that crap thats not done by humans.... anyways. so I have used this mail function before and works great, but for some reason the only thing my script is not doing is sending the email and I can't seem to figure out why. and yes thats why i am here lol... i figured to have a couple other sets of eyes look at my code and see if i missed something. CODE: <?php $em = $_POST['em']; $status = "OK"; // setting the flag to check the status $msg=""; // setting the variable for message if (!stristr($em,"@") OR !stristr($em,".")) { $msg="Your email address is not correct: ".$em."<BR>"; $status= "NOTOK"; } if($status=="OK"){ // Now the email is valid and we can add to our database $activation = md5(uniqid(rand(), true)); $query=("INSERT INTO nl_subscribe (em,status) VALUES ('$em','$activation')"); $result=mysql_query($query); // Send the email: $message = ' To activate your account, please click on this link:\n\n'; $message .= ' FULL URL HERE activate.php?email=' . urlencode($em) . '&key='.$activation; mail('guber_x@hotmail.com', 'Newsletter Confirmation', $message, 'From: noreply@fightingforyesterday.com'); echo '<center>THANK YOU '.$em.'<br>Thanks for subscribing to our newsletter and any time you can unsubscribe by clicking a link in your newsletter</center>'; } else {echo "<center>$msg </center>";} // this will display the error message if email address is not valid one. ?>
  2. Hello, I wrote an emailer script to add to my web site. The code seems to be fine and the variables seem to parse, but still I can not send an e-mail. Could you please tell me what am I doing wrong? I think the error is somewhere in the sendEmail function, but a second opinion is always better to have. The code is: <?php class emailer { private $sender; private $subject; private $body; function __construct($sender) { $this->sender = $sender; //$this->recipient = $recipient; } function addSender($sender){ $this->sender = $sender; } function addSubject($subject){ $this->subject = $subject; } function addBody($body){ $this->body = $body; } function sendEmail(){ $this->recipient = 'test@mail.com'; $this->result = mail($this->recipient, $this->subject, $this->body, "From: {$this->sender} \r\n"); if (!$this->result){ echo $this->result; echo $this->recipient; echo $this->sender; echo $this->subject; echo $this->body; echo "Error"; } else{ echo "e-mail was sent."; } } } ?> Thank you in advance. PS. when I execute the script, I get as output "Error", and I also get the data stored in the variables (recipient,sender,subject, and body).
  3. Hi This is my first so i would like to say hello. I am a novice when it comes to php code and i am just trying to get my head around a few things. So i have set a shop and got everything sorted but i need to put more information in a payment confirmation email that we receive after an order is placed. At the moment we receive this: The status of payment {$PAYMENT_ID} for order {$ORDER_ID} changed. I located the code so i could go about adding parameters to the code so that i get the payment id,order id (which is already there) but i also wanted the product name and amount. So i tried adding {$PRODUCT_NAME} like this and also amount like this {$PRICE}. But anything i tried when i made a test purchase just showed up as code. But the payment and order id showed up fine. What am i doing wrong? If anyone could help that would great.
  4. Hi there, I am not a proper coder, and am using the built in Dreamweaver options to display some tables and do some updates to tables. I have a form on a php page to update a record, which works fine, but I would like the page to send a php email of the contents of the form either before or after it updates the database. How can I do this? I think the code that Dreamweaver uses to update the table and redirect is this: $updateGoTo = "thank-you.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } What I would like to do is insert a script there somewhere, that will send an html email to a recipient with the information contained in the form, so that they are notified of the update, and what the contents of the update are. Is there someone on this site who could explain to me where to insert the code for the php email, or explain a better way to do it? Thanks for the help
  5. cmb

    Html Email

    Im trying to send a html email when i do this locally using mercury mail it works fine. Once i uploaded it and tried sending a email to gmail and yahoo it didn't work this is my php code <?php $from = $_REQUEST['from']; $to = $_REQUEST['to']; $bcc = $_REQUEST['bcc']; $subject = $_REQUEST['subject']; $message = $_REQUEST['msg']; // To send the HTML mail we need to set the Content-type header. $headers = 'From: ' . $from . "\nReply-To: ". $from ."\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=iso-8859-1' . "\r\n" . 'Bcc:' . $bcc . "\r\n"; // now lets send the email. mail($to, $subject, $message, $headers); print json_encode( "Message has been sent....!"); ?> this is the html i was trying to send (i also tried something simpler and that didn't work either) <html> <body style="background-color: #000;"> <table> <tr> <td id="pinkpanthers" style="border: 2px solid #393;padding: 40px 40px; width: 100px;border-radius: 25px; color: #000; background-color: #393;font-size: x-large;" style="border: 2px solid #393;padding: 40px 40px; width: 100px;border-radius: 25px; color: #000; background-color: #393;font-size: x-large;"><a href="http://www.photosbychristian.com/pinkpanthers/index.php" style="text-decoration:none;color: #fff;">Pink<br />Panthers</a></td> <td id="gbsa" style="border: 2px solid #393;padding: 40px 40px; width: 100px;border-radius: 25px; color: #000; background-color: #393;font-size: x-large;"><a href="http://www.photosbychristian.com/gbsa/index.php" style="text-decoration:none;color: #fff;">GBSA</a></td> <td id="elite" style="border: 2px solid #393;padding: 40px 40px; width: 100px;border-radius: 25px; color: #000; background-color: #393;font-size: x-large;"><a href="http://www.photosbychristian.com/elite/index.php" style="text-decoration:none;color: #fff;">Elite</a></td> <td id="THS" style="border: 2px solid #393;padding: 40px 40px; width: 100px;border-radius: 25px; color: #000; background-color: #393;font-size: x-large;"><a href="http://www.photosbychristian.com/THS/index.php" style="text-decoration:none;color: #fff;">THS</a></td> <td id="HDR" style="border: 2px solid #393;padding: 40px 40px; width: 100px;border-radius: 25px; color: #000; background-color: #393;font-size: x-large;"><a href="#" style="text-decoration:none;color: #fff;">HDR</a></td> <td id="family" style="border: 2px solid #393;padding: 40px 40px; width: 100px;border-radius: 25px; color: #000; background-color: #393;font-size: x-large;"><a href="#" style="text-decoration:none;color: #fff;">Family</a></td> </tr> <tr> <td colspan="6"> <p style="color: #fff; text-align:center;">Text will go here</p> </td> </tr> </table> </body> </html> this is the headers from gmail Delivered-To: cmbswim@gmail.com Received: by 10.194.21.41 with SMTP id s9csp621144wje; Sun, 14 Oct 2012 18:02:53 -0700 (PDT) Received: by 10.66.86.42 with SMTP id m10mr29016349paz.3.1350262972933; Sun, 14 Oct 2012 18:02:52 -0700 (PDT) Return-Path: <christianbasse@p3nlhg198.shr.prod.phx3.secureserver.net> Received: from p3nlsmtp20.shr.prod.phx3.secureserver.net (p3nlsmtp20.shr.prod.phx3.secureserver.net. [72.167.234.245]) by mx.google.com with ESMTP id bc7si3012631pab.65.2012.10.14.18.02.52; Sun, 14 Oct 2012 18:02:52 -0700 (PDT) Received-SPF: pass (google.com: domain of christianbasse@p3nlhg198.shr.prod.phx3.secureserver.net designates 72.167.234.245 as permitted sender) client-ip=72.167.234.245; Authentication-Results: mx.google.com; spf=pass (google.com: domain of christianbasse@p3nlhg198.shr.prod.phx3.secureserver.net designates 72.167.234.245 as permitted sender) smtp.mail=christianbasse@p3nlhg198.shr.prod.phx3.secureserver.net Received: from p3nlhg198.shr.prod.phx3.secureserver.net ([97.74.24.198]) by p3nlsmtp20.shr.prod.phx3.secureserver.net with id BD2n1k0044GSV4Z01D2nXS; Sun, 14 Oct 2012 18:02:52 -0700 Received: from p3nlhg198.shr.prod.phx3.secureserver.net (localhost [127.0.0.1]) by p3nlhg198.shr.prod.phx3.secureserver.net (8.14.4/8.12.11) with ESMTP id q9F12b5Q001356 for <cmbswim@gmail.com>; Sun, 14 Oct 2012 18:02:42 -0700 Received: (from christianbasse@localhost) by p3nlhg198.shr.prod.phx3.secureserver.net (8.14.4/8.14.4/Submit) id q9F12b7P001352; Sun, 14 Oct 2012 18:02:37 -0700 Date: Sun, 14 Oct 2012 18:02:37 -0700 Message-Id: <201210150102.q9F12b7P001352@p3nlhg198.shr.prod.phx3.secureserver.net> To: cmbswim@gmail.com Subject: Sample From: christian@photosbychristian.com Reply-To: christian@photosbychristian.com MIME-Version: 1.0 Content-type: text/html; charset=iso-8859-1
  6. I have a page on my website that sends out a simple html email. This page worked a few days ago. Then last night when I was showing my client, it worked, but the email did not display properly (html code was visible in the email). Then today I can not get it to work at all. I have not changed my code, and I am using a script that I have used a lot of times. I'm not familiar with all the php settings on a server. I assume that one of these settings below are conflicting with each other. mail.add_x_header -- on mail.force_extra_parameters -- no value mail.log -- no value sendmail_from -- no value sendmail_path -- /usr/sbin/sendmail -t -i MAILTO -- root Also I had a similar problem a week ago. The email was not being sent out, then I played around with it, but did not actually change anything and it started to work again.
  7. 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
  8. 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
  9. http://independentrepublicofursum.tk/Become_a_Citizen/ is the page I am having trouble on. Basically what I want to happen here is for the user to download a fillable pdf application, fill it, and upload it. From there the php script will send it to my email so I can review it. My code is... function mail_file($to, $from, $subject, $body, $file) { $boundary = md5(rand()); $header = array( "MIME-Version: 1.0", "Content-Type: multipart/mixed; boundary=\"{$boundary}\"", "From: {$from}" ); $message = array( "--{$boundary}", "Content-Type: text/plain", "Content-Transfer-Encoding: 7bit", '', chunk_split($body), "--{$Boundary}", "Content-Type: {$file['type']}; name=\"{$file['name']}\"", "Content-Disposition: attachment; filename=\"{$file['name']}\"", "Content-Transfer-Encoding: base64", '', chunk_split(base64_encode(file_get_contents($file['tmp_name']))), "--{$boundary}--" ); mail($to, $subject, implode("\r\n", $message), implode("\r\n", $headers)); } Then to send it I use... if (isset($_FILES['file'])) { mail_file('myemail@gmail.com', 'ContactUs@independentrepublicofursum.tk', 'test subject', '', $_FILES['file']); } My form is... <form name="citizenship_application" action="" method="post" enctype="multipart/form-data"> First Name: <input type="text" name="first_name" value="<?php echo $first_name_value; ?>"> <br /> <br /> Last Name: <input type="text" name="last_name" value="<?php echo $last_name_value; ?>"> <br /> <br /> E-Mail:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type="text" name="e_mail" value="<?php echo $e_mail_value; ?>"> <br /> <br /> Gender:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type="radio" name="sex" value="male" <?php echo $male_pre_select; ?> >Male <input type="radio" name="sex" value="female" <?php echo $female_pre_select; ?> >Female <br /> <br /> <label for="file">Please specify your application file:</label> <br /> <input type="hidden" name="MAX_FILE_SIZE" value="501"> <input type="file" name="file" size="50"> <br /> <br /> <input type="submit" value="Submit Application" name="submit"> &nbsp<?php echo $error; ?> </form> I get two errors, the first one is... Warning: file_get_contents() [function.file-get-contents]: Filename cannot be empty in /home/u418744221/public_html/B­ecome_a_Citizen/index.php on line 38 Line 38 is... chunk_split(base64_encode(fil­e_get_contents($file['tmp_name­']))), My second error is... Warning: implode() [function.implode]: Invalid arguments passed in /home/u418744221/public_html/B­ecome_a_Citizen/index.php on line 43 line 43 is... mail($to, $subject, implode("\r\n", $message), implode("\r\n", $headers)); Really need this finished, ASAP. I can't figure it out, any help appreciated thanks ya'll.
  10. Alright so I have use the PHP mail() function pretty extensively, however for my new site I will need to collect a filled fillable pdf file downloaded from my site, pull it from the files array, then send it to my e-mail so I can look at it later. I can do all of it except attach the .pdf file. How would I go about this? Please don't give me complete code because that is too easy. I wan't to figure it out myself but the tutorials simply don't explain what is happening.
  11. Hi I am trying to send email through following php code to may gmail account but it givrs me SMTP Error: Could not connect to SMTP host. ******************************************************************************************************************************************************* <?phpif(isset($_POST['submit'])){ $message='Full Name: '.$_POST['fullname'].'<br />Subject: '.$_POST['subject'].'<br />Phone: '.$_POST['phone'].'<br />Email: '.$_POST['emailid'].'<br />Comments: '.$_POST['comments'].''; require "phpmailer/class.phpmailer.php"; //include phpmailer class // Instantiate Class $mail = new PHPMailer(); // Set up SMTP $mail->IsSMTP(); // Sets up a SMTP connection $mail->SMTPAuth = true; // Connection with the SMTP does require authorization $mail->SMTPSecure = "ssl"; // Connect using a TLS connection $mail->Host = "smtp.gmail.com"; //Gmail SMTP server address $mail->Port = 465; //Gmail SMTP port $mail->Encoding = '7bit'; // Authentication $mail->Username = "myemail@gmail.com"; // Your full Gmail address $mail->Password = "mypassword"; // Your Gmail password // Compose $mail->SetFrom($_POST['emailid'], $_POST['fullname']); $mail->AddReplyTo($_POST['emailid'], $_POST['fullname']); $mail->Subject = "New Contact Form Enquiry"; // Subject (which isn't required) $mail->MsgHTML($message); // Send To $mail->AddAddress("myemail@gmail.com", "Recipient Name"); // Where to send it - Recipient $result = $mail->Send(); // Send! $message = $result ? 'Successfully Sent!' : 'Sending Failed!'; unset($mail); }?><html><head> <title>Contact Form</title></head><body> <div style="margin: 100px auto 0;width: 300px;"> <h3>Contact Form</h3> <form name="form1" id="form1" action="" method="post"> <fieldset> <input type="text" name="fullname" placeholder="Full Name" /> <br /> <input type="text" name="subject" placeholder="Subject" /> <br /> <input type="text" name="phone" placeholder="Phone" /> <br /> <input type="text" name="emailid" placeholder="Email" /> <br /> <textarea rows="4" cols="20" name="comments" placeholder="Comments"></textarea> <br /> <input type="submit" name="submit" value="Send" /> </fieldset> </form> <p><?php if(!empty($message)) echo $message; ?></p> </div> </body></html>
×
×
  • 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.