TIdSTMPServer OnMsgReceive event to redirect mail to other smtp servers - delphi

I'm using indy and I'm hosting a mail server. I'd like to make a secure connection to other mail (smtp) servers without username/password from my IdSMTPServer so that if my server receives an email that's got to go to yahoo or gmail for example I can redirect it successfully. I tried Remy's answer to this topic Using INDY SMTPServer - using IdSMTPRelay but it didn't work for me. I also tried using TIdSMTP to send the message but if I leave the username/password fields unassigned I receive the error Authentication required from the smtp servers i'm sending the mail to. The IdSMTPServer has self signed OpenSSL certificates assigned to it with the IdServerIOHandlerSSLOpenSSL component so I suppose I should be able to achieve SSL connection but I just don't know how.

Related

Way to intercept emails on smtp docker (namshi/smtp)

I am looking for a way to test the email sending feature of our app. I have configured namshi/smtp docker image to act as an smtp server and our app is using this smtp server to send emails. We currently have a system that reads the email on the client side once its delivered, to verify we are formatting the email correctly. This is a bit unreliable since it involves an actual email being delivered.
So, I wanted to see if there is a way to intercept or read emails being delivered through this local smtp server. I checked the logs of the smtp server but as expected, it doesn't have any details of the email body or subject. Anyone knows anyway I could intercept these smtp requests somehow?
Or if there is a better way to verify email formatting as part of integration testing?
Heres a good source on how to use smtpd library in python to mock an SMTP server https://pymotw.com/2/smtpd/. Mock SMTP server and process emails through smtpd.SMTPServer.process_message

Implementing Mail Server using TIdSMTPServer

I have acquired the domain name - xyz.in from GoDaddy.com and also acquired the mail ID - info#xyz.in. And currently, I can able to send 500 mails by using GoDaddy.
So, I'm thinking to implement my Mail Server using Delphi - TIdSmtpServer. I found few samples but for sending mails how can I use the sender ID as info#xyz.in and send mails. As I need to send only mails, what are the other settings and please provide some basic sample code.
Thanks in advance.
SMTP is one-way, from sender to receiver. You cannot send emails with TIdSMTPServer, only receive them. Your SMTP server needs to store received emails as needed for you to retrieve them later, via POP3/IMAP, or whatever custom system you want to make.
When someone wants to send an email to you at info#xyz.in, they perform a DNS lookup of the MX record for xyz.in, then connect to that server and issue SMTP commands to deliver the email to the info mailbox 1. So you need to configure your domain's DNS MX record to point at the IP address of your SMTP server machine.
To send an email from your system to someone else, use TIdSMTP instead, so it can connect to and send the email to the other person's SMTP server. You can use TIdDNSResolver to lookup a domain's MX records to find the IP address(es) to connect to 1.
1: most users send an outgoing email through their ISP's own SMTP server and let it relay the email to each recipient's domain SMTP server as needed. And use their ISP's SMTP server to receive emails. This is easier for users to use and configure, and it is safer as it allows ISPs to implement security and anti-spam measures. So you may end up sticking with GoDaddy's SMTP server instead of running your own in the long run.

PHPMailer authentication issue xoauth2

I am using Google Business Apps for emails, and trying to send emails through PHPMailer. Now there is an issue with the SSL certificate so I have to turn off the SSL verification, but this errors is thrown up:
Auth method requested: XOAUTH2
Auth methods available on the server: PLAIN,LOGIN
SMTP Error: Could not authenticate.
Now my host isn't particularly helpful as its saying I need to use the correct email/pass, but that's not the way it works as we have to create an App via Google Developer and the connection is verified.
I am wondering if XOAUTH2 needs to be installed to the server? I have access to cPanel, but can't find the module.
Read the troubleshooting guide that the error links you to.
I'd bet that your ISP is intercepting your traffic and redirecting you to their own mail server, which will fail to match gmail's SSL certificate, and also lacks gmail's XOAUTH2 authentication scheme.
You should pay attention to why you're getting these errors - certificate verification is there to protect you and when it fails a check it's telling you that someone is intercepting your traffic and trying to MITM you - and by disabling it you've already given away your gmail credentials.

Sending via specific SMTP credentials in Rails, whitelisted IP

I want to send mails using specific smtp credentials (those of a Gmail account) from my rails app.
The problem I encounter is that the IP specified in the resulting email is likely to be blacklisted (actually, as I'm using Heroku, it is blacklisted).
Does anybody know a way to send from a whitelisted IP / rewrite this IP, while still using those SMTP credentials?
I tried to use things like Proximo but it doesn't seem to support SMTP...
Thanks,

separate authentication for IMAP and SMTP?

I'm working on an iOS app through which user can read and send messages from his email account.
My question is that once user is logged in into IMAP server for reading mails, he has to login separately into SMTP server for sending mail? or the question can be vice versa, once he is logged in into SMTP server he have to login separately into IMAP server for reading email.
I'm not entirely sure what your question is, but yes. For IMAP/SMTP, the incoming and outgoing components are completely separate protocols, and don't even have to be on the same server (and often aren't: see imap.gmail.com and smtp.gmail.com), so yes, they need to be logged in to separately. Usually, they're the same username and password, but that's not even always true.

Resources