Android Question SMTP NET library - How to change MAIL FROM smtp directive (actually taken from user)

MMORETTI964

Member
Licensed User
Longtime User
Hi, we've used SMTP library to send an email through a commercial stmtp service (mail-up).
We need to login with user/password and specify a sender different from user.

Even if we used the sender property, seems the STMP server (postfix) don't read the from correctly (I saw in the postfix log user as sender).

Feb 26 16:16:10 fsteml03 postfix/smtpd[3200]: NOQUEUE: reject: RCPT from unknown[**.**.***.***]: 504 5.5.2 <s66360_1>: Sender address rejected: need fully-qualified address; from=<s66360_1> to=<s******@*********.com> proto=ESMTP helo=<10.10.**.**>

We've tried to use additional header with "Sender" and "From" but the result is the same.

Here our sample code:
B4X:
Dim Mail As SMTP

Mail.Initialize("****.******.com", ***, "s66360_1", "***", "SMTP")
Mail.UseSSL = False
Mail.StartTLSMode = True
Mail.Sender = "****.********.com"
Mail.Subject = "Send email"
Mail.To.Add("s******@*********.com")
Mail.Body = "Body mail"

Log(Mail.Sender)
Mail.Send
There is a way to debug the connection (writing on the log the whole SMTP dialog with the server) or you have some idea?
The same SMTP connection works fine with iOs (Objective-C) and with web application using the same parameters.

Thanks.

Maurizio
 
Last edited:

mindful

Active Member
Licensed User
The .Sender should be an email address not a hostname as you've set it. I am not at the pc right now, but as far i can remember you can set also the .From field as: My Application <user@domain.com> ... try to play with those 2 (.Sender and .From)

Sender address rejected: need fully-qualified address; from=<s66360_1>
You can see in the error that sender addrees requires a full address eg. user@domain.com

I'll post an example when I am at the pc.
 
Upvote 0

MMORETTI964

Member
Licensed User
Longtime User
After a dumping on the ethernet network, what I see:

16:08:36.801874 IP 10.10.10.59.36939 > 93.174.70.16.terabase: P 61:83(22) ack 248 win 65535 <nop,nop,timestamp 93489839 3620661548>
0x0000: 4500 004a 50d3 4000 4006 31d8 0a0a 0a3b E..JP.@.@.1....;
0x0010: 5dae 4610 904b 0fa0 9ac8 da93 e5d0 85a5 ].F..K..........
0x0020: 8018 ffff 81bc 0000 0101 080a 0592 8aaf ................
0x0030: d7ce e92c 4d41 494c 2046 524f 4d3a 3c73 ...,MAIL.FROM:<s
0x0040: 3636 3336 305f 313e 0d0a 66360_1>..

MAIL FROM directive passed from the android device is the user I set with the Initialize code

B4X:
Mail.Initialize("****.******.com", ***, "s66360_1", "***", "SMTP")

Instead, I need the "MAIL FROM" set from sender property:

B4X:
Mail.Sender = "****.********.com"

Maybe I need another function to pass the "mail from" as the library in b4j does or trying to use some other library.

Maurizio
 
Last edited:
Upvote 0

MMORETTI964

Member
Licensed User
Longtime User
Thank for the response. I will try it.

Can I use in the same project both libraries? I already use Net Library (B4A) for FTP communication.

Maurizio
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

MMORETTI964

Member
Licensed User
Longtime User
Yes but I didn't like to re-test all communication in my program (already installed on thousands devices)
My program uses extensively it and even some little changes in the libraries could be dangerous - difficult to discover - blocking application use.

So my chanches is:
* Use b4j NET library together with b4A library
* Use / make / wrap another library waiting while Erel will release a new NET version with that function included.

Maurizio
 
Upvote 0

MMORETTI964

Member
Licensed User
Longtime User
Yes, I know. But as the library is different, I can have different behaviours in some condition / OS / server FTP...
More, the way we use the library inside our code could give different unexpected result than the original B4A library.
It's not so simple as a compilation, believe me.

Maurizio

"I've seen things you people wouldn't believe,
attack ships on fire off the shoulder of Orion,
I watched c-beams glitter in the dark near the Tannhäuser Gates."
 
Upvote 0
Top