FIrst of all I don't intend to spam - I 'm building email facility in my application and would like to be able to include any email address in the from header of the email while be able to send it from any开发者_运维技巧 mail server i.e like show a yahoo address in the email from field while send it from my own smtp server? Is it possible? I'm using php and zend framework here
Zend_Mail
allows you to specify all that.
Setting up transport (during bootstrap):
$tr = new Zend_Mail_Transport_Smtp($mail_smtp_host, array(
'auth' => 'login',
'username' => $mail_smtp_username,
'password' => $mail_smtp_password,
'port' => $mail_smtp_host_port,
));
Zend_Mail::setDefaultTransport($tr);
Sending a message anywhere in your app:
$mail = new Zend_Mail();
$mail->setFrom($email_from, $email_from_name)
->addTo($email_to)
->addCc($email_cc)
->addBcc($email_bcc)
->setSubject($email_subject)
->setBodyHtml($email_html)
->setBodyText($email_text)
->send()
;
The following works with sendmail and should work with sendmail-like smtp servers. If the from domain does not match the domain of the originating server, the chance of being flagged as spam increases.
$msg = 'my message body';
$subject = 'my message';
$to = 'email@example.com';
$from = "ali@yahoo.com";
$headers .= "From: $from\r\n";
$flags = '-f "$from"';
mail($to, $subject, $msg, $headers, $flags);
You can send through Yahoo's SMTP server.
smtp.mail.yahoo.com
, SSL, port 465, username/password for the Yahoo address.
精彩评论