Send mail via sockets / with authentication

From Wikipedia

Jump to: navigation, search



The mail modul of PHProjekt 4.1 offers the choice to send mail with the php function mail() or let the script perform the SMTP dialog via sockets.


Normally no authentication is available with mail() - you have to connect to an open relay server or authenticate to your ISP during login. This new routine provides "POP before SMTP" for mail() and socket. With socket it provides SMTP authentication AUTH LOGIN too.

Socket mail is the way how to send not-very-small attachments running on Windows boxes. For really big attachments there is another limitation: In php.ini max_execution_time is set to 30 sec. by default. Increase it, because the script needs time to perform the whole sending process.

If you don't use "sendmail" or a local mail server: Be online before sending mail - using sockets as well as using mail(). Otherwise PHP will hang and possibly crash your system.

The default setting - use mail(), no authentication - provides the functionality of PHProjekt v. 4.0.

In case of using mail() be sure to do current settings in the mail-part of php.ini and/or sendmail.

The following new settings can be made in the config.inc.php, but not during setup:

  • $mail_mode = 0; // Send via mail() or socket: 0: use mail() (default); 1: use socket

  • $eol = "\r\n"; // end of line; e.g. \r\n (conform to RFC 2821 / 2822)

  • $eoh = "\r\n"; // end of header line; e.g. \r\n (conform to RFC 2821 / 2822)

Caution! Using doublequotes " is essential - don't use singlequotes '!

"\r\n" is the default. Try "\n" only in case of problems. Read about mail() in the PHP manual. This settings are specially made for mail() - until now "\n" isn't seen working via socket.

The settings below can be made in the config.inc.php as default for all users. In case of $mail_mode = "1" users can override it in the mail module with "Options|Accounts":

$mail_auth = 0; //Authentication 0: no auth (default); 1: with POP before SMTP; 2: SMTP auth (via socket only!!)

// SMTP account data (sockets only, but NEEDED in this case)

$smtp_hostname = "localhost"; // the real address of the SMTP mail server, you have access to (maybe localhost)

$local_hostname = "hereiam"; // name of the local server to identify it while HELO procedure

Many servers don't really check it. May be transmitted to the receiver as content of the headers.

// fill out in case of POP before SMTP

$pop_hostname="mypop.domain.net"; // the POP server

$pop_account="itsme"; // username for POP before SMTP

$pop_password="mypw"; // password for this POP account

//fill out in case of SMTP authentication

$smtp_account = "itsme"; // username for SMTP auth

$smtp_password = "mypw"; // password for this account


Index

Personal tools