I have used the solid basis from Surfer Tim on how to send an e-mail from an Arduino for a project.
In order to make the project work, I needed to make the variables Tim is using coded in his example sketch more flexible through reading their values from files in an SD card.
For almost all variables this works fine (own IP address, gateway IP address, subnet IP address etc...)
The files used are simple .txt files containing the IP address in the form of 1.2.3.4
When wanting to make the smtp server IP address flexible too, there appears to be a problem.
The libraries used apparently desire the variable 'server' to be declared in the header, the function IPAddress server( 1, 2, 3, 4 ) is used to do that. (line 28 in the sample sketch included in this post)
Omitting this line in the header leads to an error at compiletime stating that in the mailing-code 'server' has not been declared.
When I later in the setup() section of my code try to read-in the true values to be used that are read from an SD-card file in the same way subnet, ip, gateway values are adapted to their true values, the values given in that section (line 185 ->) are not placed in the server-ip value used by the mailer code, and the server connection fails.
Only when I give the values to be used hardcoded in line 28, the server-connection succeeds.
Can you please let me know how to work around this catch-22 to make setting the SMTP server-IP flexible from an SD card file?
Thanks!
Mailer-Forumversie.ino (8.23 KB)