(選択できるメール送信方式)
$SMTP_host = 'smtp.YOUR-SERVER.com';
$SMTP_port = '587';
$SMTP_option = 'tls';
$SMTP_user = '<メールアドレス>';
$SMTP_pass = '<メールパスワード>'; // Gmailの場合は2段階認証をon にしてアプリパスワードを設定します。
$transport = (new Swift_SmtpTransport($SMTP_host, $SMTP_port, $SMTP_option))
->setUsername($SMTP_user)
->setPassword($SMTP_pass);
$transport = new Swift_SendmailTransport('/usr/sbin/sendmail -t');
$mailer = new Swift_Mailer($transport);
$message = (new \Swift_Message('My important subject here'))
->setFrom([$from => $from_name])
->setTo( $to )
->setSubject( $subject )
->setBody( $mailtext); // , 'text/html'
$result = $mailer->send($message);