line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Email::Send::Zoho; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
28970
|
use 5.006; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
30
|
|
6
|
1
|
|
|
1
|
|
1615
|
use MIME::Lite; |
|
1
|
|
|
|
|
50745
|
|
|
1
|
|
|
|
|
45
|
|
7
|
1
|
|
|
1
|
|
1036
|
use MIME::Words qw(encode_mimewords); |
|
1
|
|
|
|
|
2173
|
|
|
1
|
|
|
|
|
61
|
|
8
|
1
|
|
|
1
|
|
945
|
use Net::SMTP::SSL; |
|
1
|
|
|
|
|
151939
|
|
|
1
|
|
|
|
|
16
|
|
9
|
1
|
|
|
1
|
|
86
|
use Carp qw/croak/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
72
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
372
|
BEGIN { @MIME::Lite::SMTP::ISA = qw(Net::SMTP::SSL); } |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
18
|
0
|
|
|
|
|
|
my $email = shift; |
19
|
0
|
|
|
|
|
|
my $passwd = shift; |
20
|
0
|
|
|
|
|
|
my $debug = shift; |
21
|
|
|
|
|
|
|
|
22
|
0
|
0
|
|
|
|
|
$debug = 0 unless defined $debug; |
23
|
|
|
|
|
|
|
|
24
|
0
|
0
|
|
|
|
|
eval { |
25
|
0
|
|
|
|
|
|
require MIME::Base64; |
26
|
0
|
|
|
|
|
|
require Authen::SASL; |
27
|
|
|
|
|
|
|
} or croak "Need MIME::Base64 and Authen::SASL for sendmail"; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
bless {email=>$email,passwd=>$passwd,debug=>$debug}, $class; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub sendmail { |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
35
|
0
|
|
|
|
|
|
my $title = shift; |
36
|
0
|
|
|
|
|
|
my $html_body = shift; |
37
|
0
|
|
|
|
|
|
my @recepients = @_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $to_address = join ',',@recepients; |
40
|
0
|
|
|
|
|
|
my $from_address = $self->{email}; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $subject = encode_mimewords($title,'Charset','UTF-8'); |
43
|
|
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
|
my $msg = MIME::Lite->new ( |
45
|
|
|
|
|
|
|
From => $from_address, |
46
|
|
|
|
|
|
|
To => $to_address, |
47
|
|
|
|
|
|
|
Subject => $subject, |
48
|
|
|
|
|
|
|
Type => 'text/html', |
49
|
|
|
|
|
|
|
Data => $html_body, |
50
|
|
|
|
|
|
|
Encoding => 'base64', |
51
|
|
|
|
|
|
|
) or croak "create container failed: $!"; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$msg->attr('content-type.charset' => 'UTF-8'); |
54
|
0
|
|
|
|
|
|
$msg->send('smtp', |
55
|
|
|
|
|
|
|
'smtp.zoho.com', |
56
|
|
|
|
|
|
|
Port => 465, |
57
|
|
|
|
|
|
|
AuthUser => $from_address, |
58
|
|
|
|
|
|
|
AuthPass => $self->{passwd}, |
59
|
|
|
|
|
|
|
Debug => $self->{debug} |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 NAME |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Email::Send::Zoho - Send email with Zoho's SMTP servers |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 VERSION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Version 0.01 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 SYNOPSIS |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
use Email::Send::Zoho; |
78
|
|
|
|
|
|
|
my $smtp = Email::Send::Zoho->new('john@zoho.com','mypasswd'); |
79
|
|
|
|
|
|
|
$smtp->sendmail($subject,$html_body,'foo@gmail.com','bar@hotmail.com'); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 METHODS |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 new($email, $password, [$debug]) |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Create the object. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
The email acount can be at zoho.com, or any other domains you setup with zoho business application. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $smtp = Email::Send::Zoho->new('foo@zoho.com','password'); |
91
|
|
|
|
|
|
|
# or with debug |
92
|
|
|
|
|
|
|
my $smtp = Email::Send::Zoho->new('foo@zoho.com','password',1); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 sendmail($subject, $html_body, @recepients) |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Send the message. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
The subject and body can be Chinese (if so they must be UTF-8 string). |
99
|
|
|
|
|
|
|
They will be encoded with UTF-8 for sending. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
The message body should be HTML syntax compatible, it will be sent with text/html format. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
my $subject = "Hello"; |
104
|
|
|
|
|
|
|
my $html_body =<
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Hello there |
108
|
|
|
|
|
|
|
It's nice to see you. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
EOF |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
$smtp->sendmail($subject,$html_body,'foo@gmail.com'); |
114
|
|
|
|
|
|
|
# send to more than one people |
115
|
|
|
|
|
|
|
$smtp->sendmail($subject,$html_body,'foo@gmail.com','bar@hotmail.com', ...); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 AUTHOR |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Ken Peng |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 BUGS/LIMITATIONS |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
If you have found bugs, please send email to |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 SUPPORT |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
perldoc Email::Send::Zoho |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Copyright 2012 Ken Peng, all rights reserved. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
140
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
141
|
|
|
|
|
|
|
|