whitt
-
Posts
44 -
Joined
-
Last visited
Posts posted by whitt
-
-
okk i think the issue is my ajax url i have the form working then the php file is in the same directory but not when in the bin folder
-
I just checked the JS console i have this
POST http://localhost/contact_form/bin/contact_me.php 500 (Internal Server Error) -
Am i close to fixing this at least?
-
How do you know it was successful? You just return true no matter what.
The mail function returns a boolean, you should use that.
mail($to,$email_subject,$email_body,$headers); return true;
One other thing I noticed, is headers need to be separated with \r\n, not just \n.
$headers = "From: whitegatescattery.com\n"; $headers .= "Reply-To: email@gmail.com";
As far as the appending error messages in your second code block, it's probably because you do a var_dump(), which sends that output back to the browser.
How do you mean return true all the time?
-
<?php // check if fields passed are empty if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['phone']) || empty($_POST['message']) || !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)) { echo "No arguments Provided!"; return false; } $name = $_POST['name']; $email_address = $_POST['email']; $message = $_POST['message']; $phone = $_POST['phone']; // create email body and send it $to = 'email@gmail.com'; // put your email $email_subject = "Contact form submitted by: $name"; $email_body = "You have received a new message. \n\n". " Here are the details:\n \nName: $name \n ". "Email: $email_address\n Phone: $phone\n Message \n $message"; $headers = "From: whitegatescattery.com\n"; $headers .= "Reply-To: email@gmail.com"; mail($to,$email_subject,$email_body,$headers); return true; ?>
This worked with Gmail i dont get why this
<?php require_once './libPHPMailerAutoload.php'; // check if fields passed are empty // check if fields passed are empty $name = $_POST['name']; $email_address = $_POST['email']; $message = $_POST['message']; $phone = $_POST['phone']; if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['phone']) || empty($_POST['message']) || !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)) { echo "No arguments Provided!"; return false; } $mail = new PHPMailer; $mail->isSMTP(); $mail->SMTPAuth= true; $mail->SMTPDebug = 1; $mail->Host = 'smtp-mail.outlook.com'; $mail->Username = 'email'; $mail->Password = 'pass'; $mail->SMTPSecure = 'tls'; $mail->Port = 587; $mail->From = $email_address; $mail->FromName = $name; $mail->addReplyTo('reply@outlook.com','reply'); $mail->addAddress('@outlook.com','me'); $mail->isHTML(true); $mail->Subject = "Contact Form has been submitted"; $mail->Body = "You have received a new message. <br><br>". " Here are the details:<br> Name: $name <br> Phone Number: $phone <br>". "Email: $email_address<br> Message <br> $message"; var_dump($mail->send()); return true; ?>
Is causing my ajax to append my fail message
-
I may have used the wrong terminology but i don't know why the form is not working
-
Can someone have a look at this , if i take the php code below the return false it says the message is sent.
-
<?php require_once 'PHPMailerAutoload.php'; // check if fields passed are empty if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['message']) || !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)) { echo "No arguments Provided!"; } $name = $_POST['name']; $email_address = $_POST['email']; $message = $_POST['message']; $mail = new PHPMailer; $mail->isSMTP(); $mail->SMTPAuth= true; $mail->SMTPDebug = 1; $mail->Host = 'smtp-mail.outlook.com'; $mail->Username = 'email'; $mail->Password = 'pass'; $mail->SMTPSecure = 'tls'; $mail->Port = 587; $mail->From = $email_address; $mail->FromName = $name; $mail->addReplyTo('reply@outlook.com','reply'); $mail->addAddress('testytestersontesting@outlook.com','Testy Testerson'); $mail->isHTML(true); $mail->Subject = "Contact Form has been submitted"; $mail->Body = "You have received a new message. <br><br>". " Here are the details:<br> Name: $name <br> Phone Number: $phone <br>". "Email: $email_address<br> Message <br> $message"; echo var_dump($mail->send()); return true; ?>
I just flat out cannot see why this does not work , the script on its own works but when i try to integrate it into the form i get my ajax sending back my error alert.
-
Ok so i just made a test email address testy testerson , i an send emails from the testy account to my email account , i literally changed no code.
-
Thing is this was working fine like 10 minutes ago i managed to send like 8 emails.
-
i have to use outlook as its what my mate wants to use for this form
-
This may seem obvious, but it has't been mentioned. Have you turned on SMTP error reporting?
/* * $mail->SMTPDebug = 0; disable debugging, 0 is the default) * $mail->SMTPDebug = 1; echo errors and server responses * $mail->SMTPDebug = 2; echo errors, server responses and client messages */ $mail->SMTPDebug = 1;
I'm not as familiar with PHPMailer, but with other classes/frameworks, you can pass additional headers. That may be where you want to research, specifically for MS mail. BTW, I've used part of your ajax script to update on of my own. I like how your handling post submit UI feedback. Good luck
If my AJAX is working it has to be on the PHP end
-
Literally 5 minutes later and i get this "
2015-03-06 11:59:37 CLIENT -> SERVER: EHLO localhost 2015-03-06 11:59:37 CLIENT -> SERVER: STARTTLS 2015-03-06 11:59:37 CLIENT -> SERVER: EHLO localhost 2015-03-06 11:59:38 CLIENT -> SERVER: AUTH LOGIN 2015-03-06 11:59:38 CLIENT -> SERVER: bWF0dGhld3B3aGl0dGluZ3RvbkBvdXRsb29rLmNvbQ== 2015-03-06 11:59:38 CLIENT -> SERVER: TWF2ZXJpY2s4OQ== 2015-03-06 11:59:39 CLIENT -> SERVER: MAIL FROM: 2015-03-06 11:59:39 CLIENT -> SERVER: RCPT TO: 2015-03-06 11:59:39 CLIENT -> SERVER: DATA 2015-03-06 11:59:39 CLIENT -> SERVER: Date: Fri, 6 Mar 2015 11:59:37 +0000 2015-03-06 11:59:39 CLIENT -> SERVER: To: Matthew Whittington 2015-03-06 11:59:39 CLIENT -> SERVER: From: matthewpwhittington@outlook.com 2015-03-06 11:59:39 CLIENT -> SERVER: Reply-To: sender 2015-03-06 11:59:39 CLIENT -> SERVER: Subject: Testing Email 2015-03-06 11:59:39 CLIENT -> SERVER: Message-ID: <26e958edff522d3f6a43f03aaf8bab81@localhost> 2015-03-06 11:59:39 CLIENT -> SERVER: X-Priority: 3 2015-03-06 11:59:39 CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.9 (https://github.com/PHPMailer/PHPMailer/) 2015-03-06 11:59:39 CLIENT -> SERVER: MIME-Version: 1.0 2015-03-06 11:59:39 CLIENT -> SERVER: Content-Type: multipart/alternative; 2015-03-06 11:59:39 CLIENT -> SERVER: boundary="b1_26e958edff522d3f6a43f03aaf8bab81" 2015-03-06 11:59:39 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit 2015-03-06 11:59:39 CLIENT -> SERVER: 2015-03-06 11:59:39 CLIENT -> SERVER: --b1_26e958edff522d3f6a43f03aaf8bab81 2015-03-06 11:59:39 CLIENT -> SERVER: Content-Type: text/plain; charset=us-ascii 2015-03-06 11:59:39 CLIENT -> SERVER: 2015-03-06 11:59:39 CLIENT -> SERVER: This is a Test Email 2015-03-06 11:59:39 CLIENT -> SERVER: 2015-03-06 11:59:39 CLIENT -> SERVER: 2015-03-06 11:59:39 CLIENT -> SERVER: --b1_26e958edff522d3f6a43f03aaf8bab81 2015-03-06 11:59:39 CLIENT -> SERVER: Content-Type: text/html; charset=us-ascii 2015-03-06 11:59:39 CLIENT -> SERVER: 2015-03-06 11:59:39 CLIENT -> SERVER: This is a Test Email ssl 2015-03-06 11:59:39 CLIENT -> SERVER: 2015-03-06 11:59:39 CLIENT -> SERVER: 2015-03-06 11:59:39 CLIENT -> SERVER: 2015-03-06 11:59:39 CLIENT -> SERVER: --b1_26e958edff522d3f6a43f03aaf8bab81-- 2015-03-06 11:59:39 CLIENT -> SERVER: 2015-03-06 11:59:39 CLIENT -> SERVER: . 2015-03-06 11:59:40 SMTP ERROR: DATA END command failed: 550 5.3.4 Requested action not taken; To continue sending messages, please sign in to your account. 2015-03-06 11:59:40 SMTP Error: data not accepted. bool(false) 2015-03-06 11:59:40 CLIENT -> SERVER: QUIT 2015-03-06 11:59:40 SMTP ERROR: QUIT command failed:" @outlook.com>@outlook.com>@outlook.com>@outlook.com> -
I did a basic just send an email PHP scrip i have the emails going to my in box with this
<?php require_once 'PHPMailerAutoload.php'; $mail = new PHPMailer; $mail->isSMTP(); $mail->SMTPAuth= true; $mail->Host = 'smtp-mail.outlook.com'; $mail->Username = 'myemail@outlook.com'; $mail->Password = 'pass'; $mail->SMTPSecure = 'tls'; $mail->Port = 587; $mail->From = 'sender@outlook.com'; $mail->FromName = $name; $mail->addReplyTo('sender@outlook.com',$name); $mail->addAddress('myemail@outlook.com',me); $mail->Subject = 'Testing Email'; $mail->Body = 'This is a Test Email ssl'; $mail->AltBody ='This is a Test Email'; var_dump($mail->send()); ?>
-
Ok so .... it works with TLS but refuses to let me use SSL .... why Microsoft...
-
Besides the possible issues with your script, also understand that ANY of the Microsoft email domains (outlook, hotmail, live, msn) are very very hard to have an email arrive in the inbox. They have very strict rules in place to prevent spam, so make sure to check your spam box before deciding that the email has never arrived. Try sending it to a yahoo or gmail address too and see if it arrives there. Those email domains are far less strict.
With Gmail when the form is submitted i get a suspicious sign in attempt email from Gmail.
-
Console doesn't appear to be coming up with anything which is odd as this script seems to work with other php mail scripts i've written it only seems to not like phpmailer.
I have attached my files , im going to keep looking at it but i cant see whats wrong. -
Doesn't matter if it works. Did you implement the changes I suggested and check the browsers console to see if you actually got a response back?
Ill be doing that tomorrow mate , its late in my timezone.
-
That url in the ajax call seems a little odd. Are you sure the ajax post is making it to your contact_me.php script? Do you receive any of the error messages back?
What makes the URL seem odd?
-
Ill rebuild workable version and post it
-
It seems to submit fine it just never shows up
-
I am attempting to create a php AJAX contact form , however the email never seems to arrive in my outlook.
/* Jquery Validation using jqBootstrapValidation example is taken from jqBootstrapValidation docs */ $(function() { $("input,textarea").jqBootstrapValidation( { preventSubmit: true, submitError: function($form, event, errors) { // something to have when submit produces an error ? // Not decided if I need it yet }, submitSuccess: function($form, event) { event.preventDefault(); // prevent default submit behaviour // get values from FORM var name = $("input#name").val(); var email = $("input#email").val(); var phone = $("input#phone").val(); var message = $("textarea#message").val(); var firstName = name; // For Success/Failure Message // Check for white space in name for Success/Fail message if (firstName.indexOf(' ') >= 0) { firstName = name.split(' ').slice(0, -1).join(' '); } $.ajax({ url: "./bin/contact_me.php", type: "POST", data: {name: name,phone:phone, email: email, message: message}, cache: false, success: function() { // Success message $('#success').html("<div class='alert alert-success'>"); $('#success > .alert-success').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×") .append( "</button>"); $('#success > .alert-success') .append("<strong>Your message has been sent. </strong>"); $('#success > .alert-success') .append('</div>'); //clear all fields $('#contactForm').trigger("reset"); }, error: function() { // Fail message $('#success').html("<div class='alert alert-danger'>"); $('#success > .alert-danger').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×") .append( "</button>"); $('#success > .alert-danger').append("<strong>Sorry "+firstName+" it seems that my mail server is not responding...</strong> Could you please email me directly ? Sorry for the inconvenience!"); $('#success > .alert-danger').append('</div>'); //clear all fields $('#contactForm').trigger("reset"); }, }) }, filter: function() { return $(this).is(":visible"); }, }); $("a[data-toggle=\"tab\"]").click(function(e) { e.preventDefault(); $(this).tab("show"); }); }); /*When clicking on Full hide fail/success boxes */ $('#name').focus(function() { $('#success').html(''); });
<?php require("../lib/phpmailer/PHPMailerAutoload.php"); if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['phone']) || empty($_POST['message']) || !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)) { echo "No arguments Provided!"; return false; } $m = new PHPMailer(); $m->IsSMTP(); $m->SMTPAuth = true; $m->SMTPDebug = 2; $m->Host = "smtp-mail.outlook.com"; $m->Username = ""; $m->Password = ""; $m->SMTPSecure = 'tls'; $m->Port = 587; $m->addAddress('EXAMPLE@outlook.com', $name); $name = $_POST['name']; $email_address = $_POST['email']; $phone = $_POST['phone']; $message = $_POST['message']; $m->Subject = "Contact Form has been submitted"; $m->Body = "You have received a new message. <br><br>". " Here are the details:<br> Name: $name <br> Phone Number: $phone <br>". "Email: $email_address<br> Message <br> $message"; if(!$m->Send()) { echo "Mailer Error: " . $m->ErrorInfo; exit; } ?>
-
Im struggling with how to filter items that have multiple categorises say if i wanted to search for a shoe that is good for walking and hiking in my database?
Shoe_id
Shoe name
color_idtype_id
colorscolor_id
color
type
type_id
type
My problem is what do i do in a situations like this? say a shoe is good for walking and running? aka type 1 and 2
shoe id 1 shoe name nike color id 1 type id 1 and 2 -
how about if say theres a shoe type say
types
type_ID
type
but i wanted a shoe to be for basket ball and runningShoes:
ID = 1, Name = 'Nike Free'
Colors
ID = 1, Name = 'Grey'
ID = 2, Name = 'Yellow'
Type
type_id 1
type running
type_id 2
type basketball
Shoe_colors:
ID = 1, Shoe_id = 1, Color_id = 1 type = 1 and 2 ??
ID = 2, Shoe_id = 1, Color_id = 2
Ajax PHP contact form help
in PHP Coding Help
Posted
fixed it