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