o4oren / Ad-Hoc-Email-Server

An ad-hoc disposable temporary mail server. Create and use ad hoc disposable mailboxes for testing or any other purpose.
Apache License 2.0
385 stars 91 forks source link

The app crashes when testing with telnet #7

Closed cryptton2004 closed 5 years ago

cryptton2004 commented 5 years ago

Hello,

I managed to follow your steps and install the app on a windows 7 virtual machine. I started the app with node ahem.js and opened another console to test the email functionality (response from API was already received as: {"success":true,"api":true,"smtp":true,"db":true} ) So, going further, in the new console I followed these steps:

  1. Type the following command: telnet \<mail server name or IP> 25
  2. Type: EHLO \<mail server internet name> Replace with your mail server's public fully qualified domain name - for instance, mail.dell.com.
  3. Type: mail from: \your_name@yourdomain.com\ and press Enter.
  4. Type: rcpt to: \recipient@recipientdomain.com\ and press Enter.
  5. Type: data and press Enter.
  6. Type: Subject: \<a subject here> and press Enter.
  7. Type: This is a test message sent from telnet. and press Enter.
  8. Type: . and press Enter

In the ahem.js console I can see the telnet connection, but just when finishing everything up and performing step 8, the ahem.js console crashes with this error:

`{"message":"SMTP Connect from myIpV6 ","level":"info"}
{"message":"SMTP MAIL FROM: testfeda@machineName.domain.org","level":"info"}
{"message":"SMTP RCPT TO: testfeda@machineName.domain.org","level":"info"}
{"message":"SMTP DATA start","level":"info"}
{"message":"SMTP DATA end","level":"info"}
E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\mongodb\lib\utils.js:132
      throw err;
      ^

TypeError: Cannot read property 'value' of undefined
    at E:\tests\EmailServer\Ad-Hoc-Email-Server\server\app\smtp.js:67:23
    at E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\←[4mmongodb←[24m\li
b\utils.js:414:17
    at E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\←[4mmongodb←[24m\li
b\utils.js:401:11
    at ClientSession.endSession (E:\tests\EmailServer\Ad-Hoc-Email-Server\node_m
odules\←[4mmongodb-core←[24m\lib\sessions.js:129:41)
    at executeCallback (E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\←[
4mmongodb←[24m\lib\utils.js:397:17)
    at E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\←[4mmongodb←[24m\li
b\operations\collection_ops.js:876:19
    at handleCallback (E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\←[4
mmongodb←[24m\lib\utils.js:128:55)
    at E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\←[4mmongodb←[24m\li
b\operations\collection_ops.js:848:5
    at E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\←[4mmongodb-core←[2
4m\lib\connection\pool.js:532:18
←[90m    at processTicksAndRejections (internal/process/task_queues.js:75:11)←[3
9m

E:\tests\EmailServer\Ad-Hoc-Email-Server>node ahem.js`

At this point, I'm not really sure how to proceed in testing if everything works. I can see that there are some emails occasionally received from what appears to be an 'alive-test' email box, but that's pretty much it. I don't know if the emails that another app sends, reach this server and I cannot debug it as I don't have access to its logs. Sending an email from outlook won't work because the VM is not accessible from outside, but the other app is within the same network so it will be able to access it. So the only way that I thought of testing was with telnet. Any thoughts? Looking in mongo, I see that when creating a mailbox from the AHEM UI, nothing happens in the API or in the DB (as in, the mailbox is not created per'say, but it's rather just a redirection). I suppose the mailbox will be created upon receiving the first email?

Thank you, Feda

o4oren commented 5 years ago

I am not sure what are you trying to achieve. Is recipientsdomain.com in the allowed domains field of the configuration json?

On Fri, Aug 30, 2019 at 3:59 PM Cryptton notifications@github.com wrote:

Hello,

I managed to follow your steps and install the app on a windows 7 virtual machine. I started the app with node ahem.js and opened another console to test the email functionality (response from API was already received as: {"success":true,"api":true,"smtp":true,"db":true} ) So, going further, in the new console I followed these steps:

  1. Type the following command: telnet 25
  2. Type: EHLO Replace with your mail server's public fully qualified domain name - for instance, mail.dell.com.
  3. Type: mail from: your_name@yourdomain.com and press Enter.
  4. Type: rcpt to: recipient@recipientdomain.com and press Enter.
  5. Type: data and press Enter.
  6. Type: Subject: and press Enter.
  7. Type: This is a test message sent from telnet. and press Enter.
  8. Type: . and press Enter

In the ahem.js console I can see the telnet connection, but just when finishing everything up and performing step 8, the ahem.js console crashes with this error:

`{"message":"SMTP Connect from myIpV6 ","level":"info"} {"message":"SMTP MAIL FROM: testfeda@machineName.domain.org ","level":"info"} {"message":"SMTP RCPT TO: testfeda@machineName.domain.org","level":"info"} {"message":"SMTP DATA start","level":"info"} {"message":"SMTP DATA end","level":"info"}

E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\mongodb\lib\utils.js:132 throw err; ^

TypeError: Cannot read property 'value' of undefined at E:\tests\EmailServer\Ad-Hoc-Email-Server\server\app\smtp.js:67:23 at E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\←[4mmongodb←[24m\li b\utils.js:414:17 at E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\←[4mmongodb←[24m\li b\utils.js:401:11 at ClientSession.endSession (E:\tests\EmailServer\Ad-Hoc-Email-Server\node_m odules\←[4mmongodb-core←[24m\lib\sessions.js:129:41) at executeCallback (E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\←[ 4mmongodb←[24m\lib\utils.js:397:17) at E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\←[4mmongodb←[24m\li b\operations\collection_ops.js:876:19 at handleCallback (E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\←[4 mmongodb←[24m\lib\utils.js:128:55) at E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\←[4mmongodb←[24m\li b\operations\collection_ops.js:848:5 at E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\←[4mmongodb-core←[2 4m\lib\connection\pool.js:532:18 ←[90m at processTicksAndRejections (internal/process/task_queues.js:75:11)←[3 9m

E:\tests\EmailServer\Ad-Hoc-Email-Server>node ahem.js`

At this point, I'm not really sure how to proceed in testing if everything works. I can see that there are some emails occasionally received from what appears to be an 'alive-test' email box, but that's pretty much it. I don't know if the emails that another app sends, reach this server and I cannot debug it as I don't have access to its logs. Sending an email from outlook won't work because the VM is not accessible from outside, but the other app is within the same network so it will be able to access it. So the only way that I thought of testing was with telnet. Any thoughts? Looking in mongo, I see that when creating a mailbox from the AHEM UI, nothing happens in the API or in the DB (as in, the mailbox is not created per'say, but it's rather just a redirection). I suppose the mailbox will be created upon receiving the first email?

Thank you, Feda

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/o4oren/Ad-Hoc-Email-Server/issues/7?email_source=notifications&email_token=AFTF65UUT34IQ6OS5J5YKPTQHEKTRA5CNFSM4ISNB4V2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HIOG33A, or mute the thread https://github.com/notifications/unsubscribe-auth/AFTF65STBVB4FKTVYQNLA2DQHEKTRANCNFSM4ISNB4VQ .

cryptton2004 commented 5 years ago

I'm trying to telnet the mail server to see if it receives mails :) Yes, the domain is in the allowed list.

cryptton2004 commented 5 years ago

Ok, this was because the 'To' field is missing from the email, when sending via telnet. Thus in smtp.js, the app was crashing while trying to iterate through the mail properties, since there is no mail.to property on the object: mail.to.value.forEach(recipient => {... Testing and debugging via telnet was incredibly slow (you have to type every single character and start over if you make a mistake) so I switched to windows power shell:

Send-MailMessage -SMTPServer my-machine.domain.com -To testfeda@my-machine.domain.com -From some@email.com -Subject "This is a test email" -Body "Hi, this is a test email sent via PowerShell to test the STMP relay server"

This doesn't make the app crash anymore, however I still don't see any other entries created in mongo's mailboxes collection. I think it still fails when trying to add the entry, probably in the same forEach (mail.to.value...) since I can't seem to reach the message: logger.info('updated email content in db.');

I'll debug further and come back with an update. Feel free to jump in if you have any ideas of known issues.

cryptton2004 commented 5 years ago

Is recipientsdomain.com in the allowed domains field of the configuration

So it seems that I had an extra space. I updated the config file and it works now. Thanks for the support! Have a great weekend!

o4oren commented 5 years ago

Thanks, I will make it not crash, and print a useful error in this case.

On Fri, Aug 30, 2019, 18:00 Cryptton notifications@github.com wrote:

Ok, this was because the 'To' field is missing from the email, when sending via telnet. Thus is smtp.js, the app was crashing while trying to iterate through the mail properties, since there is no mail.to property on the object: mail.to.value.forEach(recipient => {... Testing and debugging via telnet was incredibly slow (you have to type every single character and start over if you make a mistake) so I switched to windows power shell:

Send-MailMessage -SMTPServer my-machine.domain.com -To testfeda@my-machine.domain.com -From some@email.com -Subject "This is a test email" -Body "Hi, this is a test email sent via PowerShell to test the STMP relay server"

This doesn't make the app crash anymore, however I still don't see any other entries created in mongo's mailboxes collection. I think it still fails when trying to add the entry, probably in the same forEach (mail.to.value...) since I can't seem to reach the message: logger.info('updated email content in db.');

I'll debug further and come back with an update. Feel free to jump in if you have any ideas of knows issues.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/o4oren/Ad-Hoc-Email-Server/issues/7?email_source=notifications&email_token=AFTF65RO7GIO7I26OIHTCODQHEYZDA5CNFSM4ISNB4V2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5R47OA#issuecomment-526634936, or mute the thread https://github.com/notifications/unsubscribe-auth/AFTF65TFTIII5SZAXYXWZR3QHEYZDANCNFSM4ISNB4VQ .