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