Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
349 views
in Technique[技术] by (71.8m points)

Laravel SMTP settings are not working but the same settings are working in Perl

I'm having troubles with SMTP settings in my Laravel.

Here is the mail section of in my .env file:

MAIL_DRIVER=smtp
MAIL_HOST=xxxxx.com
MAIL_PORT=25
MAIL_USERNAME=yyyyy.com
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls

I'm getting next error:

Swift_TransportException
Connection could not be established with host xxxxx.com :stream_socket_client(): unable to connect to tcp://xxxxx.com:25 (Permission denied)

I've also tried ports 587 and 465. The same result.

But simple Perl script with the same auth data is working correctly:

$To = '[email protected]';
$Server = 'xxxxx.com';
$From = '"Do Not Reply" <[email protected]>';
$ReplyTo = '"Do Not Reply" <[email protected]>';
$Invitation = "test.txt";
$smtp = Net::SMTP->new($Server, Hello => 'yyyyy.com', Timeout => 30, Debug => 1,);
$smtp->mail($From);
$smtp->to($To);
$smtp->data();
$smtp->datasend("To: $To
");
$smtp->datasend("From: $From
");
$smtp->datasend("Reply-To: $ReplyTo
");
open(INVITE, "<$Invitation") || die "Cannot open invitation: $!
";
while(<INVITE>) {
  $smtp->datasend($_);
}
$smtp->dataend();
close INVITE;
$smtp->quit;

My only doubt is that Hello option in Perl script and MAIL_USERNAME in .env file is not the same option.

Maybe I should use other option for that in my .env file?

Thank you in advance!

question from:https://stackoverflow.com/questions/65885588/laravel-smtp-settings-are-not-working-but-the-same-settings-are-working-in-perl

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try changing the MAIL_PORT to 587


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...