Leah Collins
Leah Collins

Reputation: 637

How to read ip address of the incoming emails

I have set a continuous project for my class which is available online for students and parents can interact with. So I ask students to email their project progress everyday. I use imap to get the info and display it online.

I understand email addresses can be spoofed. How can I find out if the mail really did come from yahoo, gmail or hotmail. Which imap function could i use. i tried this

imap_headerinfo($inbox, $emails[$x])

But It does not give me ip address of the servers it passed through.

I appreciate any help.

Upvotes: 1

Views: 1729

Answers (1)

Torxed
Torxed

Reputation: 23480

$mailinfo = imap_headerinfo($inbox, $emails[$x]);
print_r($mailinfo->from);

Should give you: personal, adl, mailbox, and host

Any of the following should help you $mailinfo->...:
(For a full reference, check http://php.net/manual/en/function.imap-headerinfo.php)

->to - an array of objects from the To: line, with the following properties: personal, adl, mailbox, and host

->from - an array of objects from the From: line, with the following properties: personal, adl, mailbox, and host

->ccaddress - full cc: line, up to 1024 characters

->cc - an array of objects from the Cc: line, with the following properties: personal, adl, mailbox, and host

->bccaddress - full bcc: line, up to 1024 characters

->bcc - an array of objects from the Bcc: line, with the following properties: personal, adl, mailbox, and host

->reply_toaddress - full Reply-To: line, up to 1024 characters

->reply_to - an array of objects from the Reply-To: line, with the following properties: personal, adl, mailbox, and host

->senderaddress - full sender: line, up to 1024 characters

->sender - an array of objects from the Sender: line, with the following properties: personal, adl, mailbox, and host

->return_pathaddress - full Return-Path: line, up to 1024 characters

->return_path - an array of objects from the Return-Path: line, with the following properties: personal, adl, mailbox, and host

Why hostname is important: enter image description here

(Sorry for the shaky image, sitting on a train)

Upvotes: 4

Related Questions