Problem with email form

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
wickford
-


Joined: 21 Aug 2003
Posts: 9

PostPosted: Mon Jan 29, 2007 11:20 am    Post subject: Problem with email form Reply with quote

Hi,
I'm trying to add a PHP form I found on the Internet, but when I press send this error appears:

Quote:
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files\Abyss Web Server\htdocs\sendemail.php on line 49


contact.php:
Code:
<form method="post" action="sendemail.php">

<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>

<label for="visitor">Name</label>
<input type="text" id="visitor" name="visitor" /><br />
<label for="visitoremail">Email:</label>
<input type="text" id="visitoremail" name="visitoremail" /><br />
<label for="attn">Type of enquiry:</label>
<select id="attn" name="attn" size="1">
 <option value="General">General Questions</option>
 <option value="ProductInquiry">Product Inquiries</option>
 <option value="ServiceInquiries">Service Inquiries</option>
 <option value="SiteComments">Website Comments</option>
</select><br />
<label for="notes">Enquiry:</label>
<textarea id="notes" name="notes" rows="4" cols="40"></textarea>
<br />
<input class="submit" type="submit" value="Send" /><br />

<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />

</form>


sendemail.php:
Code:
<?php
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Please enter a valid email address</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Please fill in all the fields</h2>\n";
}

$todayis = date("l, F j, Y, g:i a") ;

$attn = $attn ;
$subject = $attn;

$notes = stripcslashes($notes);

$message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

$from = "From: $visitormail\r\n";


mail("sample@email.com", $subject, $message, $from);

?>

<p align="center">
Date: <?php echo $todayis ?>
<br />
Thank you, <?php echo $visitor ?> (<?php echo $visitormail ?>).
<br />

Attention: <?php echo $attn ?>
<br />
Message:<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?>

<br /><br />
<a href="contact.php">Back</a>
</p>


If you can help it would be greatly appreciated.
~wickford


Last edited by wickford on Mon Jan 29, 2007 1:47 pm; edited 1 time in total
Back to top View user's profile Send private message
hc2995
-


Joined: 07 Aug 2006
Posts: 644
Location: Maryland, USA

PostPosted: Mon Jan 29, 2007 1:36 pm    Post subject: Reply with quote

Are you trying to use a mail server on your pc? If so, does it require you to login? If it does require you to login, php doesnot support SMTP authentication. If the mail server is not on your Pc then open your php.ini file and look for SMTP, then change it to your mail server address. (and if it has a ";" at the begining, remove it)
_________________
Where have i been? School got heck-tick, had to move half way around the state, then back... and then i had to change jobs, so iv been away for a while :P
Back to top View user's profile Send private message AIM Address
Gannyaa
-


Joined: 29 Sep 2006
Posts: 93
Location: Nelson, BC -- Canada

PostPosted: Wed Feb 14, 2007 12:29 am    Post subject: Ha I just found SMTP Simple Authentication Reply with quote

Ha I just found SMTP Simple Authentication!

Quote:
Are you trying to use a mail server on your pc? If so, does it require you to login? If it does require you to login, php doesnot support SMTP authentication


PHP does support SMTP Authentication. I searched and searched the web and found a few classes. Instead of using the sendmail() or mail() functions in PHP with the smtp.php classes you use sendmessage() and the classes will authenticate for you. I got SMTP working so that my website can send simple contact me form messages to my email.

I use ArgoSoft because it works on my Win98 machine..

need more help I can zip the php files. I was looking in another thread how to do this. Then I found it installed the classes and completed the test and it worked... ! No need for a third party emails!

Blah blah blah
_________________
Todd (Gannyaa)
http://iGannyaa.bebo.com/
http://haidavision.no-ip.info/gannyaa/newblog.htm
Back to top View user's profile Send private message Send e-mail Visit poster's website
Ely
-


Joined: 05 Apr 2005
Posts: 5
Location: Columbus, Ohio, USA

PostPosted: Thu Mar 01, 2007 3:24 am    Post subject: Authentication script... Reply with quote

Hi,

Thanks for the tip. I just downloaded ArGoSoft's freebie mailserver (http://www.argosoft.com/RootPages/Download.aspx), and got it running with php and Abyss. Had to set my php.ini file thus:

SMTP= 127.0.0.1 ; you could use "localhost" in quotes too.
sendmail_from= mailserver@mydomain.com ; you would use your string here.

for details see http://us3.php.net/manual/en/ref.mail.php#ini.smtp

I am running my script without authentication. I would be very grateful if you would post your authentication hooks into argosoft.

Many thanks.
Back to top View user's profile Send private message Visit poster's website Yahoo Messenger
Gannyaa
-


Joined: 29 Sep 2006
Posts: 93
Location: Nelson, BC -- Canada

PostPosted: Fri Mar 02, 2007 3:17 pm    Post subject: Some SMPT authentication Links... Reply with quote

Some SMPT authentication Links...

This is where I found the SMPT authentication links first by hc2995
http://www.aprelium.com/forum/viewtopic.php?t=10848&highlight=authentication

More directly:
http://news.php.net/article.php?group=php.general&article=130351

I really haven't needed to use the SMPT wrapper. My abyss, php and argsoft work well together as long as the php.ini file allows localhost!

After testing SMPT, I joined the ArgoSoft Support Forum (much like this one) and found a very useful tool.

http://www.dnsreport.com/tools/dnsreport.ch?domain=aprelium.com
To check another domain Change the domain name.

Looking at this report, Notice that aprelium has duplicate MX records, is missing an SPF record, one NS not responding, and failed a Reverse DNS look up.

My DNS report show a warning where my NS are .com's and my domain is a .ca or no-ip.info domain, which I and most servers can live with.

Later
_________________
Todd (Gannyaa)
http://iGannyaa.bebo.com/
http://haidavision.no-ip.info/gannyaa/newblog.htm
Back to top View user's profile Send private message Send e-mail Visit poster's website
Gannyaa
-


Joined: 29 Sep 2006
Posts: 93
Location: Nelson, BC -- Canada

PostPosted: Sat Mar 03, 2007 3:22 pm    Post subject: added note: Reply with quote

To continue ....

To create an SPF record... A wizard would be nice.
So I went to No-ip.com where I get my domain name services from,
and In the managed domain names page, there is a SPF wizard to help you create one for your email server.

I'm not sure if other domain name companies have a wizard. I'm glad no-ip.com had one, so I didn't have to riffle through a lot of paper work to figure it out.

Can't say it enough, say it again, ABYSS is the BEST !
I love learning PHP, it works great with what I already know.
The tech guys here are awesome. :)
_________________
Todd (Gannyaa)
http://iGannyaa.bebo.com/
http://haidavision.no-ip.info/gannyaa/newblog.htm
Back to top View user's profile Send private message Send e-mail Visit poster's website
Ely
-


Joined: 05 Apr 2005
Posts: 5
Location: Columbus, Ohio, USA

PostPosted: Sat Mar 03, 2007 4:19 pm    Post subject: Reply with quote

Todd,

Thanks for your posts.

I hate to whine but your posts are like the start of a quest for the holy grail. I read your links about authentication and found out that it can't be done unless you add a PHP class and use a different function. There was nothing to download. Plus I saw nothing about how to add a class to PHP. Sounds like you need to recompile. How do you add a class?

Then your mention about the no-ip.com SPF wizard. I visited their site, got a sales pitch but couldn't find the wizard. I even searched their site map. Of course if you google "SPF wizard" you get this:

http://old.openspf.org/wizard.html

Seems a bit more direct.

I think I'll just stick with unauthenticated SMTP on my argosoft mail server. It's working pretty well. My only problem is that my form mail is going to my gmail spam bucket. I think it's because I'm using google apps for my email (except the form), so my MX records are set to a different server than my argosoft server (only used for sending forms).

I'm working on that now, and I might just move my domain's entire email system to argosoft and use its webmail interface. I'll post how that turns out.
Back to top View user's profile Send private message Visit poster's website Yahoo Messenger
Ely
-


Joined: 05 Apr 2005
Posts: 5
Location: Columbus, Ohio, USA

PostPosted: Sun Mar 04, 2007 2:09 am    Post subject: argosoft mailserver with php form Reply with quote

ok, got the argosoft working with a php form. The SPF wizard is a very nice tool. Got my domain name's SPF record set up. Checked the record here:

http://www.seoconsultants.com/tools/spf/

and here:

http://www.kitterman.com/spf/validate.html?

the DNS report you posted earlier was invaluable because it helped me do the old trial-and-error until everything passed. It's a good thing enom has an SOA TTL of 181 seconds. Makes mucking with the settings and checking results much quicker. Anyway, I repeat the DNS report url here:

http://www.dnsreport.com/

Turns out authentication is not an issue with the localhost form mail. Here's why. Argosoft lets you set up IP's that Do NOT get authenticated. So I included 127.0.0.1 in that list, and my php script can send email to the net, but my box is not an open relay.

To make it work and have your email not show up as spam, you need to set up the following:

MX host in your DNS (MX A <yourip>)
MX user email record (mx.yourdomain.com 10)
SPF record for the root (@) (TXT v=spf1 a mx mx:yourdomain.com ~all)
SPF record for MX (TXT v=spf1 a ~all)

That should about do it with the domain mail settings.

A few things to remember about Argosoft's settings:

Add a user postmaster (you can forward that mail to some other place, but you need a postmaster to pass the mail DNS mailserver test.)

Add a user abuse (same deal as above)
Put your domain name in the Local Host setting: yourdomain.com
put your domain name in the list of local domains: yourdomain.com
if you're going to use the webmail interface with argosoft, change the port number so it doesn't conflict with abyss. I'm using 8080

I selected SMTP Authentication and also selected Use POP3 UN/Pw. I don't think this setting really matters in my case, because I also added 127.0.0.1 and my LAN IP to the list of IP's not to authenticate.

Set your router/firewall to have your mailserver machine handle unsolicited requests for ports:

25
110
79
8080 (my example)

I'm not sure if this is needed. I don't know if argosoft tries to open these ports through the router when it starts. But just to be safe, that's what I did.

OK, that's the long and short of it. Seems to work great. Abyss serves up the pages on port 80. Surfer fills out a form and it gets PHPed to argosoft. Argosoft relays it to the net. And all that is happening on a throw-away W98 machine. The surfer probably thinks there's an IBM blade serving it up. :)

Amazing stuff!
Back to top View user's profile Send private message Visit poster's website Yahoo Messenger
Gannyaa
-


Joined: 29 Sep 2006
Posts: 93
Location: Nelson, BC -- Canada

PostPosted: Sun Mar 04, 2007 5:53 pm    Post subject: The PHP Classes link... Reply with quote

The PHP Classes link...

I forgot to mention that at the links to the PHP classes, you have to register (Its free) and subscribe to a weekly PHP classes newsletter. Once you're registered, you can download the classes.

The classes are really just php files. To add the SMPT authentication and test you can either include() or require() the php file (or .class.) at the beginning of your php code. The files I found where smpt.php and a couple of others. Then you can use the variables and functions of that php file in your own php page or file. I don't use the php classes either anymore, as ArgoSoft seems to work fine with Abyss when you define localhost or your domain name.

If found that DNS tool invaluable too... It really helps with the trial and error, debugging so to speak, and fixing your dns so the report passes.
_________________
Todd (Gannyaa)
http://iGannyaa.bebo.com/
http://haidavision.no-ip.info/gannyaa/newblog.htm
Back to top View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group