How to send a test email over SMTP with Mailgun using telnet? - email

I have configured Mailgun for my domain: blog.kop.com (fake domain), I have reset my SMTP password for this domain on mailgun dashboard.
I usually use the Mailgun API, this is why I want to test the SMTP sending from command line to check that I have the correct credentials, as an example, I'll use the following password:
Username: postmaster#blog.kop.com (guessed by me)
Password: d3bec33d3bc3e333333b3e333a3e33-3a3aa3d3-333ddf3 (given by mailgun)
This is what I do:
Convert the username to base64:
$ echo postmaster#blog.kop.com | base64
cG9zdG1hc3RlckBibG9nLmtvcC5jb20K
Convert the password to base64:
$ echo d3bec33d3bc3e333333b3e333a3e33-3a3aa3d3-333ddf3 | base64
ZDNiZWMzM2QzYmMzZTMzMzMzM2IzZTMzM2EzZTMzLTNhM2FhM2QzLTMzM2RkZjMK
Test send email over SMTP on port 587 (STARTTLS) with telnet client:
$ telnet smtp.mailgun.org 587
Trying 3.93.221.84...
Connected to smtp.mailgun.org.
Escape character is '^]'.
220 Mailgun Influx ready
ehlo blog.kop.com
250-smtp-out-n01.prod.us-east-1.postgun.com
250-AUTH PLAIN LOGIN
250-SIZE 52428800
250-8BITMIME
250-SMTPUTF8
250-PIPELINING
250 STARTTLS
AUTH LOGIN
334 VXNlcm5hbWU6
cG9zdG1hc3RlckBibG9nLmtvcC5jb20K
334 UGFzc3dvcmQ6
ZDNiZWMzM2QzYmMzZTMzMzMzM2IzZTMzM2EzZTMzLTNhM2FhM2QzLTMzM2RkZjMK
535 Authentication failed
Connection closed by foreign host.
It seems that my credentials are incorrect, this is mailgun documentation for sending mail over SMTP: https://documentation.mailgun.com/en/latest/user_manual.html#sending-via-smtp
I also tried using there code snippet and their swaks program: https://documentation.mailgun.com/en/latest/quickstart-sending.html#send-via-smtp
I also have the wrong credentials. I copy pasted the credentials and aknowledged that they are correct.
I already got this issue using the API, the mailgun documentation was providing the wrong api address for europe region. I now believe smtp.mailgun.org is not the right server for Europe region but I can't find anything related to it.
What's wrong with those steps?
Why I am failing to send email?
How can I send email over SMTP with mailgun, starttls and telnet?

When you echo a string you include a newline, but the newline should not be included in the credentials you pass in to SMTP AUTH. Try
printf '%s' 'postmaster#blog.kop.com' | base64
and similarly for the password.
Using bare Telnet sounds like a pretty brittle approach; you really want to use a proper SMTP client to talk to the SMTP server.

For europe, the SMTP address is smtp.eu.mailgun.org.

Related

Can't get outbound email working in self-hosted SugarCRM 6.5

I can't seem to get outbound email working from my SugarCRM installation, with only the message SMTP connect() failed appearing in the logs.
I've set my smtp server to smtp.gmail.com, email address, password, TLS, port 587. When I go to 'Send Test Email' I get the error.
I've set my local hostname, installed openssl, set the host_name in config.php and included it as a referrer in config_override.php. I've also tried setting SMPTDebug to 2 in SugarPHPMail.php but that seemed to have no effect.
When I run openssl s_client -starttls smtp -crlf -connect smtp.gmail.com:587 the output includes Verify return code: 0 (ok) and I don't know where to go from here. I can connect via telnet to that host & port and get a 220 SMTP message back as expected.
I do also have an exchange server available, but haven't been able to get that one working either, and thought Gmail would be more easily-solved.
I'm on Sugar 6.5.26 hosted on Linux (Debian, Raspbian).
Ok I found the solution while looking for the 'Allow less secure apps' setting in Gmail.
I have two-step authentication switched on in my Gmail account, which will obviously complicate things but had slipped my mind. Therefore I needed to use an app-specific password, and not my normal Gmail password.
As soon as I created an app-specific password in Google (at https://myaccount.google.com/apppasswords) and plugged that into the SugarCRM settings, it worked fine. D'oh!

Are IMAP/SMTP credentials always the same as the user's login credentials?

Greetings!
This question pertains to Normal (or Plain) IMAP/SMTP Authentication.
Can we be sure that a user's IMAP username is exactly the same as his full email address? Can the two be different? What about his SMTP username? Can he have different passwords for IMAP and SMTP?
To make things concrete, consider a webmail user, John Doe:
Email address: john.doe#example.com
Login password: foo.bar.baz
Given that John uses the above credentials to sign in with his webmail provider, here's a series of yes–no questions:
Can we be certain that John's IMAP username is john.doe#example.com?
1.1. Could it be john.doe, john or something else?
Can we be certain that John's IMAP password is foo.bar.baz?
Can we be certain that John's SMTP username is john.doe#example.com?
Can we be certain that John's SMTP password is foo.bar.baz?
Can we be certain that John's IMAP password is the same as his SMTP password?
Can we be certain that John's IMAP username is the same as his SMTP username?
I've been looking for these answers for a while now. If you can link to an RFC, that'd be awesome.
Thanks in advance. :)
SMTP and IMAP can be handled by disjoint programs, so no assurances there. Dovecot IMAP for example lets you freely choose to map username against mailbox name.
Certain - no, you can't be certain, as the server administrator can set any policy they like regarding these things.
However, RFC 6186 gives some suggestions. It suggests that mail user agents (MUAs) should first try using the full email address as the username for authentication (in this case john.doe#example.com), and if authentication fails, try again with the "local-part" as username (in this case john.doe). It also suggests that service providers should support authenticating with either of those usernames. This applies to both SMTP and IMAP authentication.
The RFC doesn't say anything about whether the username should be the same for SMTP and IMAP (so if the IMAP server wants the username john.doe#example.com and the SMTP server wants john.doe, that would still be within what the RFC suggests), and it doesn't say anything at all about passwords.
The RFC also suggests using DNS SRV records to find the hostname of the IMAP and SMTP servers given an email address. You can see this in action for Gmail using the dig command line tool:
$ dig +short -t srv _imaps._tcp.gmail.com
5 0 993 imap.gmail.com.
$ dig +short -t srv _submission._tcp.gmail.com
5 0 587 smtp.gmail.com.
That is, the IMAPS server is on imap.gmail.com, port 993, and the SMTP server for mail submission is on smtp.gmail.com, port 587.

Why is the SMTP AUTH extension sometimes advertised as AUTH=<SASL>?

I'm investigating an issue with SMTP AUTH, and I noticed that some mail servers advertise support for AUTH like this:
$ telnet myhost.com 25
Trying 127.0.0.1...
Connected to myhost.com.
Escape character is '^]'.
220 myhost.com ESMTP service ready
ehlo there
250-myhost.com says hello
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-AUTH CRAM-MD5
250-AUTH=CRAM-MD5
250-SIZE 100000000
250 DSN
I expected something like:
250-AUTH CRAM-MD5
but I didn't expect:
250-AUTH=CRAM-MD5
I've read RFC 4954 and some of the associated RFCs, but I didn't see an example with the "=" sign. Can someone tell me why this variant syntax exists, and where it is documented?
not all clients recognize the AUTH capability as defined by the SASL authentication RFC. Some historical implementations expect the server to send an "=" as separator between the AUTH verb and the list of mechanisms that follows it.
The "broken" clients include Outlook up to and including version 2003 and Outlook Express up to version 6.
See http://www.postfix.org/SASL_README.html#server_sasl_authc

Smtp send email with another address

Hi all I have a site where if i want to send an email I have to set the smtp with this configuration:
Enable Advanced Smtp Yes
Auth Mode Login
Username noreply#myserver.com
Password password
Smtp host smtp.myserver.com
Smtp port 465
Use SSL Yes
If I want to send with my smtp settings mail from another address like test#test.it how can I do that? Because my client don't want to see my domain when receive the email but another email.
Is possible?
All you need is an SMTP server with relaying. if smtp.myserver.com has relaying, than you can use a variety of languages. YOu need to modify the >MAIL From: parameter in any which of those languages.
For magento, modify: “/magento/app/code/core/Mage/Core/Model/Email.php"
then under the
public function send() function you need to modify:
->setFrom($this->getFromEmail(), $this->getFromName())
and use
->setFrom("test#test.com")

Smtp server not returning error

I have problem with checking existing of gmail account. For connecting to smtp server i use openssl for Windows. After run i writing next line to connect to server:
s_client -starttls smtp -crlf -connect smtp.gmail.com:587
After connect, i login on server using auth login.
After this i starting to create new mail:
C:mail from:<somegmail#gmail.com>
S:250 2.1.0 OK w7sm27345781wiz.0
C:rcpt to:<incorrectEmail#asas.com> //input incorrect email
S:250 2.1.0 OK w7sm27345781wiz.0
But after input incorrect email server must return error:
550-5.1.1 The email account that you tried to reach does not exist...
Why server not return error?
The sending server accepts your message, for sending, but does not check if the destination is actually valid at this time. That is why you have a success message.
The server is basically telling you: "Ok I have your message and will try to deliver it"
It will be later, when the gmail.com server talks with the asas.com server, that the asas.com server will give an error, at which time you will receive a bounce email from Gmail