rjbs / email-sender Goto Github PK
View Code? Open in Web Editor NEWa perl library for sending email
a perl library for sending email
The server that handles our system email is the same server used for generating Toastmasters club websites for each of the over 10,000 clubs that use the FreeToastHost system. I do not have any control over that circumstance, and occasionally there are email delivery delays when the server is under heavy load. (Mondays are typically slower.) We average around 300,000 emails through the system in a given week.
When I was previously using Email::Send, I found that I could improve email delivery by implementing a retry loop with increasing sleep times between each retry up to a maximum number of retries. (The loop was only used for certain types of delivery failures.) Sometimes it would take longer for people to get their emails, but at least it would get delivered.
Now that I am using Email::Sender, I am wondering if I should get keep the retry loop given that the server setup is the same, or if there is a built-in retry mechanism in Email::Sender. I bring this up since I recently had a user mention that they had received two duplicates of the same email. I might expect that if there is a built-in retry mechanism in Email::Sender and the system was under heavy load. I have asked the for more information from the user, but have not yet received it.
I received a report of the following error from one of my Japanese users, that appears to originate in line 218 of SMTP.pm. Not sure how to resolve this. (To address below removed by user to prevent spam bots from getting it.):
To: my address
From: Mail Delivery Subsystem [email protected]
Date: Sun, 19 Jul 2015 13:55:28 GMT
Subject: Returned mail: see transcript for details
The original message was received at Sun, 19 Jul 2015 13:55:22 GMT
from rcpt-expgw.biglobe.ne.jp [133.208.98.3]
The following addresses had permanent fatal errors
|/etc/tcmail.pl
(reason: 255)
(expanded from: [email protected])
Transcript of session follows
Status: 500
Content-type: text/html
Can't locate object method "message" via package "Wide character in subroutine entry at /usr/local/share/perl5/Email/Sender/Transport/SMTP.pm line 218. " (perhaps you forgot to load "Wide character in subroutine entry at /usr/local/share/perl5/Email/Sender/Transport/SMTP.pm line 218. "?) at /etc/smrsh/tcmail.pl line 739.
For help, please send mail to this site's webmaster, giving this error message and the time and date of the error.
[Sun Jul 19 13:55:28 2015] tcmail.pl: Can't locate object method "message" via package "Wide character in subroutine entry at /usr/local/share/perl5/Email/Sender/Transport/SMTP.pm line 218. [Sun Jul 19 13:55:28 2015] tcmail.pl: " (perhaps you forgot to load "Wide character in subroutine entry at /usr/local/share/perl5/Email/Sender/Transport/SMTP.pm line 218. [Sun Jul 19 13:55:28 2015] tcmail.pl: "?) at /etc/smrsh/tcmail.pl line 739. 554 5.3.0 unknown mailer error 255Email::Sender::Manual::QuickStart shows using Email::Simple but that module is too low on features for a proper quick start. I think It should show using Email::Stuffer because Email::MIME recommends that as an easy to use tool.
Net::SMTP supports a username/password combination as arguments of its auth()
call, but it supports a single argument form of auth()
as well, which takes an Authen::SASL
instance which is correctly configured for authentication by the caller.
Would you accept a PR to add something similar to Email::Sender::Transport::SMTP
?
I'd like to upfront say thanks and great work for abstracting away Net::SMTP, we are moving our code-base to Email::Sender since we had problems with Net::SMTP/MIME::Lite before. We had a nasty bug on our production system after an upgrade that is already handled here [1], so after reviewing Email::Sender we were delighted that this has been taken care of.
Though we have an issue with the documentation [2] pointing out a potential leak of BCC and the note that the header is ignored. While this is certainly an issue, it is only relevant for an MTA [3]. The transport modules SMTP and Sendmail should pass the BCC header untouched, since it is the responsibility of the MTA to handle the header properly.
Net::SMTP will most likely connect to a MTA which will need to implement RFC2821 appendix B [3] (postfix does that according to the smtpd man page [4]) or RFC2822 section 3.6.3 [5] (exim does so according to its man page [6]) correctly. The only case where I see a need to touch the BCC header might be the something like the SQLite transport module.
Regardless, thanks for the work again, we really appreciate the effort poured into this project.
[1] https://github.com/rjbs/Email-Sender/blob/master/lib/Email/Sender/Transport/SMTP.pm#L261-L266
[2] https://github.com/rjbs/Email-Sender/wiki/Bcc
[3] https://tools.ietf.org/html/rfc2821#appendix-B
[4] http://www.postfix.org/smtpd.8.html
[5] https://tools.ietf.org/html/rfc2822#section-3.6.3
[6] https://linux.die.net/man/8/exim
|| 151 if ($self->_security eq 'starttls') {
|| 152 $self->_throw("can't STARTTLS: " . $smtp->message)
|| 153 unless $smtp->starttls(%{ $self->ssl_options });
|| 154 }
You forgot to include
We have a project that keeps a cache of multiple Email::Sender::Transport::SMTP objects. One of this projects methods is a health check - e.g. can the project connect to the specified server, is the username correct, and so on.
Email::Sender::Transport::SMTP->_smtp_client would be perfect for what we're doing, but it's private.
What do you think about making this member public, or publicly accessible via some other method?
In your Module Mime::Lite it is the possible to give 'FromSender' as an argument to sendmail that uses it for -f.
Email::Sender::Transport::Sendmail always uses From to set -f.
It would be nice to see this option also in this module.
Thanks and regards, Stefan
I am seeing some issues with special characters in email subjects. I am the maintenance developer for an email list server/CMS used by many Toastmasters Public Speaking clubs (FreeToastHost)... we use a lot of your email modules. (We probably owe you several lunches... lol)
I recently had a user determine that removing an "en dash" "โ" character, ALT 0150, from his email subject text was the difference between it actually sending the email and not sending it.
I have seen some similar issues with special characters in subjects...
Any insights on this?
I've checked:
http://search.cpan.org/~rjbs/Email-Sender-1.300016/lib/Email/Sender.pm
http://search.cpan.org/~rjbs/Email-Sender-1.300016/lib/Email/Sender/Simple.pm
http://search.cpan.org/~rjbs/Email-Sender-1.300016/lib/Email/Sender/Manual.pm
http://search.cpan.org/~rjbs/Email-Sender-1.300016/lib/Email/Sender/Manual/QuickStart.pm
http://search.cpan.org/~rjbs/Email-Sender-1.300016/lib/Email/Sender/Transport.pm
... and found no references to authentication at all. I've seen old blog posts mentioning authentication, but none actually detailing it. Could I please be pointed to the documentation? Sorry if I've missed something obvious.
Hello,
in our setup for automatic mailings we have 3 default headers:
Return-path: bounce@...
Reply-to: noreply@...
From: noreply@...
With Email::Sender it is not possible to set a different Return-path than the From-header.
In prepare_envelope the from is used from the from-Argument.
I think this a normal setup with is often used.
MfG
Felix Ostmann
I've been using Email::Sender::Simple 1.300012 in Catalyst projects, and it always worked without a hitch. I upgraded to 1.300016 a couple of days ago, and now it's stalling the Catalyst development server upon each start and restart. The server hangs as it's setting up components, and perl eats up my CPU. It doesn't make the server completely unresponsive though. I can resave the file I was working on and cause the server to restart, but it will hang again at the same point.
This doesn't happen every single time the server starts or restarts, but it happens probably 80% of the time. If I force enough restarts, the server will load correctly on a few occasions. It's quite random. Email::Sender::Simple is definitely the cause of the issue, as the server runs perfectly when I comment out the use line. This happens regardless of what perl version I'm using.
The documentation has this line:
ssl: if 'starttls', use STARTTLS; if 'ssl' (or 1), connect securely; if 'maybestarttls', use STARTTLS if available; otherwise, no security
But from error message I can understand that maybestarttls
is not supported.
Should we fix documentation?
my options are:
transport => '+SMTP::Persistent',
port => '587',
ssl => 'maybestarttls',
This caused me a good days lost work as I think there is a subtle change with this or Socket::SSL or Net::SSLeay or something, depending on ones perspective.
So there's no way to set that parameter (feel free to correct me), which breaks things like Amazon SES processing.
I've got around it by detect Perl versions in my code (if $[ < x then use Email::Sender::Transport::SMTP else use Email::Sender::Transport::SMTPS (deprecated now I know).
Which feels all a bit clunky. Happy to be corrected about it all!
When using the SMTP::Persistent transport, the last mail of a connection is dropped by the mail relay connected to, when the disconnect method isn't called.
As the disconnect
method only exists for the SMTP::Persistent transport, code that allows configuring the transport would have to check if the transport instance has a disconnect method, and call it if.
As that isn't nice I'd prefer if it gets called automatically when the transport instance is destroyed, end of program in my case.
If that's not safely possible on global destruction, maybe moving the reset from start of next mail to end of mail would fix the problem of dropped last mail.
When I configure Email::Sender::Transport::SMTP to use SSL I get this error:
[ERROR] 2014-02-18 10:00:11,067 Error sending email: unable to establish SMTP connection
Trace begun at C:\strawberry\perl\site\lib\Email\Sender\Transport\SMTP.pm line 144
Email::Sender::Transport::SMTP::_throw('Email::Sender::Transport::SMTP=HASH(0x3bb7220)', 'unable to establish SMTP connection') called at C:\strawberry\perl\site\lib\Email\Sender\Transport\SMTP.pm line 110
Email::Sender::Transport::SMTP::_smtp_client('Email::Sender::Transport::SMTP=HASH(0x3bb7220)') called at C:\strawberry\perl\site\lib\Email\Sender\Transport\SMTP.pm line 153
Email::Sender::Transport::SMTP::send_email('Email::Sender::Transport::SMTP=HASH(0x3bb7220)', 'Email::Abstract=ARRAY(0x4a878f8)', 'HASH(0x4a8be78)') called at C:\strawberry\perl\site\lib\Email\Sender\Role\CommonSending.pm line 47
Email::Sender::Role::CommonSending::__ANON__ at C:\strawberry\perl\site\lib\Try\Tiny.pm line 76
eval {...} at C:\strawberry\perl\site\lib\Try\Tiny.pm line 67
Try::Tiny::try('CODE(0x4a7e8f8)', 'Try::Tiny::Catch=REF(0x4a87298)') called at C:\strawberry\perl\site\lib\Email\Sender\Role\CommonSending.pm line 60
Email::Sender::Role::CommonSending::send('Email::Sender::Transport::SMTP=HASH(0x3bb7220)', 'Email::Abstract=ARRAY(0x4a878f8)', 'HASH(0x4a7ecd0)') called at C:\strawberry\perl\site\lib\Email\Sender\Simple.pm line 121
Email::Sender::Simple::send_email('Email::Sender::Simple', 'Email::Abstract=ARRAY(0x4a878f8)', 'HASH(0x4a86d08)') called at C:\strawberry\perl\site\lib\Email\Sender\Role\CommonSending.pm line 47
Email::Sender::Role::CommonSending::__ANON__ at C:\strawberry\perl\site\lib\Try\Tiny.pm line 76
eval {...} at C:\strawberry\perl\site\lib\Try\Tiny.pm line 67
Try::Tiny::try('CODE(0x3bafa88)', 'Try::Tiny::Catch=REF(0x4a5eb48)') called at C:\strawberry\perl\site\lib\Email\Sender\Role\CommonSending.pm line 60
Email::Sender::Role::CommonSending::send('Email::Sender::Simple', 'Email::MIME=HASH(0x4a8d2e0)', 'HASH(0x3bb7298)') called at C:\strawberry\perl\site\lib\Sub\Exporter\Util.pm line 18
Sub::Exporter::Util::__ANON__('Email::MIME=HASH(0x4a8d2e0)', 'HASH(0x3bb7298)') called at report_mailer line 204
main::__ANON__ at C:\strawberry\perl\site\lib\Try\Tiny.pm line 76
eval {...} at C:\strawberry\perl\site\lib\Try\Tiny.pm line 67
Try::Tiny::try('CODE(0x407adc8)', 'Try::Tiny::Catch=REF(0x2c2e7e8)', 'Try::Tiny::Finally=REF(0x2a0bcd8)') called at report_mailer line 219
(report_mailer: 206)
When I disable SSL, the connection is established correctly.
The email host is GoDaddy's smtpout.secureserver.net (http://support.godaddy.com/help/article/4714/setting-up-your-email-address-with-imap?locale=en)
I set debug to 1, but the output looks the same to me.
on the page
Have a look at Email::Sender::Manual, where all the manual's documents are listed.
Actually Email::Sender::Manual
do not have the list of all the manual's documents.
It only contain one link which refers back to current document.
Email::Sender 1.300016 stalled during the testing phase while trying to install it via cpanm using perl-5.20.1. Switching perlbrew off and using system perl allowed it to install correctly.
I made several attempts at installation. It stalled mostly at this point, line 111 of the build.log:
PERL_DL_NONLAZY=1 /home/autumn/perl5/perlbrew/perls/perl-5.20.1/bin/perl
"-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches;
test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
It went past that on a couple of occasions before stalling again, though it never completed the testing phase.
For example: if remote host accepts connection but hangs up because of bad HELO, report that, do not say "could not connect."
Hello,
We noticed that an email address with a single quote in the user part, has the user part double quoted, which services like Sendgrid reject as invalid.
Eg: o'[email protected] becomes quoted as "o'neil"@foo.com. Exim and Postfix appear to handle this okay, but Sendgrid does not - the email address is considered invalid. (I will be checking with Sendgrid to see if they think this behaviour is a bug).
The behaviour happens in _quoteaddr()
in (at least) SMTP.pm, SMTPS.pm. If a single quote is added to the /[^\w.+-]/
regex, then the double quoting of the user part is avoided, and everything is happy.
Hi, I recently upgraded my entire perl ecosystem to latest versions, and within a month ran into a new problem where something in the chain of Email::Sender::Transport::SMTP::Persistent is not performing SMTP "dot stuffing". Specifically, if one line of the DATA of an SMTP message begins with "..", the server will strip out the first character according to the SMTP protocol.
https://wordtothewise.com/2018/11/why-do-my-urls-have-two-dots/
We send millions of emails a month, but it is also extremely rare that any line of a message would begin with "..", and also unlikely that anyone would even notice, so I can't say whether this bug was caused by the version bump or if it has always been there. Someone noticed this one because a URL with a "key" in it just happened to contain ".." and it just happened to land on the line boundary when wrapped, resulting in a broken key.
Do you know offhand where in the code the dot stuffing would have been happening? Was it ever part of the module? Did it used to be handled by Net::SMTP?
Hi,
Could you tell me how to use this module to send mail with attachment? Is it possible to be used like the format of MIME::Lite (as below)? Many thanks~
my $email = Email::Simple->create(
header => [
To => '***',
# cc => '***',
From => '***',
Subject => "***",
'Content-Type' => 'multipart/Mixed', #multipart/Mixed;multipart/related
],
body => $some_info ,
);
$email->attach(
filename => "1.txt",
content_type => 'text/html',
disposition => 'attachment',
name => "123",
);
Hi! The ssl
parameter is documented as follows:
Email-Sender/lib/Email/Sender/Transport/SMTP.pm
Lines 34 to 35 in 7a7b9b8
Which seems to suggest that integer values like 1 are correct.
However it is implemented as follows:
So when supplying 0 one gets the following error:
isa check for "ssl" failed: 0 is not a string! at (eval 1989) line 245.
eval {...} called at (eval 1989) line 244
Email::Sender::Transport::SMTP::Persistent::new("Email::Sender::Transport::SMTP::Persistent", HASH(0x55b8d6ce15f8)) called at xxx.pl line 54
I recommend relaxing the type check or clarifying the documentation.
use strict;
use warnings;
use utf8;
use Email::Sender::Simple qw(sendmail);
use Email::MIME;
send_foo("\x{304a}");
sub send_foo {
my $foo = shift;
my $mail = Email::MIME->create();
sendmail($mail);
}
This code should say "no recipients".
But it only says "Wide character in die". Because there is wide characters in the caller's arguments.
This behavior makes hard to debug.
(Moo enables use warnings FATAL => 'all';
by strictures.pm)
Per the instructions on CPAN I attempted to create a custom transport, this is what I got, from looking under the hood, I must assume the constructor is inherited??
Don't like to mess around too much in other peoples code.
Any ideas?
I try to send an email to an adress with unknown domain name. (something like
[email protected], DNS can't resolve def.hijk.lmn).
I get an error message:
Odd number of elements in anonymous hash at C:/Perl/site/lib/Email/Sender/Util.pm line 47, line 6.
Requested action not taken: mailbox unavailable
and a stack backtrace.
The problem is really in Util.pm line 47. The following code creates the message:
message => $smtp
? ($error ? ("$error: " . $smtp->message) : $smtp->message)
: $error,
$smtp->message returns an array of two strings because it is called in array context:
'Requested action not taken: mailbox unavailable'
'invalid DNS A/AAAA resource record'
The fix is quite simple:
message => $smtp
? ($error ? ("$error: " . $smtp->message) : scalar($smtp->message))
: $error,
In Debian we are currently applying the following patch to
Email-Sender.
We thought you might be interested in it too.
Description: use version->parse for parsing NET::SMTP's version
The current version of Net::SMTP in Debian is 3.08_01, which causes a warning
in Email::Sender::Transport::SMTP:
.
Argument "3.08_01" isn't numeric in numeric lt (<) at
/usr/share/perl5/Email/Sender/Transport/SMTP.pm line 266.
Bug-Debian: https://bugs.debian.org/847219
Author: Damyan Ivanov <[email protected]>
The patch is tracked in our Git repository at
https://anonscm.debian.org/cgit/pkg-perl/packages/libemail-sender-perl.git/plain/debian/patches/net-smtp-version-cmp.patch
Thanks for considering,
Damyan Ivanov,
Debian Perl Group
my $email = Email::Simple->create(
header => [
From => $from,
To => $to,
Subject => $subject,
],
body => $message,
);
if $subject contains a newline (\n) at the end, it will cause the sent email having no subject line
Hello everyone.
I'm desperately trying to get a connection to an SMTP server, port 465.
See my code. It works the same with swaks but I can't imagine what the problem is.
I also don't get an extra debug... how can i increase debug/verbose for
Can someone help me? Any tips?
Thank you very much
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
use Email::Sender::Simple qw(sendmail);
use Email::Sender::Transport::SMTP qw();
use Email::Simple;
use Email::Simple::Creator;
use Try::Tiny;
my $smtpserver = $ENV{MAIL_HOST};
my $smtpport = $ENV{MAIL_PORT};
my $smtpuser = $ENV{MAIL_USERNAME};
my $smtppassword = $ENV{MAIL_PASSWORD};
my $smtpsendhost = $ENV{MAIL_LOCALADDR};
my $mailto = $ENV{MAIL_TO};
my $mailfrom = $ENV{MAIL_FROM};
my $mailsubject = $ENV{MAIL_SUBJECT};
my $mailcontent = $ENV{MAIL_CONTENT};
my $transport = Email::Sender::Transport::SMTP->new(
{
host => $smtpserver,
port => $smtpport,
sasl_username => $smtpuser,
sasl_password => $smtppassword,
helo => $smtpsendhost,
localaddr => $smtpsendhost,
localport => 0,
timeout => 5,
ssl => 'ssl',
debug => 1,
ssl_options => { Debug => 1 },
}
);
print Dumper $transport;
my $email = Email::Simple->create(
header => [
To => $mailto,
From => $mailfrom,
Subject => 'Test message',
],
body => "This is a test message\n",
);
try {
sendmail( $email, { transport => $transport } );
}
catch {
warn "Error sending email: Dumper $_";
Error:
Trace begun at /usr/local/share/perl5/5.32/Email/Sender/Transport/SMTP.pm line 259
Email::Sender::Transport::SMTP::_throw('Email::Sender::Transport::SMTP=HASH(0x55e5d35e3820)', 'unable to establish SMTP connection to (myserver.local) port 465') called at /usr/local/share/perl5/5.32/Email/Sender/Transport/SMTP.pm line 207
Email::Sender::Transport::SMTP::_smtp_client('Email::Sender::Transport::SMTP=HASH(0x55e5d35e3820)') called at /usr/local/share/perl5/5.32/Email/Sender/Transport/SMTP.pm line 268
Email::Sender::Transport::SMTP::send_email('Email::Sender::Transport::SMTP=HASH(0x55e5d35e3820)', 'Email::Abstract=ARRAY(0x55e5d36188f0)', 'HASH(0x55e5d360b900)') called at /usr/local/share/perl5/5.32/Email/Sender/Role/CommonSending.pm line 45
Email::Sender::Role::CommonSending::try {...} at /usr/local/share/perl5/5.32/Try/Tiny.pm line 102
eval {...} at /usr/local/share/perl5/5.32/Try/Tiny.pm line 93
Try::Tiny::try('CODE(0x55e5d35efc60)', 'Try::Tiny::Catch=REF(0x55e5d3618a28)') called at /usr/local/share/perl5/5.32/Email/Sender/Role/CommonSending.pm line 58
Email::Sender::Role::CommonSending::send('Email::Sender::Transport::SMTP=HASH(0x55e5d35e3820)', 'Email::Abstract=ARRAY(0x55e5d36188f0)', 'HASH(0x55e5d35f0308)') called at /usr/local/share/perl5/5.32/Email/Sender/Simple.pm line 119
Email::Sender::Simple::send_email('Email::Sender::Simple', 'Email::Abstract=ARRAY(0x55e5d36188f0)', 'HASH(0x55e5d35e0300)') called at /usr/local/share/perl5/5.32/Email/Sender/Role/CommonSending.pm line 45
Email::Sender::Role::CommonSending::try {...} at /usr/local/share/perl5/5.32/Try/Tiny.pm line 102
eval {...} at /usr/local/share/perl5/5.32/Try/Tiny.pm line 93
Try::Tiny::try('CODE(0x55e5d35e0588)', 'Try::Tiny::Catch=REF(0x55e5d3618b00)') called at /usr/local/share/perl5/5.32/Email/Sender/Role/CommonSending.pm line 58
Email::Sender::Role::CommonSending::send('Email::Sender::Simple', 'Email::Simple=HASH(0x55e5d35609e8)', 'HASH(0x55e5d2082aa8)') called at /usr/share/perl5/vendor_perl/Sub/Exporter/Util.pm line 18
Sub::Exporter::Util::__ANON__('Email::Simple=HASH(0x55e5d35609e8)', 'HASH(0x55e5d2082aa8)') called at send_befund_3.pl line 50
main::try {...} at /usr/local/share/perl5/5.32/Try/Tiny.pm line 102
eval {...} at /usr/local/share/perl5/5.32/Try/Tiny.pm line 93
Try::Tiny::try('CODE(0x55e5d3560a00)', 'Try::Tiny::Catch=REF(0x55e5d2ef3398)') called at ....
Same with SWAKS but working !!!
swaks --server myserver.local --from [email protected] --to [email protected] --auth --auth-user '[email protected]#*#bla#bla#bla' --auth-password 'password' --port 465 -tlsc
=== Trying myserver.local:465...
=== Connected to myserver.local.
=== TLS started with cipher TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256
=== TLS client certificate not requested and not sent
=== TLS no client certificate set
=== TLS peer[0] subject=[blabla]
=== commonName=[bla], subjectAltName=[] notAfter=[2029-01-23T15:20:30Z]
=== TLS peer certificate failed CA verification (unable to get local issuer certificate), failed host verification (using host myserver.local to verify)
<~ 220 KIM Clientmodul ESMTP
~> EHLO myothserver.local
<~ 250-AIS
<~ 250-SIZE 734003200
<~ 250-8BITMIME
<~ 250-DSN
<~ 250-ENHANCEDSTATUSCODES
<~ 250 AUTH PLAIN LOGIN
~> AUTH LOGIN
<~ 334 bla
~> bla
<~ 334 bla
~> bla
<~ 235 Authentication Successful
~> MAIL FROM:<[email protected]>
<~ 250 sender was provisory permitted
~> RCPT TO:<[email protected]>
<~ 250 recipient was provisory permitted
~> DATA
<~ 354 Start mail input; end with <CRLF>.<CRLF>
~> Date: Fri, 21 Jun 2024 19:33:06 +0200^M
~> To: [email protected]^M
~> From: [email protected]^M
~> Subject: test Fri, 21 Jun 2024 19:33:06 +0200^M
~> Message-Id: <[email protected]>^M
~> X-Mailer: swaks v20240103.0 jetmore.org/john/code/swaks/^M
~> ^M
~> This is a test mailing^M
~> ^M
~> ^M
~> .
<~ 250 2.6.0 Message received
~> QUIT
<~ 221 2.0.0 mail.akquinet.kim.telematik Service closing transmission channel
=== Connection closed with remote host.
I got next error while trying to send email
Argument "3.08_01" isn't numeric in numeric lt (<) at Email/Sender/Transport/SMTP.pm line 297
FWIW, I was playing with adding BDAT support. This is a bit hacky, but may be something to build on in the future:
[edit, hit a keyboard shortcut and submitted before I was finished...]
If I open a filehandle like so:
my $fh = path('my-file')->filehandle('>');
and pass it into the Print transport it fails like so:
main::catch {...} ("isa check for \"fh\" failed: GLOB(0x26eb498) is not blessed at "...)
It seems to be failing this check at line 20 of Email/Sender/Transport/Print.pm:
isa => InstanceOf['IO::Handle'],
It's true that it's not an instanceOf an IO::Handle, but it should work in the place of one:
DB<1> x $fh
0 GLOB(0x35b2b78)
-> *Path::Tiny::$fh
FileHandle({*Path::Tiny::$fh}) => fileno(4)
DB<2>
Probably with an arg_generator
attribute that stores a subroutine to be called like this:
$generator->( $env );
This, then, can let users tweak their sendmail args for -B and -t and other things that don't match the rjbs-defined defaults.
In the same way that the Hello
, LocalAddr
, and LocalPort
options are passed through to Net::SMTP when the helo
, localaddr
, and localport
attributes are set in Email::Sender::Transport::SMTP, it should also be possible to specify the Domain
option for Net::SMTP. Net::SMTP passes this value straight through to IO::Socket, and as far as I can tell, this is the only reliable way to enforce IPv4 connections.
So I have a situation where an app calls Email::Sender::Transport::SMTP, and sends a helo with an IDN (a domain with a UTF-8 character in it). This does not work as Net::Cmd chokes on wide characters.
I could change my code to send a helo as punycode. but then realised if I did this then everything that uses Email::Sender::Transport::SMTP would need to do the same thing, which seems sub optimal.
This pull request automatically will convert any value in the helo field to be the punycode version of the domain (and for an ascii only domain, that is no change at all).
I think that function _quoteaddr in Email/Sender/Transport/SMTP.pm not good. When i try to point this address
"Qwe Asd" <[email protected]>
this function transform it to
""Qwe Asd" <login"@email.com>
So i think that it is a problem.
I think that need to make sure that these addresses are handled correctly:
"Qwe Asd" <[email protected]>
Qwe Asd <[email protected]>
<[email protected]>
[email protected]
Seems try_to_send
will will still initialize Sendmail
transport even when we specify another transport. Noticed since we log every single die
in testing and was getting error messages that sendmail
executable is not found.
Simple script to reproduce:
use Email::Sender::Transport::Test;
use Email::Sender::Simple;
$SIG{__DIE__} = sub { print shift };
my $email = Email::Simple->create(
header => [
To => '"Xavier Q. Ample" <[email protected]>',
From => '"Bob Fishman" <[email protected]>',
Subject => "don't forget to *enjoy the sauce*",
],
body => "This message is short, but at least it's cheap.\n",
);
my $transport = Email::Sender::Transport::Test->new;
Email::Sender::Simple->try_to_send($email, {transport => $transport});
print "\nDelivered to test transport!\n" if $transport->deliveries() == 1;
produces this output:
couldn't find a sendmail executable at /perl/local/lib/perl5/Email/Sender/Transport/Sendmail.pm line 63.
Email::Sender::Transport::Sendmail::_find_sendmail('Email::Sender::Transport::Sendmail=HASH(0x1de4ca8)', 'sendmail') called at /perl/local/lib/perl5/Email/Sender/Transport/Sendmail.pm line 36
Email::Sender::Transport::Sendmail::__ANON__('Email::Sender::Transport::Sendmail=HASH(0x1de4ca8)') called at (eval 51) line 23
Email::Sender::Transport::Sendmail::sendmail('Email::Sender::Transport::Sendmail=HASH(0x1de4ca8)') called at /perl/local/lib/perl5/Email/Sender/Transport/Sendmail.pm line 41
Email::Sender::Transport::Sendmail::BUILD('Email::Sender::Transport::Sendmail=HASH(0x1de4ca8)', 'HASH(0x1dd2758)') called at (eval 52) line 46
Email::Sender::Transport::Sendmail::new('Email::Sender::Transport::Sendmail') called at /perl/local/lib/perl5/Email/Sender/Simple.pm line 72
eval {...} called at /perl/local/lib/perl5/Email/Sender/Simple.pm line 72
Email::Sender::Simple::build_default_transport('Email::Sender::Simple') called at /perl/local/lib/perl5/Email/Sender/Simple.pm line 64
Email::Sender::Simple::default_transport('Email::Sender::Simple') called at /perl/local/lib/perl5/Email/Sender/Simple.pm line 104
Email::Sender::Simple::send_email('Email::Sender::Simple', 'Email::Abstract=ARRAY(0x1e1ad20)', 'HASH(0x1e1ae58)') called at /perl/local/lib/perl5/Email/Sender/Role/CommonSending.pm line 45
Email::Sender::Role::CommonSending::try {...} () called at /perl/local/lib/perl5/Try/Tiny.pm line 103
eval {...} called at /perl/local/lib/perl5/Try/Tiny.pm line 94
Try::Tiny::try('CODE(0x1e1ae10)', 'Try::Tiny::Catch=REF(0x135beb8)') called at /perl/local/lib/perl5/Email/Sender/Role/CommonSending.pm line 58
Email::Sender::Role::CommonSending::send('Email::Sender::Simple', 'Email::Simple=HASH(0x1e1b548)', 'HASH(0x1874880)') called at /perl/local/lib/perl5/Email/Sender/Simple.pm line 132
Email::Sender::Simple::try {...} () called at /perl/local/lib/perl5/Try/Tiny.pm line 103
eval {...} called at /perl/local/lib/perl5/Try/Tiny.pm line 94
Try::Tiny::try('CODE(0x1dfd2d0)', 'Try::Tiny::Catch=REF(0x1bbad90)') called at /perl/local/lib/perl5/Email/Sender/Simple.pm line 137
Email::Sender::Simple::try_to_send('Email::Sender::Simple', 'Email::Simple=HASH(0x1e1b548)', 'HASH(0x1874880)') called at test.pl line 17
Delivered to test transport!
(of course there will be no error output if you have sendmail
on your system)
Email::Sender::Transport::Sendmail should invoke sendmail with the -i switch
"man sendmail" says
-i Ignore dots alone on lines by themselves in incoming messages.
This should be set if you are reading data from a file.
The idea is that if you invoked sendmail interactively, you could end the message with a dot alone on a line. Of course this create problems if you want to send a message containing a dot alone on a line. The -i switch makes it so that the message ends with the end of the input stream, which is far more sensible.
This is taken right from the QuickStart guide
my $transport = Email::Sender::Transport::SMTP->new({
host => 'my.smtp.server',
port => 465,
});
Yet the returned error claims there is no 'new' method, which should be provided to Email::Sender::Transport::SMTP via moo.
I have a perl script run from a web form that create 1 to n emails. I was hoping Email::Sender would be more efficient than calling sendmail directly. However I have a problem in that the email sometimes go and other times they fail to return and the script times out.
here is a partial program sample:
use Email::Sender::Simple qw(try_to_sendmail);
use Email::Simple;
use Email::Simple::Creator;
use Data::Dumper;
use CGI;
$q = new CGI;
...
my $to = """ . $user{user_name} . "" <$user{email}>";
print "sending to $to\n";
my $msg = Email::Simple->create(
header => [
To => $to,
From => '[email protected]',
Subject => 'Login for PharmaNet',
],
body => $body,
);
print Dumper($msg);
my $res = eval {
try_to_sendmail($msg);
};
print "sent $res\n";
Here is the output from a failed attempt:
sending to "Emergency, Demo Account" [email protected]
$VAR1 = bless( {
'body' => 'You have requested a password reset
on 2016/05/04 10:56:05.
If you did not request this, then you should contact your supervisor
immediately to report this.
Click Here
to reset your password.
Your User ID will already be filled in.
Thank you
Medinet Support Staff
',
'mycrlf' => '
',
'header' => bless( {
'headers' => [
'To',
[
'"Emergency, Demo Account" [email protected]',
'To: "Emergency, Demo Account" [email protected]'
],
'From',
[
'[email protected]',
'From: [email protected]'
],
'Subject',
[
'Login for PharmaNet',
'Subject: Login for PharmaNet'
],
'Date',
'Wed, 4 May 2016 10:56:05 -0700'
],
'mycrlf' => '
'
}, 'Email::Simple::Header' )
}, 'Email::Simple' );
It should get to the sent $res statement but it doesn't
There is nothing in the webserver logs to suggest there is a problem, other than it will quit once the timeout occurs.
I just downloaded the most recent version through CPAN.
I'm running an Apache web server and a pretty standard sendmail.
Is there something obvious I'm missing?
When sending several emails using the same transport, each email take several seconds before getting sent. I'm guessing the Email::Sender is logging into the server for each email. Is there a way to send several emails in a single session?
When I use [To=>'root']
I get "no recipient" error.
When I use [To=>'[email protected]',To=>'root']
I get no errors, email sent only to [email protected] and it contain these headers: To: [email protected]
and To: [email protected]
. Same happens with reversed order of To params.
Can you please explain this behaviour?
I am setting up transport as follows:
my $transport = Email::Sender::Transport::SMTP->new({
host => "$user\@smtp.aol.com/",
ssl => 1,
sasl_username => $user,
sasl_password => $pw,
});
and then issuing
sendmail($msg, { to => $to, from => $user, transport => $transport });
where $msg
is just a string. This errors out with
unable to establish SMTP connection to (<user>@smtp.aol.com/) port 465
I can send email with mutt with these same credentials, logging in as $user
with $pw
for my password, with the SMTP server set to
"smtps://[email protected]:465/"
In Email::Sender
, if I keep either the smtps://
preamble or the :465
at the end I get a complaint:
do not pass port number to SMTP transport in host, use port parameter
So I have had to trim down the host to just [email protected]
(specifying ssl => 1
in the transport to default to port 465). Should I specify that SMTP server differently? Perhaps I am missing something obvious..
Perl sometimes ships a Net::SMTP with an underscore in its version, in which case this comparison triggers a numeric
warning.
The public APIs of Email::Simple and Email::MIME do not contain the get_body method, resulting only the message header being stored.
If two processes are trying to deliver to one maildir that doesn't exist yet, and try to create {cur,tmp,new}
at the same time, there is a race. One loses when mkdir tmp
(or whatever) gets EEXIST. That should not be fatal.
Hi
While preparing an update on Debian's side for Email::Sender I noticed the following:
perl -wc /usr/share/perl5/Email/Sender/Simple.pm
Useless use of a constant ("220 OK") in void context at /usr/share/perl5/Email/Sender/Simple.pm line 168.
is that on purpose? i was not sure to report that, since it is since mostly "forewer" that way but decided to ask via issue tracker.
Regards
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.