Submitting webforms using jmail and perl

  • skuff
  • Novice
  • Novice
  • User avatar
  • Posts: 28
  • Loc: Merseyside, UK

Post 3+ Months Ago

Hallo Everyone :)

I am having problems setting up simple forms on my website, my webhosts have told me that I will need to use something called jmail and perl, I've got a rough inderstanding what these things are but I'm a comlplete beginner when it comes to this scripting malarkey and I need some help. I am on a windows server and as far as I can make out I need to modify the following code and then upload it to the CGI-BIN folder in ASCII format but I don't know which parts I'm supposed to change.

Code: [ Select ]
use OLE;
    use CGI;
    $jmail = CreateObject OLE "JMail.SMTPMail";

print "Content-type: text/html\n\n";

$form = new CGI;
    $Recipient=$form->param('email');
    
    $domain = $ENV {'SERVER_NAME'};
    $referer = $ENV {'HTTP_REFERER'};
    $url = $referer;
    $url =~ s/^http:\/\///i;
    $url =~ s/^www\.//i;
    $domain =~ s/^www\.//i;


$Sender = "noreply\@$domain";
    $SMTPServer = "smtp.$domain:25";
    $Subject = "JMail Example";
    $Body = "This test mail sent from: $ENV{'LOCAL_ADDR'} using the JMail component on the server via Perl.";
    $Priority=3;
    $Header = "Originating-IP", $ENV{'REMOTE_ADDR'};

    $jmail->{ServerAddress} = $SMTPServer;
    $jmail->{Sender} = $Sender;
    $jmail->{Subject} = $Subject;
    $jmail->AddRecipient ($Recipient);
    $jmail->{Body} = $Body;
    $jmail->{Priority} = $Priority;
    $jmail->AddHeader ($Header);

if ($url =~ m/^$domain/)
    {
        $mailmessage = "mail sent";
        $jmail->Execute;
    }
    else
    {
        $mailmessage = "mail was not sent. Incorrect Referer";
    }
 

print "Result: $mailmessage Recipient: $Recipient";
    print "Sender: $Sender SMTP Server: $SMTPServer";
    print "Subject: $Subject Referer: $referer";
    print "Domain: $domain url: $url ";
  1. use OLE;
  2.     use CGI;
  3.     $jmail = CreateObject OLE "JMail.SMTPMail";
  4. print "Content-type: text/html\n\n";
  5. $form = new CGI;
  6.     $Recipient=$form->param('email');
  7.     
  8.     $domain = $ENV {'SERVER_NAME'};
  9.     $referer = $ENV {'HTTP_REFERER'};
  10.     $url = $referer;
  11.     $url =~ s/^http:\/\///i;
  12.     $url =~ s/^www\.//i;
  13.     $domain =~ s/^www\.//i;
  14. $Sender = "noreply\@$domain";
  15.     $SMTPServer = "smtp.$domain:25";
  16.     $Subject = "JMail Example";
  17.     $Body = "This test mail sent from: $ENV{'LOCAL_ADDR'} using the JMail component on the server via Perl.";
  18.     $Priority=3;
  19.     $Header = "Originating-IP", $ENV{'REMOTE_ADDR'};
  20.     $jmail->{ServerAddress} = $SMTPServer;
  21.     $jmail->{Sender} = $Sender;
  22.     $jmail->{Subject} = $Subject;
  23.     $jmail->AddRecipient ($Recipient);
  24.     $jmail->{Body} = $Body;
  25.     $jmail->{Priority} = $Priority;
  26.     $jmail->AddHeader ($Header);
  27. if ($url =~ m/^$domain/)
  28.     {
  29.         $mailmessage = "mail sent";
  30.         $jmail->Execute;
  31.     }
  32.     else
  33.     {
  34.         $mailmessage = "mail was not sent. Incorrect Referer";
  35.     }
  36.  
  37. print "Result: $mailmessage Recipient: $Recipient";
  38.     print "Sender: $Sender SMTP Server: $SMTPServer";
  39.     print "Subject: $Subject Referer: $referer";
  40.     print "Domain: $domain url: $url ";


Thanks
Skuff
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

It seems a little odd that a windows server would have you do it in perl. I do mine with ASP using visual basic. here's a simple one with comments that possitively works, no matter what directory it's stored in (assumes your server supports ASP and since it's a Window's server, I would have to believe so - (directory permissions should be set for read and execute scripts - cgi-bin is probably already set that way so it's just as good a place to drop it as any.) (Save as a .asp page):

Code: [ Select ]
<%
SenderEmail = request.form ("email")
SenderName = request.form ("name")
Set JMail = Server.CreateObject("JMail.SMTPMail")

' This is my local SMTP server
JMail.ServerAddress = "mailhub.yoursmptserver.com"

' This is me....
JMail.SenderName = SenderName
JMail.Sender = SenderEmail
JMail.Subject = "Subscription Submission"

' Get the recipients mailbox from a form (note the lack of a equal sign).
JMail.AddRecipient "yourmail@wherever.com"
'JMail.AddRecipient "dad@some.com"

' The body property is bodth read and write.
' If you want to append text to the body you can
' use JMail.Body = JMail.Body & "Hello world!"
' or you can use JMail.AppendText "Hello World!"
' which in many cases is easier to use.
JMail.Body ="Name = " & request.form ("name") & vbCrLf&_
"Email Address = " & request.form ("email")



JMail.Priority = 3

JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")

' Must make sure that IUSR_???? has access to the following files.
'JMail.AppendBodyFromFile "e:\mail\standard_footer.txt"
'JMail.AddAttachment "e:\products\MyProduct.exe"

' Send it...
JMail.Execute
Set JMail = nothing
%>
  1. <%
  2. SenderEmail = request.form ("email")
  3. SenderName = request.form ("name")
  4. Set JMail = Server.CreateObject("JMail.SMTPMail")
  5. ' This is my local SMTP server
  6. JMail.ServerAddress = "mailhub.yoursmptserver.com"
  7. ' This is me....
  8. JMail.SenderName = SenderName
  9. JMail.Sender = SenderEmail
  10. JMail.Subject = "Subscription Submission"
  11. ' Get the recipients mailbox from a form (note the lack of a equal sign).
  12. JMail.AddRecipient "yourmail@wherever.com"
  13. 'JMail.AddRecipient "dad@some.com"
  14. ' The body property is bodth read and write.
  15. ' If you want to append text to the body you can
  16. ' use JMail.Body = JMail.Body & "Hello world!"
  17. ' or you can use JMail.AppendText "Hello World!"
  18. ' which in many cases is easier to use.
  19. JMail.Body ="Name = " & request.form ("name") & vbCrLf&_
  20. "Email Address = " & request.form ("email")
  21. JMail.Priority = 3
  22. JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")
  23. ' Must make sure that IUSR_???? has access to the following files.
  24. 'JMail.AppendBodyFromFile "e:\mail\standard_footer.txt"
  25. 'JMail.AddAttachment "e:\products\MyProduct.exe"
  26. ' Send it...
  27. JMail.Execute
  28. Set JMail = nothing
  29. %>



The html form is just as basic (Save as an HTML page):


Code: [ Select ]
<FORM method="POST" action="/cgi-bin/subscribeform.asp">
<input type="hidden" name="required"       value="Name,SubscriberMail" />
Your Name:        
<input tabindex="1" type="text" size="30" name="name" /><br />
Your Email:            
<input tabindex="2" type="text" size="30" name="email" /><br />
<input tabindex="3" type="submit" value="Submit" title="Submit this form"><br />
</form>
  1. <FORM method="POST" action="/cgi-bin/subscribeform.asp">
  2. <input type="hidden" name="required"       value="Name,SubscriberMail" />
  3. Your Name:        
  4. <input tabindex="1" type="text" size="30" name="name" /><br />
  5. Your Email:            
  6. <input tabindex="2" type="text" size="30" name="email" /><br />
  7. <input tabindex="3" type="submit" value="Submit" title="Submit this form"><br />
  8. </form>


That is a working model. Just change the Jmail.AddRecipient to your email address and change the Jmail.ServerAddress to your hosts SMPT server and it should work for you the first time, provided you can use ASP
  • skuff
  • Novice
  • Novice
  • User avatar
  • Posts: 28
  • Loc: Merseyside, UK

Post 3+ Months Ago

Hi ATNO/TW

The account I have with the webhosts doesn't allow me to use ASP and they gave me two alternatives, upgrade my account or use Perl, I'm not upgrading my account as I am already paying £49.99 (British Pounds Sterling) a year but they do offer a 30 day money back guarantee which I may have to take them up on if I can't sort these forms out.

Cheers
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

That sorta sucks! Whoever heard of a Windows Server host that didn't offer at least ASP 3.0 on their basic plans? Well, then...I don't know Perl well enough to help you sort out the Perl version. Guess we'll have to wait on a Perl expert for that advice. Sorry I couldn't help.
  • skuff
  • Novice
  • Novice
  • User avatar
  • Posts: 28
  • Loc: Merseyside, UK

Post 3+ Months Ago

I'm getting the impression that the hosts I have chosen are a bit crap, like I mentioned before I'm new to scripts so when I registered with them I assumed that the package I chose would allow me to be receive forms through my site (it's one step up from their basic pack) but obviously it's gonna be harder than I first thought. Thanks for trying to help anyway :)
  • dreamer7
  • Student
  • Student
  • dreamer7
  • Posts: 95
  • Loc: UK

Post 3+ Months Ago

Yea your package doesn't seem that good at £49.99 a year but then again if its reliable then its ok i suppose. From what i can see from the code there has to be a page to go with it because i get the feeling that there has to be a input type with the name="email" in it with a value of an email so that the script can send to that address if you get that? $domain and $server are your domain and server i think. I think the only thing you have to do is make a html page with this in it:
Code: [ Select ]
<html>
<head>
</head>
<body>
<form action="cgi-bin/yourscript" method="post">
<input type="hidden" value="youremail@...com" name="email">
</form>
</body>
</html>
  1. <html>
  2. <head>
  3. </head>
  4. <body>
  5. <form action="cgi-bin/yourscript" method="post">
  6. <input type="hidden" value="youremail@...com" name="email">
  7. </form>
  8. </body>
  9. </html>

that will only tell the script what email address the email is going to go to. If you want the user to input something into a text box you will have to add more to the script and i have a tutorial somewhere on here that tells you what to do but i get the feeling it don't get used much lol..
http://www.ozzu.com/viewtopic.php?t=934

hope that helps
Dreamer7
  • skuff
  • Novice
  • Novice
  • User avatar
  • Posts: 28
  • Loc: Merseyside, UK

Post 3+ Months Ago

Yeah the help section on the hosts website mentions the html bit

Code: [ Select ]
<form action="cgi-bin/jmail.pl" method="post" name="mailform">
      <input name="email" type="text" size="40">
      <input name="email_submit" type="submit" value="send mail">
     </form>
  1. <form action="cgi-bin/jmail.pl" method="post" name="mailform">
  2.       <input name="email" type="text" size="40">
  3.       <input name="email_submit" type="submit" value="send mail">
  4.      </form>



I just assumed that I had to add my email address somewhere in the jmail.pl file. I don't know if it helps any but the url for the site I'm building is http://tradewagon.co.uk . It might give you a better idea what I'm trying to achieve or it might just make you laugh, either way thanks for the help.
  • dreamer7
  • Student
  • Student
  • dreamer7
  • Posts: 95
  • Loc: UK

Post 3+ Months Ago

Perhaps on the actual jmail.pl file you should change the value of $recipient from $form->param('email'); to "your@yourdomain.com"; that would stop it from taking the email address from the page so you wouldn't need the text input to enter the address into to.
dj
  • skuff
  • Novice
  • Novice
  • User avatar
  • Posts: 28
  • Loc: Merseyside, UK

Post 3+ Months Ago

right so I modify this part of jmail.pl

Code: [ Select ]

use OLE;
use CGI;
$jmail = CreateObject OLE "JMail.SMTPMail";

print "Content-type: text/html\n\n";

$form = new CGI;
$Recipient=$form->param('email@tradewagon.co.uk');
  1. use OLE;
  2. use CGI;
  3. $jmail = CreateObject OLE "JMail.SMTPMail";
  4. print "Content-type: text/html\n\n";
  5. $form = new CGI;
  6. $Recipient=$form->param('email@tradewagon.co.uk');


(am I supposed to put #!/usr/local/bin/perl at the top?)

Then I upload the jmail.pl, make sure my form(s) have

Code: [ Select ]
form action="cgi-bin/jmail.pl"


included and it should work?
  • dreamer7
  • Student
  • Student
  • dreamer7
  • Posts: 95
  • Loc: UK

Post 3+ Months Ago

No you have to take out $form->param(... because it tries to find an input on the form with the name in the brackets and there isnt one.... so change it so that it is...
Code: [ Select ]
$recipient = "email@tradewagon.co.uk";

and #!usr/local/bin/perl or #!usr/bin/perl MUST be at the top of your perl script otherwise it won't work and the rest of it should be fine so when you run it you will get the email back to your address.. fingers crossed.
dj
  • skuff
  • Novice
  • Novice
  • User avatar
  • Posts: 28
  • Loc: Merseyside, UK

Post 3+ Months Ago

I've tried uploading jmail.pl and instead of messing around with my own site I just used the example form that was on the hosts help page

Code: [ Select ]
<form action="cgi-bin/jmail.pl" method="post" name="mailform">
      <input name="email" type="text" size="40">
      <input name="email_submit" type="submit" value="send mail">
     </form>
  1. <form action="cgi-bin/jmail.pl" method="post" name="mailform">
  2.       <input name="email" type="text" size="40">
  3.       <input name="email_submit" type="submit" value="send mail">
  4.      </form>



and uploaded that but it doesn't seem to work, I've had a look on the help page at the hosts site again and it mentions that all mails must have either a valid "from" or "to" address which is a domain hosted with them and that they redirect all web based mail to an SMTP Filter System. So I don't know if that's got anything to do with why it's not working.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Perhaps adding this might help right before $Recipient:

Code: [ Select ]
$mailprog = '/usr/lib/sendmail -f email@tradewagon.co.uk -t';


I'm not sure -- but that's the filter I had to add to mine for one client when the host upgraded their spam filtering software.

Like I said earlier -- I'm not well-versed at Perl, but remembered that I had to add that to get it to bypass the hosts spam filters.
  • dreamer7
  • Student
  • Student
  • dreamer7
  • Posts: 95
  • Loc: UK

Post 3+ Months Ago

Erm out of interest yea why is it you can't use my script? because its a lot easier to use. What is the address of your host?
dj
  • skuff
  • Novice
  • Novice
  • User avatar
  • Posts: 28
  • Loc: Merseyside, UK

Post 3+ Months Ago

I still can't get it working, but no doubt I've done something wrong. There's no reason I couldn't use your script Dreamer7, in fact I just tried it but I couldn't get that to work either. Anyway I'm gonna give up trying for tonight cos it's stopped being fun now, I appreciate your help Dreamer7 and ATNO/TW thanks.

Oh yeah the hosts are fasthosts.co.uk but I think I might change them after all this and go with a host that lets me use ASP so I can use a shopping cart instead of daft forms.

Cheers :)
  • skuff
  • Novice
  • Novice
  • User avatar
  • Posts: 28
  • Loc: Merseyside, UK

Post 3+ Months Ago

After messing around for a few days trying to get my forms to work with little success and the fact that the hosting package I've purchased isn't too hot I think I am going to go back to the drawing board with my site. What I wanted to do was build a site I could link straight to my Ebay pages and save myself a fortune on listing fees etc, initially I thought using forms to submit orders would work but now I'm thinking a shopping cart would be a far better idea (I've seen a free ASP one called Charron or something similar) but as I mentioned earlier in the thread I can't use ASP with the package I have purchased so I am just about to cancel my account with my hosts (fasthosts.co.uk) as they have a 30 day trial period. Before I do though I just thought I'd see if anyone has any suggestions as to which would be a suitable host for my needs. Currently I am paying £49.99 plus £8.75 VAT so any reliable host that is cheaper would be fine.
Thanks
:)
  • dreamer7
  • Student
  • Student
  • dreamer7
  • Posts: 95
  • Loc: UK

Post 3+ Months Ago

Lol don't go to prowebhost whatever you do they have some like major reliability issues with their mySQl databases basically i cant use them lol i think its best to go with big companies because then at least they are reliable and have decent support behind them and (hopefully) they dont get hacked.
dj
  • Mercury175
  • Novice
  • Novice
  • User avatar
  • Posts: 15
  • Loc: UK

Post 3+ Months Ago

Hi people.
I came here in search of help developing my perl but it seems I may be able to give you a hand.

I also have a cheapo fasthost account who do not offer ASP support, nor sendmail, or blat or pretty much anything other than jmail to send emails online. Tried to get me to splash extra cash but decided to turn to perl.

I miss unix so bad but had to change for various reasons. Apparently win2003 is completely happy with perl..... Wasn't fun, making it up as I went along, well actually, you know it was really... :wink:

I'll give you what I have so far, its fairly straightforward. Major issue was getting all fields from the form to appear in the email, a jmail weakness. Its more for just sending online email. But you can abuse it!

Only problem with my script is that I can't get jmail to insert line breaks between the field information so doesn't make a pretty email. I'll get there. It's something about a weird combination of windows, perl and jmail. Can't find any help anywhere! People just seem to think I'm a bit sick really, for not using asp. Thing is, that's not an option right now, and not paying for something I can get for free!

Any questions, let me know.

Code: [ Select ]
use OLE;
    use CGI;
    $jmail = CreateObject OLE "JMail.SMTPMail";
print "location: http://www.mysuccesspage.htm\n\n";
print "Content-type: text/html\n\n";
$form = new CGI;
    $Recipient=$form->param('recipient');
    $domain = $ENV {'SERVER_NAME'};
    $referer = $ENV {'HTTP_REFERER'};
    $url = $referer;
    $url =~ s/^http:\/\///i;
    $url =~ s/^www\.//i;
    $domain =~ s/^www\.//i;
    $Sender =$form->param('email');
    $SMTPServer = "smtp.$domain:25";
    $Subject =$form->param('subject');
    $Body = "Name: ";
    $name = $form->param('name');
    $Tadd = "Address: ";
    $add = $form->param('address');
    $Tadd2 = "     ";
    $add2 = $form->param('address2');
    $Ttown = "Town: ";
    $town = $form->param('town');
    $Tcounty = "County: ";
    $county = $form->param('county');
    $Tpost = "Post Code: ";
    $post = $form->param('postcode');
    $Tphone = "Phone: ";
    $phone = $form->param('phone');
    $Temail = "Email: ";
    $email = $form->param('email');
    $Tsubject = "Subject: ";
    $subject = $form->param('subject');
    $Tmess = "Message: ";
    $mess = $form->param('message');
    $Priority=3;
    $Header = "Originating-IP", $ENV{'REMOTE_ADDR'};
    $jmail->{ServerAddress} = $SMTPServer;
    $jmail->{Sender} = $Sender;
    $jmail->{Subject} = $Subject;
    $jmail->AddRecipient ($Recipient);
    $jmail->{Body} = $Body;
    $jmail->appendText ($name & vbCrLf);
    $jmail->appendText & vbCrLf;
    $jmail->appendText ($Tadd);
    $jmail->appendText ($add);
    $jmail->appendText & vbCrLf;
    $jmail->appendText ($Tadd2);
    $jmail->appendText ($add2);
    $jmail->appendText & vbCrLf;
    $jmail->appendText ($Ttown);
    $jmail->appendText ($town);
    $jmail->appendText & vbCrLf;
    $jmail->appendText ($Tcounty);
    $jmail->appendText ($county);
    $jmail->appendText & vbCrLf;
    $jmail->appendText ($Tpost);
    $jmail->appendText ($post);
    $jmail->appendText & vbCrLf;
    $jmail->appendText & vbCrLf;
    $jmail->appendText ($Tphone);
    $jmail->appendText ($phone);
    $jmail->appendText & vbCrLf;
    $jmail->appendText ($Temail);
    $jmail->appendText ($email);
    $jmail->appendText & vbCrLf;
    $jmail->appendText & vbCrLf;
    $jmail->appendText ($Tsubject);
    $jmail->appendText ($subject);
    $jmail->appendText & vbCrLf;
    $jmail->appendText ($Tmess);
    $jmail->appendText & vbCrLf;
    $jmail->appendText & vbCrLf;
    $jmail->appendText ($mess);
    $jmail->{Priority} = $Priority;
    $jmail->AddHeader ($Header);
if ($url =~ m/^$domain/)
    {
        $mailmessage = "mail sent";
        $jmail->Execute;
        
    }
    else
    {
        $mailmessage = "mail was not sent. Incorrect Referer";
    }

   
  1. use OLE;
  2.     use CGI;
  3.     $jmail = CreateObject OLE "JMail.SMTPMail";
  4. print "location: http://www.mysuccesspage.htm\n\n";
  5. print "Content-type: text/html\n\n";
  6. $form = new CGI;
  7.     $Recipient=$form->param('recipient');
  8.     $domain = $ENV {'SERVER_NAME'};
  9.     $referer = $ENV {'HTTP_REFERER'};
  10.     $url = $referer;
  11.     $url =~ s/^http:\/\///i;
  12.     $url =~ s/^www\.//i;
  13.     $domain =~ s/^www\.//i;
  14.     $Sender =$form->param('email');
  15.     $SMTPServer = "smtp.$domain:25";
  16.     $Subject =$form->param('subject');
  17.     $Body = "Name: ";
  18.     $name = $form->param('name');
  19.     $Tadd = "Address: ";
  20.     $add = $form->param('address');
  21.     $Tadd2 = "     ";
  22.     $add2 = $form->param('address2');
  23.     $Ttown = "Town: ";
  24.     $town = $form->param('town');
  25.     $Tcounty = "County: ";
  26.     $county = $form->param('county');
  27.     $Tpost = "Post Code: ";
  28.     $post = $form->param('postcode');
  29.     $Tphone = "Phone: ";
  30.     $phone = $form->param('phone');
  31.     $Temail = "Email: ";
  32.     $email = $form->param('email');
  33.     $Tsubject = "Subject: ";
  34.     $subject = $form->param('subject');
  35.     $Tmess = "Message: ";
  36.     $mess = $form->param('message');
  37.     $Priority=3;
  38.     $Header = "Originating-IP", $ENV{'REMOTE_ADDR'};
  39.     $jmail->{ServerAddress} = $SMTPServer;
  40.     $jmail->{Sender} = $Sender;
  41.     $jmail->{Subject} = $Subject;
  42.     $jmail->AddRecipient ($Recipient);
  43.     $jmail->{Body} = $Body;
  44.     $jmail->appendText ($name & vbCrLf);
  45.     $jmail->appendText & vbCrLf;
  46.     $jmail->appendText ($Tadd);
  47.     $jmail->appendText ($add);
  48.     $jmail->appendText & vbCrLf;
  49.     $jmail->appendText ($Tadd2);
  50.     $jmail->appendText ($add2);
  51.     $jmail->appendText & vbCrLf;
  52.     $jmail->appendText ($Ttown);
  53.     $jmail->appendText ($town);
  54.     $jmail->appendText & vbCrLf;
  55.     $jmail->appendText ($Tcounty);
  56.     $jmail->appendText ($county);
  57.     $jmail->appendText & vbCrLf;
  58.     $jmail->appendText ($Tpost);
  59.     $jmail->appendText ($post);
  60.     $jmail->appendText & vbCrLf;
  61.     $jmail->appendText & vbCrLf;
  62.     $jmail->appendText ($Tphone);
  63.     $jmail->appendText ($phone);
  64.     $jmail->appendText & vbCrLf;
  65.     $jmail->appendText ($Temail);
  66.     $jmail->appendText ($email);
  67.     $jmail->appendText & vbCrLf;
  68.     $jmail->appendText & vbCrLf;
  69.     $jmail->appendText ($Tsubject);
  70.     $jmail->appendText ($subject);
  71.     $jmail->appendText & vbCrLf;
  72.     $jmail->appendText ($Tmess);
  73.     $jmail->appendText & vbCrLf;
  74.     $jmail->appendText & vbCrLf;
  75.     $jmail->appendText ($mess);
  76.     $jmail->{Priority} = $Priority;
  77.     $jmail->AddHeader ($Header);
  78. if ($url =~ m/^$domain/)
  79.     {
  80.         $mailmessage = "mail sent";
  81.         $jmail->Execute;
  82.         
  83.     }
  84.     else
  85.     {
  86.         $mailmessage = "mail was not sent. Incorrect Referer";
  87.     }
  88.    
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

Mercury175 - came across your name in this post, and it looks like you
would be very valuble to ozzu if you were to stick around. I hope you do. :)

Please introduce and post a little about yourself here --
http://www.ozzu.com/viewtopic.php?t=4&start=390
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Here's an example from one of my Jmail forms. Mine is written for ASP, but the cariage return should be the same. The only difference between your carriage return and mine is the underscore at the end. Try adding the underscore to yours as in this working example:

Code: [ Select ]
' The body property is bodth read and write.
' If you want to append text to the body you can
' use JMail.Body = JMail.Body & "Hello world!"
' or you can use JMail.AppendText "Hello World!"
' which in many cases is easier to use.
JMail.Body ="Name = " & request.form ("name") & vbCrLf&_
"Owner First Name = " & request.form ("OwnerFirstName") & vbCrLf&_
 "Owner Middle Initial = " & request.form ("OwnerMiddleInitial") & vbCrLf&_
     "Owner Last Name = " & request.form ("OwnerLastName") & vbCrLf&_
     "Address = " & request.form ("Address") & vbCrLf&_
         "City = " & request.form ("City") & vbCrLf&_
         "State = " & request.form ("State") & vbCrLf&_
             "Zip = " & request.form ("Zip") & vbCrLf&_
             "Phone = " & request.form ("Phone") & vbCrLf&_
                 "Best time to reach = " & request.form ("TimetoReach") & vbCrLf&_
                 "Email Address = " & request.form ("email") & vbCrLf&_
                 "Directions = " & request.form ("Directions") & vbCrLf&_
                 "Bedrooms = " & request.form ("Bedrooms") & vbCrLf&_
                 "Baths = " & request.form ("Baths") & vbCrLf&_
                 "Repairs = " & request.form ("Repairs") & vbCrLf&_
                 "Price = " & request.form ("Price") & vbCrLf&_
                 "Taxes = " & request.form ("Taxes") & vbCrLf&_
                 "Payment = " & request.form ("Payment") & vbCrLf&_
                 "Mortgage Balance = " & request.form ("MortgageBalance") & vbCrLf&_
                 "Option to buy = " & request.form ("OptiontoBuy")
  1. ' The body property is bodth read and write.
  2. ' If you want to append text to the body you can
  3. ' use JMail.Body = JMail.Body & "Hello world!"
  4. ' or you can use JMail.AppendText "Hello World!"
  5. ' which in many cases is easier to use.
  6. JMail.Body ="Name = " & request.form ("name") & vbCrLf&_
  7. "Owner First Name = " & request.form ("OwnerFirstName") & vbCrLf&_
  8.  "Owner Middle Initial = " & request.form ("OwnerMiddleInitial") & vbCrLf&_
  9.      "Owner Last Name = " & request.form ("OwnerLastName") & vbCrLf&_
  10.      "Address = " & request.form ("Address") & vbCrLf&_
  11.          "City = " & request.form ("City") & vbCrLf&_
  12.          "State = " & request.form ("State") & vbCrLf&_
  13.              "Zip = " & request.form ("Zip") & vbCrLf&_
  14.              "Phone = " & request.form ("Phone") & vbCrLf&_
  15.                  "Best time to reach = " & request.form ("TimetoReach") & vbCrLf&_
  16.                  "Email Address = " & request.form ("email") & vbCrLf&_
  17.                  "Directions = " & request.form ("Directions") & vbCrLf&_
  18.                  "Bedrooms = " & request.form ("Bedrooms") & vbCrLf&_
  19.                  "Baths = " & request.form ("Baths") & vbCrLf&_
  20.                  "Repairs = " & request.form ("Repairs") & vbCrLf&_
  21.                  "Price = " & request.form ("Price") & vbCrLf&_
  22.                  "Taxes = " & request.form ("Taxes") & vbCrLf&_
  23.                  "Payment = " & request.form ("Payment") & vbCrLf&_
  24.                  "Mortgage Balance = " & request.form ("MortgageBalance") & vbCrLf&_
  25.                  "Option to buy = " & request.form ("OptiontoBuy")
  • Mercury175
  • Novice
  • Novice
  • User avatar
  • Posts: 15
  • Loc: UK

Post 3+ Months Ago

It just doesn't want to know about it. It may be something to do with window's perl interpreter, or the version that my server is running. The script just fails to return a good set of headers, or simply prints the code when I try to use '& vbCrLf&_ ' in any logical combination.

Again, asp isn't an option for me, something as trivial as a line break must be possible with perl.
I'll keep working on it, seems as though no one else in the world has attempted to use a form with jmail via a perl script. If YOU have, I'd like to hear from you.

Merc.
  • fional24
  • Graduate
  • Graduate
  • fional24
  • Posts: 125
  • Loc: Scotland

Post 3+ Months Ago

I'm having the same fasthosts blues with this jmail thing. Switching to xcalibre when my year runs out, they install form scripts for you even though it's not meant to be part of the package!

My jmail seems to process, send me to the thank-you page etc.. but no mail turns up.

I've changed the line which reads
$Recipient = "me@domain.com";

This was previously

$Recipient = "form\@$SMTPServer";

But I read a recommendation by Dreamer7 to change it.

Anyone have any ideas which bit of the code is messing this up?
------------------------
Code: [ Select ]
Jmail:

use OLE;
use CGI;
$jmail = CreateObject OLE "JMail.SMTPMail";
print "Content-type: text/html\n\n";
$form = new CGI;

$domain = $ENV {'SERVER_NAME'};
$referer = $ENV {'HTTP_REFERER'};
$url = $referer;
$url =~ s/^http:\/\///i;
$url =~ s/^www\.//i;
$domain =~ s/^www\.//i;

$Sender = $form->param('email');

$SMTPServer = "smtp.$domain:25";
#$Recipient = "form\@$SMTPServer";
$Recipient = "me@domain.com";
$Subject = "Sales Enquiry";
$Priority=1;
$Header = "Originating-IP", $ENV{'REMOTE_ADDR'};

$jmail->{ServerAddress} = $SMTPServer;
$jmail->{Sender} = $Sender;
$jmail->{Subject} = $Subject;
$jmail->AddRecipient ($Recipient);


$mail_body = '';

foreach $field ($form->param) {
foreach $value ($form->param($field)) {
$mail_body .= "$field: $value\n";
}
}

$jmail->{Body} = $mail_body;
$jmail->{Priority} = $Priority;
$jmail->AddHeader ($Header);

if ($url =~ m/^$domain/)
{
$mailmessage = "Mail was sent.";
$jmail->Execute;
}
else
{
$mailmessage = "mail not sent. Incorrect Referer";
}

print "Content-type: text\n\n";
print "Result: $mailmessage\n\n";
#print "Recipient: $Recipient\n\t\n";
#print "Sender: $Sender SMTP Server: $SMTPServer\t";
#print "Subject: $Subject Referer: $referer";
#print "Domain: $domain url: $url ";


print <<"(END ERROR HTML)";

Content-type: text/html

<html>
<head>
<title>Enquiry</title>
<META HTTP-EQUIV="Refresh" CONTENT="0; URL=../thanks.html">
</head>
<body>

</body>
</html>
(END ERROR HTML)
  1. Jmail:
  2. use OLE;
  3. use CGI;
  4. $jmail = CreateObject OLE "JMail.SMTPMail";
  5. print "Content-type: text/html\n\n";
  6. $form = new CGI;
  7. $domain = $ENV {'SERVER_NAME'};
  8. $referer = $ENV {'HTTP_REFERER'};
  9. $url = $referer;
  10. $url =~ s/^http:\/\///i;
  11. $url =~ s/^www\.//i;
  12. $domain =~ s/^www\.//i;
  13. $Sender = $form->param('email');
  14. $SMTPServer = "smtp.$domain:25";
  15. #$Recipient = "form\@$SMTPServer";
  16. $Recipient = "me@domain.com";
  17. $Subject = "Sales Enquiry";
  18. $Priority=1;
  19. $Header = "Originating-IP", $ENV{'REMOTE_ADDR'};
  20. $jmail->{ServerAddress} = $SMTPServer;
  21. $jmail->{Sender} = $Sender;
  22. $jmail->{Subject} = $Subject;
  23. $jmail->AddRecipient ($Recipient);
  24. $mail_body = '';
  25. foreach $field ($form->param) {
  26. foreach $value ($form->param($field)) {
  27. $mail_body .= "$field: $value\n";
  28. }
  29. }
  30. $jmail->{Body} = $mail_body;
  31. $jmail->{Priority} = $Priority;
  32. $jmail->AddHeader ($Header);
  33. if ($url =~ m/^$domain/)
  34. {
  35. $mailmessage = "Mail was sent.";
  36. $jmail->Execute;
  37. }
  38. else
  39. {
  40. $mailmessage = "mail not sent. Incorrect Referer";
  41. }
  42. print "Content-type: text\n\n";
  43. print "Result: $mailmessage\n\n";
  44. #print "Recipient: $Recipient\n\t\n";
  45. #print "Sender: $Sender SMTP Server: $SMTPServer\t";
  46. #print "Subject: $Subject Referer: $referer";
  47. #print "Domain: $domain url: $url ";
  48. print <<"(END ERROR HTML)";
  49. Content-type: text/html
  50. <html>
  51. <head>
  52. <title>Enquiry</title>
  53. <META HTTP-EQUIV="Refresh" CONTENT="0; URL=../thanks.html">
  54. </head>
  55. <body>
  56. </body>
  57. </html>
  58. (END ERROR HTML)



-----------------------

Using this with a very basic form to get this working
HTML:

Code: [ Select ]
<form action="cgi-bin/jmail.pl" method="post" name="mailform">
      <input name="email" type="text" size="40">
      <input name="email_submit" type="submit" value="send mail">
     </form>
  1. <form action="cgi-bin/jmail.pl" method="post" name="mailform">
  2.       <input name="email" type="text" size="40">
  3.       <input name="email_submit" type="submit" value="send mail">
  4.      </form>
  • fional24
  • Graduate
  • Graduate
  • fional24
  • Posts: 125
  • Loc: Scotland

Post 3+ Months Ago

or alternatively, i could just change my $Recipient back to the way it was and add a hidden recipient field into my html. Then sit back and enjoy feedbackfest.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

fional24

I had that problem at several of my client's web sites. The problem occured when my webhost decided to put spam filtering in place on their servers. I had to add a switch to the referer or recipient (I can't remember which now) so it would pass the mail through.

You may want to check with your host and see if this is what may be happening.
  • fional24
  • Graduate
  • Graduate
  • fional24
  • Posts: 125
  • Loc: Scotland

Post 3+ Months Ago

Yeh, they only allow certain scripts to be used because of spam. Fair enough, but they could at least offer support on the script, or give a working example to learn from!
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

I hear ya. As an aside for future reference, when you post code, please use the BBcode "code" buttons in the postform. That way the code displays correctly. Normally a mod would have fixed that for you, but apparently none of the ones that moderate this forum caught that yet. Just an FYI for future reference.
  • Mercury175
  • Novice
  • Novice
  • User avatar
  • Posts: 15
  • Loc: UK

Post 3+ Months Ago

fional24

Most hosts, including fasthosts, will only process the mail if either the 'from' or 'to' address is on a domain which is registered on their servers. You can easily set up a new address via your fasthosts control panel and use mail forwarding from your domain to your current address.

Depending on the nature of your form its probably best to enter your new redirected email address as your recipient.
You may be better off just making a reference to a hidden field on your form which contains the address you want to send the mail to. Just type the address in the field as is, no need for any special characters.

Then in your script place,

$Recipient=$form->param('recipient');

Where recipient is the name of your hidden field.
Try placing this line at the top of the list of parameters, above the request for the server name, below $form = new CGI;

Hope this may have been some help.

Merc.
  • fional24
  • Graduate
  • Graduate
  • fional24
  • Posts: 125
  • Loc: Scotland

Post 3+ Months Ago

yep, that works perfectly!

tnx
  • fsuk
  • Newbie
  • Newbie
  • fsuk
  • Posts: 8
  • Loc: Scotland UK

Post 3+ Months Ago

Hey everyone I too am having these exact problems with my fasthost account! (which I now wish I hadn't ever signed up too!) I will be following all the advice on this forum and see if I get any luck with getting my form to work!
  • Electricmoon
  • Born
  • Born
  • Electricmoon
  • Posts: 1

Post 3+ Months Ago

Thanx to ATNO/TW

My hosting service is Fasthosts, I've never been able to receive any submitted form emails. That is until NOW.

Thanx to ATNO/TW's guides, the ASP option works a treat for me!

Cheers, Electricmoon
  • LittleJon
  • Born
  • Born
  • LittleJon
  • Posts: 1

Post 3+ Months Ago

In perl to add carriage returns to your message body fields, I use \n at the end of each string.

$Body = "Name : $Str1\n Phone : $Str2\n Email : $Str3\n Enquiry : $Str6\n Dates : $Str7\n Rooms : $Str8\n Marketing : $Str9\n Please contact this person";
$jmail->{Body} = $Body;
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

Post Information

  • Total Posts in this topic: 30 posts
  • Users browsing this forum: No registered users and 66 guests
  • 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 post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.