| 97 | | if ($route->{via} eq 'smtp_tls') { |
|---|
| 98 | | $self->{tls_args} = [ |
|---|
| 99 | | $route->{host}, |
|---|
| 100 | | User => $route->{username}, |
|---|
| 101 | | Password => $route->{password}, |
|---|
| 102 | | Port => $route->{port} || 587, |
|---|
| 103 | | ]; |
|---|
| 104 | | $msg->send_by_smtp_tls(@{ $self->{tls_args} }); |
|---|
| 105 | | } elsif ($route->{via} eq 'sendmail') { |
|---|
| 106 | | my %param = (FromSender => "<$cfg->{mailfrom}>"); |
|---|
| 107 | | $param{Sendmail} = $route->{command} if defined $route->{command}; |
|---|
| 108 | | $msg->send('sendmail', %param); |
|---|
| 109 | | } else { |
|---|
| 110 | | my @args = $route->{host} ? ($route->{host}) : (); |
|---|
| 111 | | $msg->send($route->{via}, @args); |
|---|
| | 97 | eval { |
|---|
| | 98 | if ($route->{via} eq 'smtp_tls') { |
|---|
| | 99 | $self->{tls_args} = [ |
|---|
| | 100 | $route->{host}, |
|---|
| | 101 | User => $route->{username}, |
|---|
| | 102 | Password => $route->{password}, |
|---|
| | 103 | Port => $route->{port} || 587, |
|---|
| | 104 | ]; |
|---|
| | 105 | $msg->send_by_smtp_tls(@{ $self->{tls_args} }); |
|---|
| | 106 | } elsif ($route->{via} eq 'sendmail') { |
|---|
| | 107 | my %param = (FromSender => "<$cfg->{mailfrom}>"); |
|---|
| | 108 | $param{Sendmail} = $route->{command} if defined $route->{command}; |
|---|
| | 109 | $msg->send('sendmail', %param); |
|---|
| | 110 | } else { |
|---|
| | 111 | my @args = $route->{host} ? ($route->{host}) : (); |
|---|
| | 112 | $msg->send($route->{via}, @args); |
|---|
| | 113 | } |
|---|
| | 114 | }; |
|---|
| | 115 | |
|---|
| | 116 | if ($@) { |
|---|
| | 117 | $context->log(error => "Error while sending emails: $@"); |
|---|