如何调试Net :: SMTP Perl程序? [英] How can I debug my Net::SMTP Perl program?

查看:82
本文介绍了如何调试Net :: SMTP Perl程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个将测试消息发送到另一封电子邮件的应用程序,该程序可以正确执行,但是当我检查电子邮件时,没有任何新电子邮件,请看一下我的代码:

I'm building a application that sends a test message to another email, the program executes without errors, but when I check my email there isn't any new email, take a look at my code:

my $smtpserver = 'smtp.vix.terra.com.br';
my $smtpuser = 'nathanpc';
my $fromemail = 'nathanpc@terra.com.br';

    my $smtp = Net::SMTP-> new($smtpserver, Timeout => 120);
    $smtp-> mail($smtpuser);
    $smtp-> to('eeepc904@gmail.com');
    $smtp-> data();
    $smtp-> datasend("To: eeepc904\@gmail.com\n");
    $smtp-> datasend("From: nathanpc\@terra.com.br\n");
    $smtp-> datasend("\n");
    $smtp-> datasend("test\n");
    $smtp-> dataend();
    $smtp-> quit;


推荐答案

只是因为您没有收到电子邮件,这并不表示未发送电子邮件。可能是尚未交付,或者已经交付并被过滤,或者还有许多其他事情。

Just because you didn't get the email doesn't mean the email wasn't sent. It could be that it hasn't been delivered yet, or it was delivered and was filtered, or many other things.

有很多很多事情可能出错

There are many, many things that can go wrong with email.


  • 脚本中带有警告并已严格启用的部分是什么,并且您加载了Net :: SMTP?

  • 为什么不检查是否能够连接到邮件服务器?

  • 为什么没有避难所您是否在调用 new 的呼叫中启用了 Debug 选项?

  • 有警告或错误消息吗?

  • 通过手动连接到服务器尝试相同的SMTP对话时会发生什么?发布整个成绩单。

  • Where's the part of the script with warnings and strict enabled, and you load Net::SMTP? Help yourself with those before running to Stackoverflow.
  • Why don't you check that you were able to connect to the mail server?
  • Why haven't you enabled the Debug option in your call to new?
  • Were there any warnings or error messages?
  • What happens when you try the same SMTP conversation by manually connecting to the server? Post the entire transcript.

在这里问之前,您可以做很多事情来帮助自己,甚至可以依靠Stackoverflow进行操作。最基本的问题不会给您发展自己的技能的机会。

There is a lot that you can do to help yourself before asking here, and relying on Stackoverflow for even the most basic questions doesn't give you a chance to develop your own skills.


#!perl

use warnings;
use strict;

use Net::SMTP;

my $smtpserver = 'smtp.vix.terra.com.br';
my $smtpuser   = 'nathanpc';
my $fromemail  = 'nathanpc@terra.com.br';

my $smtp = Net::SMTP->new($smtpserver, Timeout => 10, Debug => 1);
die "Could not connect to server!\n" unless $smtp;

$smtp->mail($smtpuser);
$smtp->to('eeepc904@gmail.com');
$smtp->data();
$smtp->datasend("To: eeepc904\@gmail.com\n");
$smtp->datasend("From: $fromemail\n");
$smtp->datasend("\n");
$smtp->datasend("test\n");
$smtp->dataend();
$smtp->quit;

这篇关于如何调试Net :: SMTP Perl程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆