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