Xenforo not sending emails

aljaxus

Member
Hello, i recently moved (still working on it) from my webserver to my dedi server.
I host some other things besides forums, but that should not affect PHP mail sending.

So, what i need?
Any help, why PHP does not / can not send emails.
I tried with this code
Code:
<?php
if(isset($_POST['submit'])){
    $to = $_POST['email']; // this is your Email address
    $from = "testing@email.com"; // this is the sender's Email address
    $first_name = $_POST['first_name'];
    $last_name = $_POST['last_name'];
    $subject = "Form submission";
    $subject2 = "Copy of your form submission";
    $message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_POST['message'];
    $message2 = "Here is a copy of your message " . $first_name . "\n\n" . $_POST['message'];

    $headers = "From:" . $from;
    $headers2 = "From:" . $to;
    mail($to,$subject,$message,$headers);
    mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
    echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
    // You can also use header('Location: thank_you.php'); to redirect to another page.
    }
?>

<!DOCTYPE html>
<head>
<title>Form submission</title>
</head>
<body>

<form action="" method="post">
First Name: <input type="text" name="first_name"><br>
Last Name: <input type="text" name="last_name"><br>
Email: <input type="text" name="email"><br>
Message:<br><textarea rows="5" name="message" cols="30"></textarea><br>
<input type="submit" name="submit" value="Submit">
</form>

</body>
</html>
and it does not work neither.
PHP file (that should send the email) https://www.towernetwork.eu/misc/email
Any ideas why ?
Thank you for any help/suggestion/answer in advance :)


Regards.

*edit* Fixed the URL
 
Last edited:
How are you sending email, using sendmail, postfix, a remote smtp server?
How is your xenforo setup, using default, or smtp?

What do the error.log from the server show, or the mail log files.
And maybe any xenforo server errors being logged when you try to send an email?
 
How is your xenforo setup, using default, or smtp?
using default method.
What do the error.log from the server show, or the mail log files.
Xenforo's error logs: nothing
/etc/logs/mail-log.txt (i think it's that, i don't remember the exact name of the file) : again nothing
And maybe any xenforo server errors being logged when you try to send an email?
No, not at all. No errors.
 
You need to invest a lot more time in your email strategy.

Why not log into your domain email and send that way?? (With the settings in xf options)
 
You need to invest a lot more time in your email strategy.
I invest quite a lot of time in my hobbies, if we note that i am just 16 years old, still go to school, am waking up at 5:20am and i come home late (4pm) and then i go work for 3 hours/day (excluding weekends). So please, until you know what you are saying, don't say it.

Why not log into your domain email and send that way?? (With the settings in xf options)
Am what are you trying o say here ?
As far as i got, you are saying; why do i not login on my current mailserver and use that service ?

Right now i have my mailserver (and webserver) hosted on a webhost, but i want to 100% move on my DEDI host, so i can do whatever i want (until i will be able to understand what's going on, and if i won't i will learn).
And i want to use the PHP mail method instead of the mail forwording one.


I wil provide some more info that may be usefull;

On my previous host it worked using PHP based methid, default one (WebServer - http://towernetwork.eu/community ) but on the new host (my dedicated one) it does not work anymore.
I have installed PHP5 everything else works perfectl, just the mail sending does not.

Thank you for any help.
Regars.
 
Last edited:
I don't care what age you are. I'd said to anybody the same way. I started on the internet when I was 9 I'm 33 now. Do you think anybody cares? No. And nobody should.

So the question is how you going to send and receive email?

You could just use exim but that would be like saying it's as simple as heart surgery.

So you could setup your domain with Google for email and you'd be limited to 100 emails a day. That would be a starting point.
 
I don't care what age you are. I'd said to anybody the same way. I started on the internet when I was 9 I'm 33 now. Do you think anybody cares? No. And nobody should.
i agree :)

So you could setup your domain with Google for email and you'd be limited to 100 emails a day. That would be a starting point.
naah not going on google things, more self hosted, more freedom.
*edit* i did lookup on that, if you are talking about gSuite. Be sure i did as much research as i could, but seems like noone had this issue (i don't think so), or i did not search it with right keywords.


But i don't know why it does work on the webserver and what is wrong on my DEDI host.
As far s i know the mail() method (or whatever it is used, i am not a PHP expert, not even close) is based ONLY on PHP.
If that requires any additional settings/dependencies, please tell me.

First, I would ask my new host about his mail policies.
it is a dedicated server. No limitations (only hardware and NET speed). You do whatever you want, whenever you want. Until you are breaking a law (example, hosting a child porn site, etc.)

Thank you all for replying so far :) (i hope you are having a great friday and tomorrow even batter weekend start ;)
 
Last edited:
When you find your mail log, and error log and access log files, etc on the CLI, then use "tail -F" on it and keep it open.

like:

:~# tail -F error.log

etc in various shell sessions.

then just go to the forum with a test user and click on "contact us" and send a test email.

The log files will then simply show what is going right, what is going wrong, and give more details.

But the CLI mail service has to work first for outgoing email, before xenforo can use it. So use a simple CLI command to send out a mail trigger and analyze it. If you know it works on the server level, then step it up and take it to the web server, php, etc.
 
as sudo user (root access) type on the CLI

Code:
which sendmail

to see if you have sendmail, and where it is.

If you get something like /usr/sbin/sendmail, then you're good to go for the next one.

otherwise might have to install it, on ubuntu this might be apt-get install sendmail or something along those lines.

Code:
echo "Subject: cli mail test" | sendmail -v myemail@example.com

Obviously replace your real email address (like your gmail or something)

If this works, you can start debugging things a little bit,
use nano or pico or vim to create a ~/mailtest.txt file like this:
Code:
To: myemail@example.com.com
Subject: Another test email using mail.txt
From: me@myserver.com
And here goes the e-mail body, test test test..
Replace the email addresses accordingly.

then use this command to send it:
Code:
sendmail -vt < ~/mailtest.txt

And you should see the verbose output of its travels for the most part.

Or let someone else handle email, get an SMTP server like google suite or amazon ses and set that up for xenforo.
 
Or let someone else handle email, get an SMTP server like google suite or amazon ses and set that up for xenforo.
nah nah,, i will learn how to do this and i am not going to use other services. Not for this.

So what i got was; (my steps)


which sendmail
It works :)

echo "Subject: cli mail test" | sendmail -v myemail@example.com
Code:
LOG: MAIN
  <= root@it21.mondoserv.com U=root P=local S=321
root@tower1:~# delivering 1cwVS2-0006yj-7k
R: nonlocal for cratslazo@gmail.com
LOG: MAIN
  ** cratslazo@gmail.com R=nonlocal: Mailing to remote domains not supported
LOG: MAIN
  <= <> R=1cwVS2-0006yj-7k U=Debian-exim P=local S=1158
delivering 1cwVS2-0006yn-8T
LOG: MAIN
  Completed
R: system_aliases for root@it21.mondoserv.com
R: userforward for root@it21.mondoserv.com
R: procmail for root@it21.mondoserv.com
R: maildrop for root@it21.mondoserv.com
R: lowuid_aliases for root@it21.mondoserv.com (UID 0)
R: mail4root for root@it21.mondoserv.com
T: address_file for root@it21.mondoserv.com
LOG: MAIN
  => /var/mail/mail <root@it21.mondoserv.com> R=mail4root T=address_file
LOG: MAIN
  Completed
This one does not work -> "Mailing to remote domains not supported"

i found this, but when i entered the menu i found out that i get what that is, but i don't want to mess with that stuff until i am at least 80% sure what i am doing.

But overall i am just curious WHY did it work on the WEBhost and it does not work on DEDI host. i suppose i am missing any software, which (if anyone can tell me) i will try to setup.
Regarding to answers above, i am missing a mail service. If i got it right.

Thank you in advance for any help.
 
Email isn't a silver bullet type job.

You have:

DKIM
SPF
DMARC

Which is all about how an email is validated against spam

I dont know what distro or what your using so I am going to put it all here

DKIM is domain keys, which is a method of singing the email with a private key and using the public key (a TXT record for your domain) to authenticate the signing.

https://debian-administration.org/article/718/DKIM-signing_outgoing_mail_with_exim4

SPF is a TXT record that says that this IP/domain can send email, which a wizard can be found here: http://www.spfwizard.net/

The DMARC is a method of validating to ensure that your emails are being signed and reporting to see if anybody is faking your domain. Another tool here: https://dmarc.postmarkapp.com/

The SMTP client which is sendmail/exim etc.

You will also need an SSL certificate at this point, because thats the way the internet is: https://loune.net/2016/02/lets-encrypt-with-exim-and-dovecot/

Now you need to recieve email

https://www.dovecot.org/

or sendmail: https://chrisjean.com/configuring-sendmail-to-receive-external-mail/

setting it up? dunno thats a black hole of work.

Now you still cant read your email unless you use your phone or desktop mail client but web-mail like round cube, squirrel, horde etc can be handy and configure those services to your SSL Certificate.

And by the time you finish that you will be a certified genius because that is a lot of effort.

Also this makes no grantee that email will be delivered successfully or wont be sent to spam or vaporized instantly by microsoft email or other email providers like BT Internet.

As I said you "you will need to invest a lot of time in your email strategy" as you can see from above the statement was not a throw away comment but quiet a serious one.

The difference between your dedicated and your webhost is that your webhost takes the easy path and invests in a control panel like cpanel, plesk, directadmin, webadmin etc that automates all of this.
 
Wow that was a roast :3 (no jk, thanks for making it clear)

As I said you "you will need to invest a lot of time in your email strategy" as you can see from above the statement was not a throw away comment but quiet a serious one.
i never stated that you were joking or anything. Regarding on how much replies i saw that you posted on other threads (and were actually useful) i never doubt that.


The difference between your dedicated and your webhost is that your webhost takes the easy path and invests in a control panel like cpanel, plesk, directadmin, webadmin etc that automates all of this.
And this is what i've been searching for. So in order to run a XenForo forums on your host (DEDI / VPS / HomeHosted) with some other services, not just webserver use, you would need a separate server (or virtual machine) running a separate OS.

About all that stuff you posted above... *grin* i get not even a half of it. Sure not, i am working with stuff like this for not even a year, i did not expect anything else. Thank you for the reply tho, it did clear things out (compared to other thread i posted a few days ago; "how to get your logo on top centre").

So the overall answer is (please correct me if i am wrong);
  • If you host Xenforo on your host, you would need an Mail server.
  • Php-based email sening methods don't work (still don't get why, please explain if you have time & want to)
  • If you still want to selfhost you need to set this up.
I am sure that i am somewhere wrong, so please (again) correct me.

Thank you :)
 
First more info is required.
On your dedicated server (which is what I assume you are wanting to use for everything), what OS are you using (Ubuntu, Debian, CentOS, etc).
What MTA is installed (Exim, Postfix)?
If you haven't configured your MTA then that is the very first step you need to do. Many times some installs are NOT set up to send out mail to the web (usually due to the fact most people don't know how to configure it and end up setting it up as an open relay).
 
First more info is required.
On your dedicated server (which is what I assume you are wanting to use for everything), what OS are you using (Ubuntu, Debian, CentOS, etc).
What MTA is installed (Exim, Postfix)?
If you haven't configured your MTA then that is the very first step you need to do. Many times some installs are NOT set up to send out mail to the web (usually due to the fact most people don't know how to configure it and end up setting it up as an open relay).
OS: Debian 7
Installed software: Fail2Ban, Java 8-JRE, PHP, MySql, Pyton, Apache2 (i think that's it)
MTA: Nothing at the moment, i was going to use the basic PHP-based email function, but i did not know it does require an additional software to be installed (or use an STMP service)

Thank you for info :)
 
OS: Debian 7
Installed software: Fail2Ban, Java 8-JRE, PHP, MySql, Pyton, Apache2 (i think that's it)
MTA: Nothing at the moment, i was going to use the basic PHP-based email function, but i did not know it does require an additional software to be installed (or use an STMP service)

Thank you for info :)
Add ufw to the list, memcached, and imageMagick, and it's basically what I use too. hehe
 
OS: Debian 7
Installed software: Fail2Ban, Java 8-JRE, PHP, MySql, Pyton, Apache2 (i think that's it)
MTA: Nothing at the moment, i was going to use the basic PHP-based email function, but i did not know it does require an additional software to be installed (or use an STMP service)
Been a while since I installed Debian, but I believe it uses Exim - and the default install of it is only configured for local delivery. You will have to modify it to the "internet" selection if you chose to use the PHP method.
 
Back
Top Bottom