Opensource SMTP client with TLS/SSL for Gmail SMTP server. (How to cross-compilation)

     需求:想要能利用Gmail的SMTP server來發信,所以一定要有支援TLS/SSL功能
順便筆記一下
a.我選了這個opensource的STMP Client。Thanks gosu~
http://cleancode.org/projects/email

b.
先試試./configure --build=powerpc-linux-gnu --host=powerpc-linux CC=powerpc-linux-gcc,可惜出現error。
直接./configure,再來改Makefile.

c.查一下有哪些Makefile
[root@new-host-1052 email-3.1.3]# find . -name "Makefile"
./dlib/Makefile
./src/Makefile
./Makefile
把三個Makefile裡面的CC = powerpc-linux-gcc

d.執行./configure時checking for SSL_library_init in -lssl... no

vim configure的script。 改check condition
if test $ac_cv_lib_ssl_SSL_library_init = yes; then --> if test $ac_cv_lib_ssl_SSL_library_init = no; then
  cat >>confdefs.h <<_aceof p="">#define HAVE_LIBSSL 1
或是
vim ./include/config.h
硬改成1
/* Define to 1 if you have the `ssl' library (-lssl). */
#define HAVE_LIBSSL 1

e.遇到email-3.1.3/src/progress_bar.c:137: undefined reference to `rpl_malloc'

google說直接comment out這兩行就行了。
/* Define to rpl_malloc if the replacement function should be used. */
//#define malloc rpl_malloc
/* Define to rpl_realloc if the replacement function should be used. */
//#define realloc rpl_realloc

f.編成功後在email-3.1.3/src可以看到email這隻application。
[root@new-host-1052 src]# file email
email: ELF 32-bit MSB executable, PowerPC, version 1 (SYSV), dynamically linked (uses shared libs), not stripped

確認機器上有openssl的library
g.ls /usr/lib/
libcrypto.so            libssl.so
libcrypto.so.0.9.8      libssl.so.0.9.8

h. tftp 放到機器上。
[root@localhost /sbin]# tftp -gr email 192.168.4.215
email                100% |*******************************|   211k --:--:-- ETA

I.
 email -f"IloveTW@gmail.com" -n"IseeYOU" -s"SONYYO" 
-r"smtp.gmail.com" -mlogin -u"karose.tzu@gmail.com" -i"ycm2uru9" -tls -V "carlos
hsu@embeddedlinux.com.tw" < test.msg 
Connecting to server smtp.gmail.com on port 25

成功的收到信件.........收工!!!!!

留言

Unknown寫道…
請問...下列的狀況..要如何處理呢?

Connecting to server smtp.gmail.com on port 25

email: FATAL: Smtp error: 334 UGFzc3dvcmQ6
534-5.7.14 Please log in via your web browser and then try again.
534-5.7.14 Learn more at
534 5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754 ap5sm11067902pad.22 - gsmtp
karose寫道…
看起來像是帳號、密碼打錯了。
Unknown寫道…
通常是 2-step verificaiton等安全性問題造成,
解法一:
降低自己帳號的安全性: (1)關掉 2-step驗證 (2)設定 Less Secure,但是這樣會讓自己帳號暴露風險。

解法二:
設定 Application-specific password,到自己帳號設定->Security設定區,找到App Passwrod設定處,去新增一個特定密碼,Google會產生一個16位元密碼給你,拿這組密碼去登入通常就可以解決了。
可參考:
http://support.google.com/accounts/bin/answer.py?answer=185833

這個網誌中的熱門文章

Raspberry Pi (ARMv6)上自幹一個微小作業系統

C語言,大數運算,階層筆記

Linux VLAN 筆記