1 package FS::contact_email;
2 use base qw( FS::Record );
5 use FS::Msgcat qw( gettext );
9 FS::contact_email - Object methods for contact_email records
13 use FS::contact_email;
15 $record = new FS::contact_email \%hash;
16 $record = new FS::contact_email { 'column' => 'value' };
18 $error = $record->insert;
20 $error = $new_record->replace($old_record);
22 $error = $record->delete;
24 $error = $record->check;
28 An FS::contact_email object represents a contact's email address.
29 FS::contact_email inherits from FS::Record. The following fields are currently
55 Creates a new contact email address. To add the email address to the database,
58 Note that this stores the hash reference, not a distinct copy of the hash it
59 points to. You can ask the object for a copy with the I<hash> method.
63 sub table { 'contact_email'; }
67 Adds this record to the database. If there is an error, returns the error,
68 otherwise returns false.
72 Delete this record from the database.
74 =item replace OLD_RECORD
76 Replaces the OLD_RECORD with this one in the database. If there is an error,
77 returns the error, otherwise returns false.
81 Checks all fields to make sure this is a valid email address. If there is
82 an error, returns the error, otherwise returns false. Called by the insert
91 $self->ut_numbern('contactemailnum')
92 || $self->ut_number('contactnum')
94 return $error if $error;
96 #technically \w and also ! # $ % & ' * + - / = ? ^ _ ` { | } ~
97 # and even more technically need to deal with i18n addreesses soon
98 # (maybe the UI can convert them for us ala punycode.js)
99 # but for now in practice have not encountered anything outside \w . - & + '
100 # and even & and ' are super rare and probably have scarier "pass to shell"
101 # implications than worth being pedantic about accepting
102 # (we always String::ShellQuote quote them, but once passed...)
104 if ( $self->emailaddress =~ /^\s*([\w\.\-\+]+)\@(([\w\.\-]+\.)+\w+)\s*$/ ) {
105 my($user, $domain) = ($1, $2);
106 $self->emailaddress("$1\@$2");
108 return gettext("illegal_email_invoice_address"). ': '. $self->emailaddress;
120 L<FS::contact>, L<FS::Record>