Results 1 to 4 of 4
  1. #1

    Default Help with configuring sendmail "from" field--automatically adds my domain name?

    I'm writing a Perl script to automatically send an e-mail to people under certain circumstances. I've only just started, so right now I just have a very basic script which is supposed to send a test e-mail to my other e-mail address whenever I run it. But the problem I'm having is that it won't put the correct name in the "From" field. For instance, the line

    Code:
    print SENDMAIL "From: Tom Jones\n";
    causes the e-mail I receive to say "Tom.Jones@heroofcamelot.com" as the sender's name when I receive the e-mail. Just so this is clear, when I say the "from name" I'm talking about the name it's supposed to say the person came from when you get the e-mail. I'm not talking about the reply-to address, that works fine. But just displaying the person's name. Like usually when you open your Inbox, it shows the name of the person each e-mail came from, and not their e-mail address.

    This is the code I have so far:

    Code:
    #!/usr/bin/perl
    
    my $sendmail = '/usr/lib/sendmail -t';
    
    my $reply_to = "Reply-to: foo\@yahoo.com\n";
    my $subject = "Subject: Test E-mail\n";
    my $send_to = "To: foo\@yahoo.com\n";
    my $from = "From: Tom Jones\n";
    my $content = 'Test';
    
    open(SENDMAIL, "|$sendmail") or die "Cannot open sendmail!";
    print SENDMAIL $reply_to;
    print SENDMAIL $from;
    print SENDMAIL $send_to;
    print SENDMAIL $subject;
    print SENDMAIL "Content-type:text/plain\n\n";
    print SENDMAIL $content;
    close(SENDMAIL);
    (The names and e-mail addresses above are changed because I don't want spam bots to get the real addresses.) This code causes the e-mail to say it's from Tom.Jones@heroofcamelot.com when it's sent, but I want the name to just say Tom Jones. How do I get that to work?

    Not sure if this makes any difference, but I'm on WH 3.0
    Last edited by heroofcamelot; 12-21-2013 at 08:18 AM.

  2. #2
    Moderator wildjokerdesign's Avatar
    Join Date
    Jun 2003
    Location
    Kansas City Mo
    Posts
    5,721

    Default

    Try this:
    Code:
    my $from = "From: Tom Jones <tom\@example.com>\n";
    Shawn
    Please remember your charity of choice: http://www.redcross.org

    Handy Links: wildjokerdesign.net | Plain Text Editors: EditPlus | Crimson

  3. #3
    Moderator wildjokerdesign's Avatar
    Join Date
    Jun 2003
    Location
    Kansas City Mo
    Posts
    5,721

    Default

    P.S. I got rid of the double posting for you. To keep from having the log out issue while composing a post you can choose to have the forum remember you when you log in. Of course that also means that from the computer you do that on, anyone who accesses the forum would be logged in as you because it sets a cookie. If you are not on a secure computer of your own you can simply manually log out when you are done and then the next time you would log back in and choose the option again.
    Shawn
    Please remember your charity of choice: http://www.redcross.org

    Handy Links: wildjokerdesign.net | Plain Text Editors: EditPlus | Crimson

  4. #4

    Default

    Thanks. That worked. Thanks also for getting rid of the other thread.

Tags for this Thread

Posting Permissions

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