Forum Moderators: coopster & phranque

Message Too Old, No Replies

Sending authenticated email from Perl

         

csdude55

8:01 pm on Dec 16, 2023 (gmt 0)

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



I mentioned this earlier in the Webmaster General forum, but now I'm having a different issue.

The email in the "To" field receives the email just fine, with the "From" field showing noreply@mysite.com as it should and a spam score of -1

But the "Bcc" (which is my own Gmail) isn't being delivered! When I look at WHM's Delivery Report it shows that it was sent and approved, but the "From" field shows "accountusername@my.server.com" with a spam score of +3! Which I guess is maybe why Gmail isn't accepting it?

Here's is the script. Any thoughts on why the BCC field isn't working right?

use Net::SMTP;
use MIME::Lite;
use Digest::MD5 qw(md5_hex);

$to = 'foo@gmail.com';

$from= 'noreply@mysite.com';
$login_pass = <PASSWORD>;

# I couldn't get time() to work inline, it would change the format to something
# like "14 Dec blah blah blah"
# If I set it as its own variable, it would give me the desired "6798123234"
$messageID = time();

$msg = MIME::Lite ->new (
From => "Me <$from>",
To => "$to",
Bcc => 'me@gmail.com',
Subject => 'Testing Net::SMTP',
'Message-ID'=> '<' . $messageID . '-' . md5_hex($from) . '-' . md5_hex($found_email) . '@gonc.net>',
Type=> 'multipart/alternative'
);

$msg->attach(
Type => 'text/plain',
Encoding => 'quoted-printable',
Data => qq~
The body of the email Net-SMTP example
~
);

$msg->attach(
Type => 'text/html',
Data => qq~
The <i>body</i> of the <b>email</b> Net-SMTP example
~
);

$msg->scrub(['x-mailer', 'Content-Disposition']);

$smtp = Net::SMTP->new(
'mail.mysite.com',
Port => 465,
SSL => 1
);

$smtp->auth($from, $login_pass) or die('Could not authenticate');

$smtp->mail($from);
if ($smtp->to($to)) {
$smtp->data();
$smtp->datasend( $msg->as_string() );
$smtp->dataend();
}

else {
print "Error: ", $smtp->message();
}

$smtp->quit;

print "Done";
exit;

phranque

7:12 am on Dec 23, 2023 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



your script is obviously using the same Mime and SMTP objects to send the email, so it is unlikely your problem solution lies in the script.

i would suspect your smtp server is modifying headers before sending those bcc: emails.