Answer the question
In order to leave comments, you need to log in
How to fill in From?
Hello, The mail.ru mail service provides the ability to create additional mail addresses on one account.
There is mail_1 - the main and mail_2 additional address.
Mail_2 received a message, if you send a response through the web interface, then the sender will be mail_2, if I send it with a perl script, then the sender will be mail_1.
how to make the sender be mail_2 ?
Below are the functions in which there is From
# Email login and password
$email_login = '[email protected]';
$email_password = 'd123';
$MAIL_2 = '[email protected]';
# -----------------------------------------------------------------------------------
sub get_inbox_emails {
$ping->ping($email_server) or die "Ошибка: Сервер ${email_server} не доступен.\n";
@mails = ($client->seen, $client->unseen);
my %check_exst;
for my $msg_id (@mails) {
$body = $client->message_string($msg_id) or die;
$parser = MIME::Parser->new() or die;
$parser->output_to_core(1);
$entity = $parser->parse_data(\$body) or die "parse failed\n";
$header = $entity->head;
$from = $header->get('Reply-To');
$from = $header->get('From') unless ($from);
chomp $from;
if ($from =~ /([\w\.]*\[email protected][\w+\.]+[A-Za-z]+)/) {
unless (defined $check_exst{$1}) {
push @emails_list, $1;
$check_exst{$1} = '';
}
} else {
print "Ошибка определения адреса отправителя в сообщении ${msg_id}.\n";
}
}
}
# -----------------------------------------------------------------------------------
sub send_email {
undef $smtp;
my $msg_data = "From: ${email_login}\nTo: ${to_mail}\nSubject: ${mail_send_text_subject}\nContent-Type: text/html; charset=\"UTF-8\"\n\n${mail_send_text}\n";
$smtp = Net::SMTP->new(
$email_send_server,
Port => $email_send_port,
SSL => 1,
Timeout => 10,
Debug => $send_debug_flag
) or return 0;
$smtp->auth($email_login, $email_password) or return 0;
$smtp->mail("${email_login}\n") or return 0;
$smtp->to("${to_mail}\n") or return 0;
$smtp->data() or return 0;
$smtp->datasend("$msg_data") or return 0;
$smtp->dataend() or return 0;
$smtp->quit;
return 1;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question