Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.00 KB | None | 0 0
  1. my $to = qq|"Andy" <andy.newby@gmail.com>|;
  2. my $subject_val = "test subject";
  3.  
  4. my $write_path = "/srv/www/mysite.net/www/cgi-bin/admin/invoice_pdfs/new/pdf_versions/$order->{amazon_order_id}.pdf";
  5. my $file_name = "$order->{amazon_order_id}.pdf";
  6.  
  7. if (!-e $write_path) {
  8. print qq|PDF doesn't seem to exist yet! SKIPPING ($write_path) n|;
  9. next;
  10. }
  11.  
  12. print "TO: $to n";
  13.  
  14. my $to = qq|"$order->{buyer_name}" <andy.newby@gmail.com>|;
  15. my $subject_val = sprintf($languages->{subject}->{$lang},$order->{amazon_order_id});
  16.  
  17. my $write_path = "/srv/www/mysite.net/www/cgi-bin/admin/invoice_pdfs/new/pdf_versions/$order->{amazon_order_id}.pdf";
  18. my $file_name = "$order->{amazon_order_id}.pdf";
  19.  
  20. my $msg = MIME::Lite->new(
  21. Type => 'multipart/mixed',
  22. Subject => $subject_val,
  23. To => $to,
  24. From => $from
  25. );
  26.  
  27. # create a sub-part
  28. my $part = MIME::Lite->new(
  29. Type => 'multipart/alternative',
  30. );
  31.  
  32. my $att_html = MIME::Lite->new(
  33. Type => 'text',
  34. Data => "text version",
  35. Encoding => 'quoted-printable',
  36. );
  37. $att_html->attr('content-type' => 'text/plain; charset=iso-8859-1');
  38. $part->attach($att_html);
  39.  
  40. my $att_text = MIME::Lite->new(
  41. Type => 'text',
  42. Data => "html version",
  43. Encoding => 'quoted-printable',
  44. );
  45. $att_text->attr('content-type' => 'text/html; charset=iso-8859-1');
  46. $part->attach($att_text);
  47.  
  48. $msg->attach($part);
  49.  
  50. $msg->attach(
  51. Type =>'application/pdf',
  52. Path => $write_path,
  53. Filename => $file_name,
  54. Disposition => 'attachment'
  55. );
  56.  
  57. my $email = $msg->as_string();
  58.  
  59. # now do the sending...
  60. my $smtp = Net::SMTP->new('smtp.gmail.com',
  61. Hello => 'steampunkjunkies.net',
  62. Timeout => 30,
  63. Debug => 1,
  64. SSL => 1
  65. ) || die "Error: $!";
  66.  
  67. $smtp->auth($CFG->{db_smtp_user}, $CFG->{db_smtp_pass}) or die "Could not authenticate with mail.n";
  68.  
  69. $smtp->mail($from); # from addr
  70. $smtp->to($to);
  71. $smtp->bcc('myemail@gmail.com');
  72. $smtp->data($email); # It hangs here
  73. $smtp->quit();
  74.  
  75. $msg->attach(
  76. Type =>'application/pdf',
  77. Path => $write_path,
  78. Filename => $file_name,
  79. Disposition => 'attachment'
  80. );
  81.  
  82. perl -d test.cgi
  83.  
  84. Loading DB routines from perl5db.pl version 1.44
  85. Editor support available.
  86.  
  87. Enter h or 'h h' for help, or 'man perldebug' for more help.
  88.  
  89. Malformed UTF-8 character (unexpected non-continuation byte 0x63, immediately after start byte 0xe9) at test.cgi line 24.
  90. at test.cgi line 24.
  91. "my" variable $to masks earlier declaration in same scope at test.cgi line 87.
  92. at test.cgi line 87.
  93. "my" variable $subject_val masks earlier declaration in same scope at test.cgi line 88.
  94. at test.cgi line 88.
  95. "my" variable $write_path masks earlier declaration in same scope at test.cgi line 90.
  96. at test.cgi line 90.
  97. "my" variable $file_name masks earlier declaration in same scope at test.cgi line 91.
  98. at test.cgi line 91.
  99. IO::Socket::SSL::CODE(0x29d3f50)(/usr/local/share/perl/5.20.2/IO/Socket/SSL.pm:192):
  100. 192: INIT { init() }
  101. DB<1> r
  102. void context return from CODE(0x29d3f50)
  103. main::(test.cgi:14): $| = 1;
  104. DB<1> r
  105. Content-type: text/html; charset=utf-8
  106.  
  107. Doing: 205-2876651-1862762
  108. TO: Indrek Päri
  109. $VAR1 = 'Indrek Päri';
  110. TO: "Andy" <andy.newby@gmail.com>
  111. r
  112.  
  113.  
  114.  
  115. ^X^CIO::Socket::SSL::readline(/usr/local/share/perl/5.20.2/IO/Socket/SSL.pm:1171):
  116. 1171: if ( ! defined $poke or $poke eq '' ) {
  117.  
  118. DB<1> n
  119. ^CIO::Socket::SSL::readline(/usr/local/share/perl/5.20.2/IO/Socket/SSL.pm:1171):
  120. 1171: if ( ! defined $poke or $poke eq '' ) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement