1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Test email notifications on localhost dev install

Discussion in 'XenForo Development Discussions' started by RichardKYA, Jul 28, 2016.

  1. RichardKYA

    RichardKYA Well-Known Member

    Hey everyone,

    Is it possible to test e-mail notifications on a local machine using xampp?

    I've tried searching online to find an answer and I've tried making changes to xamppfiles/etc/php.ini file as a few articles have suggested, but I have no idea if I've done it correctly/need to do something else or if it's just my add on code that is not working. That said, I've tried watching a thread with e-mail notifications, making a new post and that hasn't been sent either, so I'm assuming it's the set up. I also tested this before making any changes to the php.ini, but I have no real way of knowing because I'm not receiving any errors or any confirmation either, so I'm left scratching my bald head and wishing that I still had hair.

    If it helps, I'm using a macbook pro with El Capitan and XAMPP 7.0.4-0.

    Any help or tips would be greatly appreciated

    Thank you in advanced :)
  2. Brogan

    Brogan XenForo Moderator Staff Member

    You would probably need to install a mail transfer agent such as Postfix or SendMail and configure PHP to use it correctly (sendmail_path).

    Also, make sure you don't have this in the config.php file:
    $config['enableMail'] = false;
    RichardKYA likes this.
  3. Chris D

    Chris D XenForo Developer Staff Member

    I highly recommend "MailTrap":


    The free usage tier should be about enough for basic email testing.

    Sign up, it provides you with a specific SMTP server and username and password, add that to your Email Options in XF as you normally would, and all emails sent via XF (regardless of the recipient) will be delivered to your MailTrap inbox, where you can view how the mail would look in HTML and text format.
    RichardKYA and Brogan like this.
  4. RichardKYA

    RichardKYA Well-Known Member

    Hi @Brogan,

    Yeah, I updated my config.php and one of the things I done in the php.ini was add:

    sendmail_path = "env -i /usr/sbin/sendmail -t -i"
    Which apparently is what other mac users have added to get it working. I did read something about postfix, but it also said something about security issues with it, so I didn't look too much further into it.

    Hi @Chris,

    That sounds great, I will give that a go (y)

    Thank you both for your responses
  5. RichardKYA

    RichardKYA Well-Known Member

    Hi @Chris,

    Sorry to be a pain.

    I've signed up to mailtrap and added the credentials to the ACP > Email Options and although an attempt to send the email is being made, I keep receiving this error in log:

    Zend_Mail_Protocol_Exception: Email to name@domain.com failed: ' mailtrap.io' appears to be a DNS hostname but cannot match against hostname schema for TLD 'io', ' mailtrap.io' does not appear to be a valid URI hostname, ' mailtrap.io' does not appear to be a valid local network name - library/Zend/Mail/Protocol/Abstract.php:145
    Generated By: Unknown Account, 2 minutes ago
    Here's the credentials it provided:


    ACP > Email Options:

    Screen Shot 2016-07-28 at 15.19.54.jpg

    I've tried it with and without the optional TLS encryption, but still have the same result.

    Any ideas on what I am getting wrong?

    Thank you
  6. Chris D

    Chris D XenForo Developer Staff Member

    There appears to be a space before the hostname.

    The error suggests it is ' mailtrap.io' rather than 'mailtrap.io'.

    That said, it seems to be complaining about the '.io' TLD rather than the hostname itself. If it genuinely is that it's complaining about you will need to see if they offer an alternative hostname, or use its IP address directly. Based on a ping I just did, that may well be
  7. RichardKYA

    RichardKYA Well-Known Member

    Yep, it had a space in front of it lol

    That's what you get for copying and pasting stuff. The irony is, I copied and pasted so that I wouldn't get it wrong :ROFLMAO:

    Anyway, with my dumbassery over, things seems to be working well and my add on sends the e-mails just fine *High five*

    Brilliant recommendation of Mailtrap by the way, it was so easy to sign up and if it wasn't for my simple error, this would have been up and running in less than 3mins, so *high ten* for that

    Thanks again for your help
  8. Xon

    Xon Well-Known Member


    I wrote Email Transport to /Dev/Null add-on purely for this sort of thing.

    You can then configure it to throw fail mail delivery (or silently discard email), report HTML or TEXT or the email if required.

Share This Page