Sentora Support Forums

Full Version: No emails sent via PHP Mail() function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I am building a webpage with a contact form that sends an email to me via the Mail() php function.

I can send/receive emails fine via Roundcube, but none are sent via this method.  

Here is my script:

contact page:

Code:
<form  action="mail_handler.php" method="post" class="col s12">            <div class="row">              <div class="input-field col s6">                <input id="name" type="text" class="validate">                <label for="name">Name</label>              </div>            </div>            <div class="row">              <div class="input-field col s6">                <input id="email" type="email" class="validate">                <label for="email">Email Address</label>              </div>              <div class="input-field col s6">                <input id="telephone" type="tel" class="validate">                <label for="telephone">Telephone Number</label>              </div>            </div>              <div class="row">                <div class="input-field col s12">                  <textarea id="message" class="materialize-textarea"></textarea>                  <label for="message">Breif description of work to be done.</label>                </div>              </div>              <div class="row">                <div class="input-field col s6">                  <select>                    <option value="" disabled selected>Choose the best way to contact you</option>                    <option value="email">Email</option>                    <option value="telephone">Telephone</option>                  </select>                  <label>Best Contact Method</label>                </div>                <div class="input-field col s6">                  <button class="btn waves-effect waves-light" type="submit" name="action">Submit                    <i class="material-icons right">send</i>                  </button>                </div>              </div>            </form>



php page:
Code:
<?php if(isset($_POST['submit'])){    $to = "myemailishere"; // this is your Email address    $from = $_POST['email']; // this is the sender's Email address    $name = $_POST['name'];    $telephone = $_POST['telephone'];    $contactmethod = $_POST['contactmethod'];    $subject = "Form submission";    $subject2 = "Copy of your form submission";    $message = $name . " wrote the following:" . "\n\n" . $_POST['message'];    $message2 = "Here is a copy of your message " . $name . "\n\n" . $_POST['message'];    $headers = "From:" . $from;    $headers2 = "From:" . $to;    mail($to,$subject,$message,$telephone,$contactmethod,$headers);    mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender    echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";    // You can also use header('Location: thank_you.php'); to redirect to another page.    // You cannot use header and echo together. It's one or the other.    } ?>


Any ideas?  I'm not receiving any emails whether I specify the 'to' email as my personal email (hosted on protomail) or an email I have on round cube.
If you send to mail@domain.com while domain.com setup in sentora it will likely send the email to local server.

Also can you test sending to gmail.com?

M B
(04-11-2016, 09:49 PM)Me.B Wrote: [ -> ]If you send to mail@domain.com  while domain.com setup in sentora it will likely send the email to local server.

Also can you test sending to gmail.com?

M B

Went ahead and tried sending to gmail, still no dice Sad
can you check postfix queue to see where the file ended?

Also sending email that way can cause issues. As the sender may some time authorize few smtp servers to send on his behalf using SPF. Best is setting FROM as sever@domain.com.

M B
(04-12-2016, 12:33 AM)Me.B Wrote: [ -> ]can you check postfix queue to see where the file ended?

Also sending email that way can cause issues. As the sender may some time authorize few smtp servers to send on his behalf using SPF. Best is setting FROM as sever@domain.com.

M B

I'll check the postfix queue here in a sec.  I've changed the php to the below quoted code, but still no dice.

Code:
<?php if(isset($_POST['submit'])){    $to = "email@domain.com (not hosted on same server)";    $to2 = $_POST['email'];    $from = "email@domain.com (hosted on same server)";    $name = $_POST['name'];    $email = $_POST['email'];    $telephone = $_POST['telephone'];    $contactmethod = $_POST['contactmethod'];    $subject = "Form submission";    $subject2 = "Copy of your form submission";    $message = $name . " wrote the following:" . "\n\n" . $_POST['message'];    $message2 = "Here is a copy of your message " . $name . "\n\n" . $_POST['message'];    $headers = "From:" . $from;    $headers2 = "From:" . $to;    mail($to,$subject,$message,$telephone,$email, $contactmethod,$headers);    mail($to2,$subject2,$message2);    echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";    } ?>
Alright.  I checked the postfix queue and I think that I've found the problem.

It looks like than an old domain name (that I no longer use or have) is configured somehow (see code below).

How would I remedy this?

Code:
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient------- 3240B41965      833 Thu Apr  7 06:47:49  root@admin.olddomain.com                                                  (mail transport unavailable)                                         root@admin.olddomain.com 30F8B4196B     2961 Fri Apr  8 11:33:26  MAILER-DAEMON (Host or domain name not found. Name service error for name=admin.olddomain.com type=AAAA: Host not found)                                         root@admin.olddomain.com 5C9E841967     2899 Thu Apr  7 07:08:25  MAILER-DAEMON (Host or domain name not found. Name service error for name=admin.olddomain.com type=AAAA: Host not found)                                         root@admin.olddomain.com 5AC2D41962     2961 Thu Apr  7 11:33:25  MAILER-DAEMON (Host or domain name not found. Name service error for name=admin.olddomain.com type=AAAA: Host not found)                                         root@admin.olddomain.com 259FB419AE      833 Mon Apr 11 06:35:16  root@admin.olddomain.com (Host or domain name not found. Name service error for name=admin.olddomain.com type=AAAA: Host not found)                                         root@admin.olddomain.com 437F64197A      833 Sun Apr 10 06:54:14  root@admin.olddomain.com (Host or domain name not found. Name service error for name=admin.olddomain.com type=AAAA: Host not found)                                         root@admin.olddomain.com 43E8F41977     2961 Mon Apr 11 11:23:27  MAILER-DAEMON (Host or domain name not found. Name service error for name=admin.olddomain.com type=AAAA: Host not found)                                         root@admin.olddomain.com 9618841972     2899 Sat Apr  9 07:03:26  MAILER-DAEMON (Host or domain name not found. Name service error for name=admin.olddomain.com type=AAAA: Host not found)                                         root@admin.olddomain.com A69D341943     2899 Mon Apr 11 07:13:26  MAILER-DAEMON (Host or domain name not found. Name service error for name=admin.olddomain.com type=AAAA: Host not found)                                         root@admin.olddomain.com A68CE41976      833 Sat Apr  9 06:33:07  root@admin.olddomain.com (Host or domain name not found. Name service error for name=admin.olddomain.com type=AAAA: Host not found)                                         root@admin.olddomain.com A473141978     2899 Sun Apr 10 06:58:26  MAILER-DAEMON (Host or domain name not found. Name service error for name=admin.olddomain.com type=AAAA: Host not found)                                         root@admin.olddomain.com 0F4D841945     2961 Sun Apr 10 11:43:27  MAILER-DAEMON (delivery temporarily suspended: Host or domain name not found. Name service error for name=admin.olddomain.com type=AAAA: Host not found)                                         root@admin.olddomain.com 71E1C418FB     2899 Fri Apr  8 07:08:26  MAILER-DAEMON (Host or domain name not found. Name service error for name=admin.olddomain.com type=AAAA: Host not found)                                         root@admin.olddomain.com EF1BE4196F      833 Fri Apr  8 06:48:23  root@admin.olddomain.com (Host or domain name not found. Name service error for name=admin.olddomain.com type=AAAA: Host not found)                                         root@admin.olddomain.com EE32E40DE7     2961 Sat Apr  9 11:18:26  MAILER-DAEMON (Host or domain name not found. Name service error for name=admin.olddomain.com type=AAAA: Host not found)                                         root@admin.olddomain.com
May be check postfix conf file if it's the default setup here.

M B
(04-12-2016, 05:16 AM)Me.B Wrote: [ -> ]May be check postfix conf file if it's the default setup here.

M B

I checked the config, and everything looks fine there.  I rebooted the server, cleared the mail queue, and tried a few more times.   The # of emails in the mail queue isn't increasing from 0 now.

edit: Thank you so much for your help by the way! I really appreciate it Smile
Anyone else have any more ideas? I can't seem to find what's the problem Sad
Still again the problem? Seem you said it was solved?
Pages: 1 2