Forum Moderators: coopster

Message Too Old, No Replies

Email forms without MAIL( ) function.

Need help submitting forms using php server side script.

         

GrapefruiTgirl

8:20 pm on Jul 29, 2006 (gmt 0)

10+ Year Member



Several servers I have had my site hosted on took care of the technical details of email form submitting; I simply set the ACTION="http://MySite.MyDomain.Com". Now, my current host seems not to do this, or anything remotely like this. I have tried about 6 or 7 php scripts for email forms to no success, only error messages or nothing at all. I have read what I can find on this site here, as well as the About.com php tutorials and whatever else I can find. I think there is more I need to know about the server-side of things, such as where is the CGI-BIN directory, if there is one and if I need to use it; and also, Do I really need a Database and Tables just to send a simple form to email?.
My host server claims to support php, and also I have available to me a php/MyAdmin/MySQL area, but I don't know how to use this. My host also has the Mail() function disabled to deter spammers apparently, and it seems to be this function which all the scripts I can find are using. How then, without using this Mail() function, can I have my contact form submitted and emailed to me?
PS- I am not an expert at this stuff by any stretch, but have a good grip on HTML and page design; the rest of my site works very well, except now for the Contact Page. It's the scripting stuff which is turning my hair grey since going to this new host! Please help!

Sasha

eeek

9:00 pm on Jul 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



My host also has the Mail() function disabled to deter spammers apparently, and it seems to be this function which all the scripts I can find are using. How then, without using this Mail() function, can I have my contact form submitted and emailed to me?

You can create a socket and connect to port 25 of your mail server (assuming they don't have the port blocked) and then do the SMTP yourself.

GrapefruiTgirl

9:15 pm on Jul 29, 2006 (gmt 0)

10+ Year Member



Hello eeek! Thank you for that input :) but I need more information than that. Can you point me to a tutorial on that? Creating a socket? thats new one.
Thank you very much.
Sasha

supermoi

9:37 pm on Jul 29, 2006 (gmt 0)

10+ Year Member



Try using phpMailer. It's an awesome class.

eelixduppy

2:44 am on Jul 30, 2006 (gmt 0)



Welcome to WebmasterWorld GrapefruiTgirl!

>>>Do I really need a Database and Tables just to send a simple form to email?.
No

Take a look at PHP's Mail Functions Page [us3.php.net]. The user-submitted content can point you in a direction that may work for you.

Good luck!

GrapefruiTgirl

2:38 am on Jul 31, 2006 (gmt 0)

10+ Year Member



Thank you for the welcome, eelixduppy!
I am currently downloading php to use with my local Apache server to see if I can get this sorted out on my own machine first, before trying again to get it to work on my actual site host's server.
If I can get it working here, shouldnt be an issue really, but... lol, dont count my chickens.. I likely still will need coaching on getting this SMTP port 25 email thingie working, as my real host does not allow the MAIL() function.

Sasha

jatar_k

5:59 pm on Aug 1, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld GrapefruiTgirl,

I have used this as a straight shot into sendmail, might give you some ideas

function SendmailAPI( $EmailTemplate, $whowhere = 'address@example.com' ){
if( FALSE === ( $pipe_handle = popen( "/usr/lib/sendmail -t -f $whowhere", "w" ) ) )
return( -1 );
$tx = fwrite( $pipe_handle, $EmailTemplate );
pclose( $pipe_handle );
return( $tx );
}

GrapefruiTgirl

5:02 pm on Aug 1, 2006 (gmt 0)

10+ Year Member




System: The following 2 messages were spliced on to this thread from: http://www.webmasterworld.com/php/3030361.htm [webmasterworld.com] by jatar_k - 11:29 am on Aug. 1, 2006 (pst -7)


OK, finally got (another version of) Apache running on my WinXP machine as a testing server for my site, and I seem to have the php working basically..
However, as my site/server runs as "http://localhost/...", are the settings in the php.ini file correct for sending SMTP mail on port 25?
Here is what's in the php.ini file in the [MAIL] department:

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
sendmail_from = grapefruity@hotmail.com
<--not my real address

Or do I have to set something here or somewhere so that the mail being sent actually leaves my computer and goes to my I.S.P or something like that to get processed?
I am getting an Error message from my php form-mail script, but I can't tell what is causing the error (doesn't help that the plain-text in the script is in Italiano :o ) but here is a bit of lines from the script where the error is being generated, with what I believe are the english translations for the $variables but I don't know what an 'Intestazioni' is.. It sounds like intestines though..

[b][4]

if ($html)
{
$output = getHtmlOutput ($key, $val);
$intestazioni = "MIME-Version: 1.0\r\n";
$intestazioni .= "Content-type: text/html; charset=iso-8859-1\r\n";
}
else
{
for ($i = 0; $i < count ($key); $i++)
{
$output .= $key[$i].": ".$val[$i]."\n";
}
$intestazioni = "";
}
if ( (!empty($emailAddress)) ¦¦ (!empty($Name)) )
{
$intestazioni .= "From: ".$Name."<".$emailAddress."> \r\n";
}
else
{
$intestazioni .= "From: ".$Address."\r\n";
}
if (!mail($destination, $subject, $output, $intestazioni))
{
echo "<br>".$AAARGH-The-ERROR-MSSG."<br><br><br>".getHtmlOutput($key, $val)."<br><br><br>".getCredits();
if (strlen($paginaErrore) < 5)
{
exit ();
}
else
{
echo "<META HTTP-EQUIV=Refresh CONTENT=\"10; URL=".$paginaErrore."\">";
}
}
echo "<br>".$messaggioConferma."<br><br><br>".getHtmlOutput($key, $val)."<br><br><br>".getCredits();

[/b][/4]

It has been suggested to me that I use 'PhpMailer', and I have it now, but this script looks so much simpler/smaller. it aaalllllmost works :)
Thanks so much everyone!
Sasha

GrapefruiTgirl

5:32 pm on Aug 1, 2006 (gmt 0)

10+ Year Member



Woo Hooo It works it works!
Haha, I hadda direct the smtp thingie in the php.ini towards my ISP's smtp server, and change some little thing about the sender name, like maybe it was the space in between the "NAME <address>",
but it works.. er, well, the mail hasn't arrived yet, but, well it SENT! That's a good thing isnt it?
:)
ok.. will it all work if I upload this stuff to my host.. LOL then what will I use for the smtp server?
More on that later, it's time for a break while I still have hair on my head..
Sasha

jatar_k

6:31 pm on Aug 1, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I figured we could splice this all together since it deals with the same issue

>> will it all work if I upload this stuff to my host

no, because you can't change their php.ini and that is how you set yours up. You also have it set up on your local windows machine. Is your site hosted on a windows box? Those settings are different for win or *nix.

GrapefruiTgirl

6:50 pm on Aug 1, 2006 (gmt 0)

10+ Year Member



hmm good idea Jatar RE: splicing this together..

I am noticing though, this script I am using is actually still using the mail () function is it not? Or is this php stuff different than the normal (?) html MAIL() function?

And I guess I have jumped the gun, as my mail had apparently SENT but has definitely not ARRIVED as of yet, its been lika an hour :( boo hoo..

Right: No, my site is currently hosted on Linux, but I hope to move it again very shortly, maybe tonight even, though I see mostly Linux/Apache hosts out there;Pretty common.. Not sure what my potential next host is running on, but I hope to hear back from them soon about whether they will host me or not...
I guess they will (hopefully) have an SMTP server of their own which I will be able to use for this purpose? I realize I cannot change their php.ini file, so... where does this leave me.

Still researching.....
Thanks!

Sasha

jatar_k

6:54 pm on Aug 1, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> my site is currently hosted on Linux

much better imo, I was mainly pointing out that your local environment wouldn't be an exact match to your host

>> this script I am using is actually still using the mail () function is it not

yes it is, right here
if (!mail($destination, $subject, $output, $intestazioni))

you just need a host that allows you to use the mail function or gives another alternative so you can send mail from scripts

have you asked your present host if they have an alternative?

GrapefruiTgirl

7:05 pm on Aug 1, 2006 (gmt 0)

10+ Year Member



Hmmm, thats a good one, asking my current host of they have something.. I don't think they have a pulse :o I havent gotten an email reply from their help, their support, OR their ICQ contact addresses.. I think the server is on auto pilot :) so no , I don't know if they have any other means of allowing mail through but based on the types of sites that are hosted in that domain it might be safe to assume that there isnt a lot of demand for contact forms etc..
And yes, I realised the setup on a different server would have differnt variables and ports and addresses etc, but theoretically would still be using the same basics.
Finally yes I recognized the!mail() line in the code, but wasnt sure if that was the same mail() function in every scripting/html language. Thanks for that :)

Perhaps my best bet is to wait and find out what sort of system Im going to be hosted on next and go from there.
Sasha

GrapefruiTgirl

2:18 am on Aug 2, 2006 (gmt 0)

10+ Year Member



Whew... After the last 2 days, I finally try an experiment tonight:
In my php.ini and in my config.php for my mail sending script, I replaced my grapefruity@hotmail.com address with my grapefruity@yahoo.com one, and WHAMMO! Instant emails coming into my account from the php formmailer.. LOL
Darned SMTP server at my ISP obviously doesnt forward emails having much to do with hotmail (reply) addresses (thats Sympatico by the way, for all you other sympatico users who's php-mail isnt going anywhere). I guess the hotmail from all my hotmail addresses are either going through the MSN smtp servers or perhaps I need that SMTP AUTH function I havent learned yet..
Still working, but happy the mails getting from somewhere to somewhere! :) :)

Sasha!
(note: the above addresses are phoney baloney)

barns101

12:05 pm on Aug 2, 2006 (gmt 0)

10+ Year Member



If you were initially sending the test email to Hotmail it's more likely that Hotmail blocked it, rather than your ISP not sending it.

GrapefruiTgirl

1:35 pm on Aug 2, 2006 (gmt 0)

10+ Year Member



Interesting idea Barns. I don't know for sure.
But it doesnt make sense that Hotmail would block my email from my own address does it? As in, FROM:myname@hotmail.com TO:myname@hotmail.com

I can send myself mail any other time using any mail system, so.. Just dunno.

Sasha

ps - Now I am sending FROM:myname@yahoo.com TO:myname@yahoo.com via my sympatico SMTP and no problem, its there in like 5 seconds.

PPS - since I would prefer to use hotmail-to-hotmail ultimately, I think I best get onto this SMTP Authorization stuff and eventually use the MSN SMTP server with my name and password.

[edited by: GrapefruiTgirl at 1:39 pm (utc) on Aug. 2, 2006]

barns101

2:56 pm on Aug 2, 2006 (gmt 0)

10+ Year Member



The FROM: email address makes no difference as far as Hotmail is concerned. Anyone could claim to be sending email from a Hotmail account simply by setting that as the FROM: address. Hotmail looks at the IP address that the email originates from and bases their filters on that, as well as the content of the email.

From my experience, Hotmail will block your email if your domain name doesn't have a valid PTR record. Seeing as Hotmail's IP does not match your IP (that you send the email from), they see it as being spoofed.

(That's how I understand it in simple terms, maybe someone will be able to explain better! ;))

GrapefruiTgirl

3:04 pm on Aug 2, 2006 (gmt 0)

10+ Year Member



Hmm Ok I see RE: the From address, that makes sense.
And as far as content, I havent been slandering myself in these test emails :O Hehehe..
SO.. The PTR Record... Would that come from the originator of the mail? As in my Computer's server here in front of me? If so, I guess there is no PTR record, good/bad/or otherwise..
Or does that PTR record come from teh SMTP server that I am sending thru?
I am guessing it would be from MY server here at home, if I were actually live here and had a working domain name (its only localhost, a testing server).. However, whether I use a hotmail or yahoo or whatever other address to send FROM my server at home here, the PTR record will be the same regardless, right? I mean, changing my FROM address doesnt affect that. So its safe to suppose just that Yahoo doesnt care where the email comes from, but hotmail does to a degree?
But, atleast I am getting the mail to my!oohaY account, and from there if I get really motivated, I will auto-FWD the mail to my hotmail address.. Problem solved :)
Thanks for your input too Barns ;)

Sasha

[edited by: GrapefruiTgirl at 3:09 pm (utc) on Aug. 2, 2006]

barns101

2:11 am on Aug 3, 2006 (gmt 0)

10+ Year Member



I'm no expert re: PTR records but I think it works something like this:

Your domain name (i.e. the FROM: address) points to the IP address of the server that hosts it. When Hotmail receives an email it looks up the IP address corresponding to the FROM: domain name. Hotmail then does a reverse DNS lookup on the IP address and should find a PTR record for the domain name in the FROM: address. If there is no PTR record or it is incorrect (as mine is on my shared host :( ), Hotmail simply does not deliver the email. As far as I know, the PTR record is set up by whoever controls the DNS.

And since Hotmail probably assumes that if you're sending email from a Hotmail email address you will be doing so from the Hotmail website, it probably blocks emails with a Hotmail FROM: email address that are not sent from a Hotmail IP address. (I'm just making assumptions here!)

GrapefruiTgirl

1:31 pm on Aug 4, 2006 (gmt 0)

10+ Year Member



Allrighty.. Hmmm.
Barns (or anyone) lemme ask you then, keeping mind you aren't an expert (and neither am I by any stretch) your opinion of this in your experience:

1- Lets say I have my site hosted live somewhere like GrapefruitSite.ReputablePTR.net. Do you suspect I might be able perform mail functions using TO:hotmail.com and FROM:Grapefruitgirl@GrapefruitSite.ReputablePTR.net and have the mail be delivered?

2- assuming the same host, ReputablePTR.net, am I limited in my mail functions, to using the SMTP server (if present) provided by ReputablePTR.net, OR could I continue to route my mail through my own ISP's SMTP server (sympatico) as I currently am, and expect it to be delivered (as opposed to how the mail is currently coming from from my computer's localhost testing server, which is actually connected to my ISP)?
(I guess a simpler way of asking that is: Can just anybody send mail via an ISP's SMTP server, or does a person have to be a customer of the ISP, and be connected via the ISP, to use the ISP's mail server?)

Thanks for any input :)
Sasha

[edited by: GrapefruiTgirl at 1:48 pm (utc) on Aug. 4, 2006]