GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Configuring SMTP to work on FreeBSD 9.0 server. (https://gfy.com/showthread.php?t=1091677)

GFED 12-04-2012 07:53 PM

Configuring SMTP to work on FreeBSD 9.0 server.
 
Okay, so I'm working on another project where I've set up a FreeBSD system on one of my older computers. I've set up Apache, PHP, mySQL, and myPHPadmin on the box and tested a few PHP scripts from hotscripts.com

The box is running on a local IP address of 192.168.1.77 as hostname "freebsd" and my router is set to forward it any incoming connections to port 80.

One of the scripts I am trying to install requires an SMTP server so in the config files I set it as:
$email_server = 'outgoing.verizon.net'; // What mail server (an FQDN DNS name) should emails be sent from?

However, this doesn't seem to work and I'm wondering if I need to setup my own SMTP on the box itself, or do I need to install something such as mail/ssmtp to get it to work?

Telnet into the SMTP server on port 25 is successful.
Code:

freebsd# telnet outgoing.verizon.net 25
Trying 206.46.232.12...
Connected to outgoing.verizon.net.
Escape character is '^]'.
220 vms173021pub.verizon.net -- Server ESMTP (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009))


The script I am trying to install is called BlackNova Traders and can be found at http://sourceforge.net/projects/blacknova/


Thanks.

edgeprod 12-04-2012 08:02 PM

It's difficult to tell from just a variable declaration what the script is trying to do. Does your SMTP server require authentication, or just being on the correct IP block is enough?

edgeprod 12-04-2012 08:07 PM

I browsed the code tree for occurrences of email_server, and I only see one, and it's in that file only. Maybe it's a future feature that hasn't been implemented yet?

edgeprod 12-04-2012 08:10 PM

Browsing further through the code, it seems to take advantage of mail(), which is a built-in function and will use the SMTP settings of your server.

GFED 12-04-2012 08:15 PM

Quote:

Originally Posted by edgeprod (Post 19351904)
It's difficult to tell from just a variable declaration what the script is trying to do. Does your SMTP server require authentication, or just being on the correct IP block is enough?

Good question. I've used Yahoo mail for over that past 12 years so I'm not sure. I'll have to look into that further. I'm just learning as I go. I'm finding it very interesting learning to manage my own web server. Most of the time I've spent the past couple days has been troubleshooting my log files.

Quote:

Originally Posted by edgeprod (Post 19351909)
I browsed the code tree for occurrences of email_server, and I only see one, and it's in that file only. Maybe it's a future feature that hasn't been implemented yet?

A new player has to create an account to play the game, and his password is sent to him VIA email.

GFED 12-04-2012 08:17 PM

Quote:

Originally Posted by edgeprod (Post 19351911)
Browsing further through the code, it seems to take advantage of mail(), which is a built-in function and will use the SMTP settings of your server.

Okay, so if my server has no SMTP settings I would have to set something up such as this?
http://www5.us.freebsd.org/doc/handb...oing-only.html

edgeprod 12-04-2012 08:17 PM

Quote:

Originally Posted by GFED (Post 19351919)
A new player has to create an account to play the game, and his password is sent to him VIA email.

Via mail() from what I can see. It doesn't use that variable anywhere that I can tell. I'm looking directly at the implementation in the code.

I'm working on MUCH more complex code in another window, and it has 85% of my focus while I wind down from a rough day of looking at said code ... so this is a welcome distraction for a bit.

edgeprod 12-04-2012 08:18 PM

Quote:

Originally Posted by GFED (Post 19351921)
Okay, so if my server has no SMTP settings I would have to set something up such as this?
http://www5.us.freebsd.org/doc/handb...oing-only.html

I'd recommend you create an otherwise-blank PHP file, and test the mail() function with an address you know to be valid.

GFED 12-04-2012 08:31 PM

Quote:

Originally Posted by edgeprod (Post 19351924)
I'd recommend you create an otherwise-blank PHP file, and test the mail() function with an address you know to be valid.

I tried using both of the examples at http://www.w3schools.com/php/php_mail.asp and ran them from my server. It responds that it sends the mail without giving an error, but the mail is not received.

edgeprod 12-04-2012 08:36 PM

Quote:

Originally Posted by GFED (Post 19351943)
I tried using both of the examples at http://www.w3schools.com/php/php_mail.asp and ran them from my server. It responds that it sends the mail without giving an error, but the mail is not received.

Here's some things to get you going in your troubleshooting:

* Check your error logs.
* Check your sendmail config, if that's what you're using.
* Check if you can mail any of the local accounts on the server.

GFED 12-04-2012 09:37 PM

Quote:

Originally Posted by edgeprod (Post 19351951)
Here's some things to get you going in your troubleshooting:

* Check your error logs.
* Check your sendmail config, if that's what you're using.
* Check if you can mail any of the local accounts on the server.

output of the error statements per the failed transmission of email
/var/log/maillog

Code:

Dec  4 22:46:12 freebsd sendmail[3938]: qB53kC5j003938: from=www, size=125, class=0, nrcpts=1, msgid=<[email protected]>, relay=www@localhost
Dec  4 22:46:12 freebsd sm-mta[3939]: qB53kCiI003939: from=<[email protected]>, size=386, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=Daemon0, relay=localhost [127.0.0.1]
Dec  4 22:46:12 freebsd sendmail[3938]: qB53kC5j003938: to=*******@yahoo.com, ctladdr=www (80/80), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30125, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (qB53kCiI003939 Message acce

all settings are default. assuming these might be relevant to my problem? should port 587 be port 25 or is port 25 no longer used for smtp?
/etc/mail/sendmail.cf

Code:

O DaemonPortOptions=Name=IPv4, Family=inet
O DaemonPortOptions=Name=IPv6, Family=inet6, Modifiers=O
O DaemonPortOptions=Port=587, Name=MSA, M=E

# SMTP client options
#O ClientPortOptions=Family=inet, Address=0.0.0.0

changing the php script to send mail to root@freebsd was sucessful in transmitting.

Code:

freebsd# sendmail -bv root
root... deliverable: mailer local, user root
freebsd# sendmail -bv *******
*******... deliverable: mailer local, user *******

Code:

freebsd# mail
Mail version 8.1 6/6/93.  Type ? for help.
"/var/mail/root": 1 message 1 new
>N  1 *******@yahoo.com    Tue Dec  4 23:28  23/746  "testing mailform to root@freebsd"
& 1
Message 1:
From [email protected] Tue Dec  4 23:28:26 2012
Date: Tue, 4 Dec 2012 23:28:26 -0500 (EST)
To: [email protected]
Subject: testing mailform to root@freebsd
X-PHP-Originating-Script: 0:mailform.php
From:*******@yahoo.com

this
is
a
test


&


mail seems to be working fine internally just not outbound.

edgeprod 12-04-2012 09:40 PM

587, if I remember correctly, is the "alternate" SMTP port, designed to get around the ISP blocking port 25.

In your case, sendmail probably isn't properly configured to talk to the outside world. It may need ports exposed (or forwarded) on the router, or some other settings. Next thing on your list should be checking out the sendmail docs, specifically for FreeBSD.

Supz 12-04-2012 09:51 PM

wouldnt any outbound email server need a public ip address?

sandman! 12-04-2012 10:54 PM

when you ready for a managed freebsd 9 box let me know :)

GFED 12-04-2012 11:52 PM

Quote:

Originally Posted by edgeprod (Post 19352018)
587, if I remember correctly, is the "alternate" SMTP port, designed to get around the ISP blocking port 25.

In your case, sendmail probably isn't properly configured to talk to the outside world. It may need ports exposed (or forwarded) on the router, or some other settings. Next thing on your list should be checking out the sendmail docs, specifically for FreeBSD.

Okay, according to http://www.freebsd.org/doc/en_US.ISO.../sendmail.html

Code:

29.3.1 /etc/mail/access
The access database defines what host(s) or IP addresses have access to the local mail server and what kind of access they have. Hosts can be listed as OK, REJECT, RELAY or simply passed to sendmail's error handling routine with a given mailer error. Hosts that are listed as OK, which is the default, are allowed to send mail to this host as long as the mail's final destination is the local machine. Hosts that are listed as REJECT are rejected for all mail connections. Hosts that have the RELAY option for their hostname are allowed to send mail for any destination through this mail server.

so I added the following to /etc/mail/access
Code:

localhost.localdomain                  RELAY
localhost                              RELAY
127.0.0.1                              RELAY
192.168.1                              RELAY

and compile the db
Code:

freebsd# pwd
/etc/mail
freebsd# make
/usr/sbin/makemap hash access.db < access
chmod 0640 access.db

Still not working... I'll continue researching and post an update when I find something else...

Quote:

Originally Posted by sandman! (Post 19352093)
when you ready for a managed freebsd 9 box let me know :)

Yes, I have a managed box but I decided to make my own for fun. :)

GFED 12-05-2012 02:25 AM

After editing the /etc/mail/access entries I began receiving the following errors:

Code:

Dec  5 03:03:45 freebsd sm-mta[1106]: My unqualified host name (localhost) unknown; sleeping for retry
Dec  5 03:04:45 freebsd sm-mta[1106]: unable to qualify my own domain name (localhost) -- using short name

This was resolved by editing the /etc/hosts file and changing

Code:

::1                    localhost freebsd
127.0.0.1              localhost freebsd

to

Code:

::1                    localhost freebsd freebsd.local freebsd.local.home
127.0.0.1              localhost freebsd freebsd.local freebsd.local.home

Additionally, I added this line to /etc/rc.conf to load the sendmail daemon:

Code:

sendmail_enable="YES"
and verified that it had opened up the SMTP ports 25 and 587

Code:

freebsd# sockstat -4 -l
USER    COMMAND    PID  FD PROTO  LOCAL ADDRESS        FOREIGN ADDRESS
www      httpd      1216  4  tcp4  *:80                  *:*
www      httpd      1215  4  tcp4  *:80                  *:*
www      httpd      1214  4  tcp4  *:80                  *:*
www      httpd      1213  4  tcp4  *:80                  *:*
www      httpd      1212  4  tcp4  *:80                  *:*
root    sendmail  1104  3  tcp4  *:25                  *:*
root    sendmail  1104  6  tcp4  *:587                *:*
root    sshd      1099  4  tcp4  *:22                  *:*
root    httpd      1076  4  tcp4  *:80                  *:*
mysql    mysqld    1063  10 tcp4  *:3306                *:*
root    syslogd    755  7  udp4  *:514                *:*

but still not receiving messages sent via terminal to an outside destination...

Code:

freebsd# sendmail *******@yahoo.com
test
test
test
.
freebsd#

:disgust

notjoe 12-05-2012 02:39 AM

Check your spam folder. Generally speaking, emails sent from a machine without a FQDM tend to be spam.


All times are GMT -7. The time now is 05:10 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123