Email-SendGrid-V3
view release on metacpan or search on metacpan
lib/Email/SendGrid/V3.pm view on Meta::CPAN
#pod shown a list of these groups and allowed to choose which ones he/she would like to unsubscribe
#pod from.
#pod
#pod =cut
sub unsubscribe_group {
my ($self, $group_id, @display_groups) = @_;
croak "Unsubscribe group ID is required" unless $group_id;
croak "Cannot display more than 25 groups" if scalar(@display_groups) > 25;
$self->{data}{asm} = { group_id => $group_id };
$self->{data}{asm}{groups_to_display} = \@display_groups if @display_groups;
return $self;
}
#pod =head3 $self->ip_pool_name($pool_name);
#pod
#pod The IP Pool that you would like to send this email from.
#pod
#pod =cut
sub ip_pool_name {
my ($self, $pool_name) = @_;
delete $self->{data}{ip_pool_name};
$self->{data}{ip_pool_name} = $pool_name if $pool_name;
return $self;
}
#pod =head3 $self->click_tracking($enable, %args);
#pod
#pod Whether to enable click-tracking for this message. If enabled, any URLs in the body of this
#pod message will be rewritten to proxy through SendGrid for tracking purposes. This setting will
#pod overwrite the account-level setting if any. One optional argument is accepted: 'enable_text'
#pod which controls whether the link-rewriting is also performed for plaintext emails (the rewritten
#pod URL will be visible to the recipient)
#pod
#pod =cut
sub click_tracking {
my ($self, $enable, %args) = @_;
$enable = $enable ? JSON::true : JSON::false;
$self->{data}{tracking_settings} ||= {};
$self->{data}{tracking_settings}{click_tracking} = { enable => $enable };
if (defined $args{enable_text}) {
$self->{data}{tracking_settings}{click_tracking}{enable_text} =
$args{enable_text} ? JSON::true : JSON::false;
}
return $self;
}
#pod =head3 $self->open_tracking($enable, %args);
#pod
#pod Whether to enable open-tracking for this message. If enabled, a single transparent pixel image
#pod is added to the HTML body of this message and used to determine if and when the recipient opens
#pod the message. This setting will overwrite the account-level setting if any. One optional argument
#pod is accepted: 'substitution_tag' which identifies a token in the message body that should be replaced
#pod with the tracking pixel.
#pod
#pod =cut
sub open_tracking {
my ($self, $enable, %args) = @_;
$enable = $enable ? JSON::true : JSON::false;
$self->{data}{tracking_settings} ||= {};
$self->{data}{tracking_settings}{open_tracking} = { enable => $enable };
$self->{data}{tracking_settings}{open_tracking}{substitution_tag} =
$args{substitution_tag} if $args{substitution_tag};
return $self;
}
#pod =head3 $self->subscription_tracking($enable, %args);
#pod
#pod Whether to enable a sendgrid-powered unsubscribe link in the footer of the email. You may pass
#pod optional arguments 'text' and 'html' to control the verbiage of the unsubscribe link used, OR
#pod 'substitution_tag' which is a token that will be replaced with the unsubscribe URL.
#pod This setting will overwrite the account-level setting if any.
#pod
#pod =cut
sub subscription_tracking {
my ($self, $enable, %args) = @_;
$enable = $enable ? JSON::true : JSON::false;
my $new = { enable => $enable };
$new->{text} = $args{text} if $args{text};
$new->{html} = $args{html} if $args{html};
$new->{substitution_tag} = $args{substitution_tag} if $args{substitution_tag};
$self->{data}{tracking_settings} ||= {};
$self->{data}{tracking_settings}{subscription_tracking} = $new;
return $self;
}
#pod =head3 $self->ganalytics($enable, %args);
#pod
#pod Whether to enable google analytics tracking for this message. Optional arguments
#pod include 'utm_source', 'utm_medium', 'utm_term', 'utm_content', and 'utm_campaign'.
#pod This setting will overwrite the account-level setting if any.
#pod
#pod =cut
sub ganalytics {
my ($self, $enable, %args) = @_;
$enable = $enable ? JSON::true : JSON::false;
my $new = { enable => $enable };
$new->{utm_source} = $args{utm_source} if $args{utm_source};
lib/Email/SendGrid/V3.pm view on Meta::CPAN
Clears out all categories defined for this message.
=head3 $self->set_categories(@categories);
Sets the list of categories for this message. The list of categories must be
unique and contain no more than 10 items.
=head3 $self->add_category($name);
Adds a new category for this message. The list of categories must be
unique and contain no more than 10 items.
=head3 $self->clear_custom_args();
Clears out all custom arguments defined for this message.
=head3 $self->set_custom_args(%args);
Sets all custom arguments defined for this message.
These can be overridden at the message personalization level.
The total size of custom arguments cannot exceed 10,000 bytes.
=head3 $self->send_at($timestamp);
A unix timestamp (seconds since 1970) specifying when to deliver this message.
Cannot be more than 72 hours in the future.
This can be overridden at the message personalization level.
=head3 $self->batch_id($batch_id);
Identifies a batch to include this message in. This batch ID can later be used
to pause or cancel the delivery of a batch (if a future delivery time was set)
=head3 $self->unsubscribe_group($group_id, @display_groups);
If you've set up multiple unsubscribe groups in the SendGrid web application, this method
allows you to specify which group this message belongs to. If this is set and the user
unsubscribes from this message, they will only be added to the suppression list for that
single group. If not set, they will be added to the global unsubscribe list.
@display_groups is optional. If specified, when the user clicks "unsubscribe" they will be
shown a list of these groups and allowed to choose which ones he/she would like to unsubscribe
from.
=head3 $self->ip_pool_name($pool_name);
The IP Pool that you would like to send this email from.
=head3 $self->click_tracking($enable, %args);
Whether to enable click-tracking for this message. If enabled, any URLs in the body of this
message will be rewritten to proxy through SendGrid for tracking purposes. This setting will
overwrite the account-level setting if any. One optional argument is accepted: 'enable_text'
which controls whether the link-rewriting is also performed for plaintext emails (the rewritten
URL will be visible to the recipient)
=head3 $self->open_tracking($enable, %args);
Whether to enable open-tracking for this message. If enabled, a single transparent pixel image
is added to the HTML body of this message and used to determine if and when the recipient opens
the message. This setting will overwrite the account-level setting if any. One optional argument
is accepted: 'substitution_tag' which identifies a token in the message body that should be replaced
with the tracking pixel.
=head3 $self->subscription_tracking($enable, %args);
Whether to enable a sendgrid-powered unsubscribe link in the footer of the email. You may pass
optional arguments 'text' and 'html' to control the verbiage of the unsubscribe link used, OR
'substitution_tag' which is a token that will be replaced with the unsubscribe URL.
This setting will overwrite the account-level setting if any.
=head3 $self->ganalytics($enable, %args);
Whether to enable google analytics tracking for this message. Optional arguments
include 'utm_source', 'utm_medium', 'utm_term', 'utm_content', and 'utm_campaign'.
This setting will overwrite the account-level setting if any.
=head3 $self->bcc($enable, %args);
Whether to BCC a monitoring account when sending this message. Optional arguments
include 'email' for the address that will receive the BCC if one is not configured
at the account level. This setting will overwrite the account-level setting if any.
=head3 $self->bypass_list_management($enable);
Whether to bypass the built-in suppression SendGrid provides, such as unsubscribed
recipients, those that have bounced, or marked the emails as spam.
This setting will overwrite the account-level setting if any.
=head3 $self->footer($enable, %args);
Whether to add a footer to the outgoing message. Optional arguments include 'html' and
'text' to specify the footers that will be used for each message body type.
This setting will overwrite the account-level setting if any.
=head3 $self->sandbox_mode($enable);
Whether to enable sandbox mode. When enabled, SendGrid will validate the contents of this
API request for correctness, but will not actually send the message.
=head3 $self->spam_check($enable, %args);
Whether to perform a spam check on this message prior to sending. If the message fails the
spam check, it will be dropped and not sent. Optional parameters include 'threshold' - an
integer score value from 1-10 (default 5) over which a message will be classified as spam,
and 'post_to_url' - a SendGrid inbound message parsing URL that will be used to post back
notifications of messages identified as spam and dropped. These settings will overwrite
the account-level settings if any.
=head1 AUTHOR
Grant Street Group <developers@grantstreet.com>
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2018 - 2020 by Grant Street Group.
This is free software, licensed under:
( run in 0.935 second using v1.01-cache-2.11-cpan-e1769b4cff6 )