http://www.perlmonks.org?node_id=827711

Appy16 has asked for the wisdom of the Perl Monks concerning the following question:

Hi.. I'm trying to send an email using the Script I've posted below. The script downloads a particular file and mails it as an attachment but has just one problem. The problem is that the email i am sending is sent into Spam or the Junk folder. How can i authenticate the mail using this script.
#!/usr/bin/perl use LWP::Simple; use MIME::Lite; use Spreadsheet::WriteExcel; $from = 'abc\@gmail.com'; $to = 'def\@gmail.com'; $Subject = 'Daily Social Media search'; my $url = "abc.org/?xyz=csv"; my $file = "/Users/abc/Desktop/abc.csv"; my $status = mirror($url,$file); die "Cannot retrieve $url" unless is_success($status); # Part using which the file being downloaded is sent as an attachment +to an email # $msg = MIME::Lite->new( From => $from, To => $to, Subject => $Subject, Type => 'multipart/Mixed', ); $msg->attach( Type => 'Text', Data => "The attachment contains the csv file downloaded t +oday." ); $msg->attach( Type => 'Application/Text', Path => "/Users/abc/Desktop/abc.csv" ); print "Mail Sent\n"; $msg->send; # send via default

Replies are listed 'Best First'.
Re: Authenticating the Mail Sent
by scorpio17 (Canon) on Mar 10, 2010 at 16:51 UTC

    I've had the same problem. There's not much you can do about it, because it depends on how gmail is doing its filtering - which you have no control over.

    If you're sending email out from an ISP that is on some kind of email black list, you could try switching ISP's. You can try adding extra stuff to your email header, in order to make your message look "less spammy" - but I tried that unsuccessfully. Note that my emails went to other web-based email services fine - it was just gmail that gave me fits.

    As an email recipient, you need to check the email and mark it as "not spam" - once that is done, it won't be trashed anymore. Just make sure you alert users (email recipients to be) that they may need to look in their spam folders for that first email...

      He is sending email from non-gmail servers to gmail account pretending to be from a gmail account -- this could be considered an attempted hacking attempt .
      thanx for your suggestion
Re: Authenticating the Mail Sent
by Anonymous Monk on Mar 10, 2010 at 07:34 UTC
    The problem is that the email i am sending is sent into Spam or the Junk folder. How can i authenticate the mail using this script.

    What does that mean?

      What i'm trying to say is that the mails generated using the program go to the Spam folder and not the Inbox. I want to authenticate the email address so that the mail is sent directly to the inbox and not to the Spam Folder.

        It's hard to tell without knowing what the receiver of the mail accepts as an "authenticated" mail/address...

        (If there was a generally applicable method, every spammer would probably be interested in hearing of it :)

        Update:

        P.S.: if you're talking about a Gmail-internal solution, it's always good to mention it right from the start. Using two @gmail.com addresses in the sample code does not necessarily imply it — email is more than gmail...