SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2007
    Location
    Ryde, Isle of Wight, UK
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    FormMail.pl question

    I'm using the following formMail perl script, but can't seem to sort out why I keep getting any e-mail sent to me as Nobody, it just will not allow me to see who has sent me a response unless I open every single email, also I'm unable to reply to an enquiry directly from the reply.

    Code Perl:
    BEGIN
    {
      $DEBUGGING         = 1;
      $emulate_matts_code= 0;
      $secure            = 1;
      $allow_empty_ref   = 1;
      $max_recipients    = 5;
      $mailprog          = '/usr/sbin/sendmail -t -i';
      $postmaster        = '';
      @referers          = qw([url]www.seaviewstudioworkshop.co.uk);[/url]
      @allow_mail_to     = qw(info@seaviewstudioworkshop.co.uk);
      @recipients        = ();
      %recipient_alias   = ();
      @valid_ENV         = qw(REMOTE_HOST REMOTE_ADDR REMOTE_USER HTTP_USER_AGENT);
      $locale            = '';
      $charset           = 'iso-8859-1';
      $date_fmt          = '%A, %B %d, %Y at %H:%M:%S';
      $style             = '/css/nms.css';
      $no_content        = 0;
      $double_spacing    = 1;
      $wrap_text         = 0;
      $wrap_style        = 1;
      $address_style     = 0;
      $send_confirmation_mail = 0;
      $confirmation_text = <<'END_OF_CONFIRMATION';
    From: [email]info@seaviewstudioworkshop.co.uk[/email]
    Subject: form submission
     
    Thank you for your form submission.

  2. #2
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's not a complete Perl script, just a portion of its configuration, so I can't say anything about how to fix it, but the reason everything shows as being from "Nobody" is because that's the user that the web server (probably apache) is configured to run as. As far as the mail service is concerned, "Nobody" is the name of the person sending the message because that's the user who owns the process used to send it.

    Depending on the mail service configuration, it may or may not be possible for the script to specify an alternative "from:" address... but it's very likely that the mail service will not allow this. If you're running on shared hosting, it's practically certain to be disallowed.

    Most likely, your primary option will be to put the user's name/email address/whatever into the subject line of the message if you want to be able to see who it's actually from without having to open the message.

    To get your email client's "reply" function to work properly, you can have the script insert a "reply-to:" header into the message with the user's email address.

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2007
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi bloodofeve

    The formmail.pl script you are using is now very old.
    Why it still keeps cropping up for Perl newbies, no-one knows, (except many web service providers
    still keep churning it out), so it isn't your fault you've ended up using it.

    FWIW you don't appear to have finished off the 'here' document
    at the end of the code snippet you have shown.

    In the code you have presented, the only place you set a From: field is in the 'here'
    document with the email address, info @ seaviewstudioworkshop.co.uk, in the
    body of the email message.

    As dsheroh has said, your best option is to use their email in the subject line.
    If you think about it, it is quite reasonable for an email server not to appear to send email from
    an address it doesn't manage.

    You really should also look at some more up-to-date code.

    http://learn.perl.org/examples/email_valid.html
    Code:
    #!/usr/bin/perl
    use strict;
    use warnings;
    
    use Email::Valid;
    
    my $email_address = 'a.n@example.com';
    
    unless( Email::Valid->address($email_address) ) {
        print "Sorry, that email address is not valid!";
    }
    to check you have a valid email address entered on the form.


    and
    http://learn.perl.org/examples/email.html
    Code:
    #!/usr/bin/perl
    use strict;
    use warnings;
    
    # first, create your message
    use Email::MIME;
    my $message = Email::MIME->create(
      header_str => [
        From    => 'you@example.com',
        To      => 'friend@example.com',
        Subject => 'Happy birthday!',
      ],
      body_str => 'Happy birthday to you!',
    );
    
    # send the message
    use Email::Sender::Simple qw(sendmail);
    sendmail($message);
    to send the email.

    The full documentation for the Email::MIME module used can be found at http://search.cpan.org/~rjbs/Email-M.../Email/MIME.pm

    You could also look at Mime::Lite http://search.cpan.org/~rjbs/MIME-Li...b/MIME/Lite.pm
    Code:
        $msg = MIME::Lite->new(
            From     =>'me@myhost.com',
            To       =>'you@yourhost.com',
            Cc       =>'some@other.com, some@more.com',
            Subject  =>'Hello!',
            Data     =>"How's it going?"
        );
    You should be able to install the Perl modules you need via the CPanel interface, if that is what you are using.

    Good luck with the website.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •