Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 8f3ecba9

Von Moritz Bunkus vor mehr als 16 Jahren hinzugefügt

  • ID 8f3ecba98c0f85f2b48735c1ac110c3c9d957100
  • Vorgänger 01bdb4dc
  • Nachfolger 16d8d326

Beim Verschicken von Emails müssen die Absender- und Empfängeradressen MIME-Encodiert werden.

Unterschiede anzeigen:

SL/Mailer.pm
30 30

  
31 31
package Mailer;
32 32

  
33
use Email::Address;
34

  
33 35
use SL::Common;
34 36
use SL::Template;
35 37

  
......
97 99
  local (*IN, *OUT);
98 100

  
99 101
  $num_sent++;
100
  my $boundary = time() . "-$$-${num_sent}";
101
  $boundary    =  "LxOffice-$self->{version}-$boundary";
102
  my $domain   =  $self->{from};
103
  $domain      =~ s/(.*?\@|>)//g;
104
  my $msgid    =  "$boundary\@$domain";
105

  
106
  my $form     =  $main::form;
107
  my $myconfig =  \%main::myconfig;
108

  
109
  my $email    =  $myconfig->{email};
110
  $email       =~ s/[^\w\.\-\+=@]//ig;
102
  my $boundary    = time() . "-$$-${num_sent}";
103
  $boundary       =  "LxOffice-$self->{version}-$boundary";
104
  my $domain      =  $self->{from};
105
  $domain         =~ s/(.*?\@|>)//g;
106
  my $msgid       =  "$boundary\@$domain";
111 107

  
112
  $form->{myconfig_email} = $email;
108
  my $form        =  $main::form;
109
  my $myconfig    =  \%main::myconfig;
113 110

  
114
  my $template =  PlainTextTemplate->new(undef, $form, $myconfig);
115
  my $sendmail =  $template->parse_block($main::sendmail);
111
  my $email       =  $myconfig->{email};
112
  $email          =~ s/[^\w\.\-\+=@]//ig;
116 113

  
117
  $self->{charset} = Common::DEFAULT_CHARSET unless $self->{charset};
114
  my %temp_form   = ( %{ $form }, 'myconfig_email' => $email );
115
  my $template    = PlainTextTemplate->new(undef, \%temp_form, $myconfig);
116
  my $sendmail    = $template->parse_block($main::sendmail);
118 117

  
119 118
  if (!open(OUT, $sendmail)) {
120 119
    $main::lxdebug->leave_sub();
121 120
    return "$sendmail : $!";
122 121
  }
123 122

  
124
  $self->{contenttype} = "text/plain" unless $self->{contenttype};
125

  
126
  my ($cc, $bcc);
127
  $cc  = "Cc: $self->{cc}\n"   if $self->{cc};
128
  $bcc = "Bcc: $self->{bcc}\n" if $self->{bcc};
123
  $self->{charset}     ||= Common::DEFAULT_CHARSET;
124
  $self->{contenttype} ||= "text/plain";
129 125

  
130 126
  foreach my $item (qw(to cc bcc)) {
127
    next unless ($self->{$item});
131 128
    $self->{$item} =~ s/\&lt;/</g;
132 129
    $self->{$item} =~ s/\$<\$/</g;
133 130
    $self->{$item} =~ s/\&gt;/>/g;
134 131
    $self->{$item} =~ s/\$>\$/>/g;
135 132
  }
136 133

  
137
  my $subject = $self->mime_quote_text($self->{subject}, 60);
134
  my $headers = '';
135
  foreach my $item (qw(from to cc)) {
136
    next unless ($self->{$item});
137
    my (@addr_objects) = Email::Address->parse($self->{$item});
138
    next unless (scalar @addr_objects);
139

  
140
    foreach my $addr_obj (@addr_objects) {
141
      $addr_obj->phrase($self->mime_quote_text($addr_obj->phrase(), 60))   if ($addr_obj->phrase());
142
      $addr_obj->comment($self->mime_quote_text($addr_obj->comment(), 60)) if ($addr_obj->comment());
143

  
144
      $headers .= sprintf("%s: %s\n", ucfirst($item), $addr_obj->format());
145
    }
146
  }
147

  
148
  $headers .= sprintf("Subject: %s\n", $self->mime_quote_text($self->{subject}, 60));
138 149

  
139
  print OUT qq|From: $self->{from}
140
To: $self->{to}
141
${cc}${bcc}Subject: $subject
142
Message-ID: <$msgid>
150
  print OUT qq|${headers}Message-ID: <$msgid>
143 151
X-Mailer: Lx-Office $self->{version}
144 152
MIME-Version: 1.0
145 153
|;

Auch abrufbar als: Unified diff