Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my $to = qq|"Andy" <andy.newby@gmail.com>|;
- my $subject_val = "test subject";
- my $write_path = "/srv/www/mysite.net/www/cgi-bin/admin/invoice_pdfs/new/pdf_versions/$order->{amazon_order_id}.pdf";
- my $file_name = "$order->{amazon_order_id}.pdf";
- if (!-e $write_path) {
- print qq|PDF doesn't seem to exist yet! SKIPPING ($write_path) n|;
- next;
- }
- print "TO: $to n";
- my $to = qq|"$order->{buyer_name}" <andy.newby@gmail.com>|;
- my $subject_val = sprintf($languages->{subject}->{$lang},$order->{amazon_order_id});
- my $write_path = "/srv/www/mysite.net/www/cgi-bin/admin/invoice_pdfs/new/pdf_versions/$order->{amazon_order_id}.pdf";
- my $file_name = "$order->{amazon_order_id}.pdf";
- my $msg = MIME::Lite->new(
- Type => 'multipart/mixed',
- Subject => $subject_val,
- To => $to,
- From => $from
- );
- # create a sub-part
- my $part = MIME::Lite->new(
- Type => 'multipart/alternative',
- );
- my $att_html = MIME::Lite->new(
- Type => 'text',
- Data => "text version",
- Encoding => 'quoted-printable',
- );
- $att_html->attr('content-type' => 'text/plain; charset=iso-8859-1');
- $part->attach($att_html);
- my $att_text = MIME::Lite->new(
- Type => 'text',
- Data => "html version",
- Encoding => 'quoted-printable',
- );
- $att_text->attr('content-type' => 'text/html; charset=iso-8859-1');
- $part->attach($att_text);
- $msg->attach($part);
- $msg->attach(
- Type =>'application/pdf',
- Path => $write_path,
- Filename => $file_name,
- Disposition => 'attachment'
- );
- my $email = $msg->as_string();
- # now do the sending...
- my $smtp = Net::SMTP->new('smtp.gmail.com',
- Hello => 'steampunkjunkies.net',
- Timeout => 30,
- Debug => 1,
- SSL => 1
- ) || die "Error: $!";
- $smtp->auth($CFG->{db_smtp_user}, $CFG->{db_smtp_pass}) or die "Could not authenticate with mail.n";
- $smtp->mail($from); # from addr
- $smtp->to($to);
- $smtp->bcc('myemail@gmail.com');
- $smtp->data($email); # It hangs here
- $smtp->quit();
- $msg->attach(
- Type =>'application/pdf',
- Path => $write_path,
- Filename => $file_name,
- Disposition => 'attachment'
- );
- perl -d test.cgi
- Loading DB routines from perl5db.pl version 1.44
- Editor support available.
- Enter h or 'h h' for help, or 'man perldebug' for more help.
- Malformed UTF-8 character (unexpected non-continuation byte 0x63, immediately after start byte 0xe9) at test.cgi line 24.
- at test.cgi line 24.
- "my" variable $to masks earlier declaration in same scope at test.cgi line 87.
- at test.cgi line 87.
- "my" variable $subject_val masks earlier declaration in same scope at test.cgi line 88.
- at test.cgi line 88.
- "my" variable $write_path masks earlier declaration in same scope at test.cgi line 90.
- at test.cgi line 90.
- "my" variable $file_name masks earlier declaration in same scope at test.cgi line 91.
- at test.cgi line 91.
- IO::Socket::SSL::CODE(0x29d3f50)(/usr/local/share/perl/5.20.2/IO/Socket/SSL.pm:192):
- 192: INIT { init() }
- DB<1> r
- void context return from CODE(0x29d3f50)
- main::(test.cgi:14): $| = 1;
- DB<1> r
- Content-type: text/html; charset=utf-8
- Doing: 205-2876651-1862762
- TO: Indrek Päri
- $VAR1 = 'Indrek Päri';
- TO: "Andy" <andy.newby@gmail.com>
- r
- ^X^CIO::Socket::SSL::readline(/usr/local/share/perl/5.20.2/IO/Socket/SSL.pm:1171):
- 1171: if ( ! defined $poke or $poke eq '' ) {
- DB<1> n
- ^CIO::Socket::SSL::readline(/usr/local/share/perl/5.20.2/IO/Socket/SSL.pm:1171):
- 1171: if ( ! defined $poke or $poke eq '' ) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement