Search the Community
Showing results for tags 'mail'.
-
, 02:03 PM //My contact.php <!DOCTYPE html> <html> <body> <div class="col-sm-6"> <form onsubmit="return false"> <div class="form-group"> <label for="cname" class="control-label">Full Name:</label> <input type="text" class="form-control" name="cname" id="cname"> </div> <div class="form-group"> <label for="mob" class="control-label">Phone Number:</label> <input type="text" class="form-control" name="mob" id="mob"> </div> <div class="form-group"> <label for="mail" class="control-label">Email Address:</label> <input type="email" class="form-control" name="mail" id="mail"> </div> <div class="form-group"> <label for="msg" class="control-label">Message:</label> <textarea class="form-control" rows="4" name="msg" id="msg" style="resize:none"></textarea> </div> <div id="sendmsg"> </div> <button type="submit" name="sendemail" id="sendemail" class="btn btn-success">Send Message</button> </form> </div> <script src="../res/js/jquery.min.js"></script> <script src="../res/js/bootstrap.min.js"></script> <script> $(function(){ $("#sendemail").click(function(){ var err = reqfield_val(['cname', 'mob', 'mail', 'msg']); if(err == 0){ $.ajax({ type: 'post', data: $('form').serialize() }); <?php require_once('../res/php/code.php'); $res = sendemailfn(); // I want to use the function return value here ?> $("#sendmsg").text('<?=$res?>').css("opacity",'1'); } }); }); </script> </body> </html> //mail function code in code.php file <?php function sendemailfn() { if($_POST) // to prevent form submission on page reload (& on not using this condition function is returning the value) { $res = ""; $cname = $_POST['cname']; $email_from = $_POST['mail']; $mobile = $_POST['mob']; $msg = $_POST['msg']; $to = '[email protected]'; $body = 'Name'.$cname. '\nEmail'.$email_from. '\nMobile'.$mobile. '\nMessage'.$msg; $subject = 'Enquiry from www.zuhaconsultants.com'; $headers = 'From: '.$email_from."\r\n" . 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); $mail_sent = mail($to, $subject, $body, $headers); if($mail_sent == true) $res = "Thank you for contacting us. We will be in touch with you very soon."; else $res = "Seems Some Error Occured."; return $res; // this value is not returned to contact.php page // if the about condition if($_POST) is not given then it is returning the value // if it is not given the page is submitting the form on page reload } } ?> Please help me get the return value $res... in the same way please note that the form should not be submitted on page reload Thanking you
-
I'm having a probably server-side issue that I cannot fix, so I need to find a workaround. I have a page designed to allow people to enter their report and email it to a list of people (it will vary each time). There are 2 ways people can enter an email recipient: full email address or first and last name (which is how you find people in the corporate Outlook Exchange accounts). So when the recipient field is entered, it may contain a mix of full email addresses or just first and last names (separated by commas). For example, here's my original array of email recipients: $recipient = "[email protected], John Smith, Barb Johnson"; The problem is with the first and last names. When the email sends, it adds the entire domain of the server to the email address. For example, if the server I'm using is "test.server.xyz.com" and I enter "John Smith", when the email gets sent, it sends to "[email protected]" instead of just "[email protected]". So I'm wondering if there's code that would search an array using mixed email addresses, locate just the ones with first and last names, and fix them. How would I code this so it ended up as: $new_recipients = "[email protected], [email protected], [email protected]"; Thanks in advance! Note: I've asked IT if they can fix something on the server end to correct this, but I'm not counting on their help, so looking for a workaround.
-
I am trying to send a basic email that is multipart via the mail() function in php. I am not interested in using PHPmail. This should be very light weight. Currently when I send email to gmail, it is sending the html part as plain text so all the tags are showing. Here is my code: //GET VAR INPUT $to = htmlentities($_GET['to']); $friendly_from = htmlentities($_GET['friendly_from']); $email_from = htmlentities($_GET['email_from']); $subject = htmlentities($_GET['subject']); $text = htmlentities($_GET['text']); $html = htmlentities($_GET['html']); //SEND EMAIL # Setup mime boundary $mime_boundary = 'Multipart_Boundary_x' . md5(time()) . 'x'; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\r\n"; $headers .= "Content-Transfer-Encoding: 7bit\r\n"; $headers .= "Reply-To: " . $email_from . " \r\n"; # Add in plain text version $body.= "--$mime_boundary\n"; $body.= "Content-Type: text/plain; charset=\"charset=us-ascii\"\n"; $body.= "Content-Transfer-Encoding: 7bit\n\n"; $body.= $text; $body.= "\n\n"; # Add in HTML version $body.= "--$mime_boundary\n"; $body.= "Content-Type: text/html; charset=\"UTF-8\"\n"; $body.= "Content-Transfer-Encoding: 7bit\n\n"; $body.= $html; $body.= "\n\n"; # End email $body.= "--$mime_boundary--\n"; # <-- Notice trailing --, required to close email body for mime's # Finish off headers $headers .= "From: " . $friendly_from . " <" . $email_from . ">\r\n"; $headers .= "X-Sender-IP: " . $_SERVER[SERVER_ADDR] . "\r\n"; $headers .= 'Date: ' . date('n/d/Y g:i A') . "\r\n"; # Mail it out return mail($to, $subject, $body, $headers); Here is what I am receiving. (And yes I can accept html emails).
-
I am trying to echo out product names onto php mail. I have it in the $message variable, code is below (have cut out a lot of other stuff in there, HTML code is all working fine) $message = ' 'for($z=0;$z<$h;$z++) { echo "<tr>"; echo '<td colspan="18">'.$_SESSION['transferproducts'.$z.''].'</td>'; echo '<td colspan="2">'.$_SESSION['transferprices'.$z.''].'</td>'; echo "</tr>"; }' '; I'm getting an error on the line where the "for" starts. How can I get it to work correctly?
-
I've got this: mail($to,$subject,$message,"Content-type: text/html; charset=iso-8859-1"); It sends through HTML e-mail fine, but I can't get it to show both who its from, and get the HTML bits in ("Content-type: text/html; charset=iso-8859-1"). Can anyone help please?