Mailing

Allikas: Juhised

Description[muuda]

Unfortunately, I cannot set up sendmail nor something similar in order to use my own mail server. Therefore, we use the secure gmail server.

Be aware that gmail only allows to send the same message up to 100 recipients per day! If this limit is reached, you get this error: "SMTP viga: Andmeid ei võeta vastu."

Model[muuda]

As the sending software, we use PHPPGMailer:

					require_once dirname(
						__FILE__
					) . '/../phpgmailer/class.phpgmailer.php';
 
					$mailer = new PHPGMailer();
 
					$mailer->From = 'kaart@tennis24.ee';
					$mailer->FromName = 'EKõTeL-i kaardikeskus';
					$mailer->Subject = 'EKõTeL-i kaardi tellimus';
 
					$toName = sprintf(
						'%1$s %2$s',
						$sender->firstName, // 1
						' ' . $sender->lastName // 2
					);
 
					$mailer->AddAddress($sender->email, $toName);
 
					$mailer->Body = $schoolCardView->buildSchoolCardOrderConfirmationEmail(
						$lastSchoolCard['lastSchoolCard']
					);
 
					$mailer->AddReplyTo('kaart@tennis24.ee', 'EKõTeL-i kaardikeskus');
 
					$resultOSending = $mailer->Send();
 
					if (!$resultOSending)
					{
						require_once dirname(__FILE__) . '/../Error.php';
 
						new Error(
							ERROR_TYPE_USUAL_ROLLBACK_UNLOCK,
							$mailer->ErrorInfo,
							NULL,
							$connection
						);
 
						exit;
					}

It is very important to make a new instance of PHPGMailer for every new mail. Otherwise, new values will be appended not replaced.